                            Intel Assembler Manual
                                    V0.51
                      Era Scarecrow / rtcvb32@coffey.com

Table of Contents

1) Introduction

2) Using the program
+Numbers:
|_Hexadecimal
|_Decimal
|_Octal
L_Binary

Types and Examples, and uses: (compiler)

+Distance:
|_SHORT
|_NEAR
L_FAR

+Byte's Sizes: (defining)
|_BYTE
|_WORD
L_QUAD

Labels:

Programming Formats:

Assembler Odds and Ends:

3) Debugging

4) Compadible Instructions

5) Other Assembler peices

6) How can YOU help?
------------------------------------------------------------

1) Introduction

 I have copied most of this information from my previous assembler's
manual, since it was close to correct, and adjusted what was nessisary.

 I would just like to introduce this product as it is, and like to tell
you a little about it. This is Intel Assembler. I have built this for use
with IBM computers, and I have had to start from scratch to get it done.

 But Now that it IS almost done, there are only little bugs to fix along
the way. I have various notes on the program, but these I won't get into
detail on it. If you want to understand the program, read it.. Want to use
the program? Simple, just put 'intelasm IN OUT'. The IN, should be a source
code, the OUT should be what you are writing to.

 My previous assembler (V.21 - V.27) was too large to compile in an EXE,
since it was written in QBASIC, but this version was compiled into a COM
file. Why? Well, it's all i need right not. Sides, i don't see any
difference in control just yet. This newer version has all of the older
compadibility (from the .27 one) to this one. Newer features added, more
instructions, more power, and one important element missing before. SPEED.

 I suggest using a good debugger program, as that is invaluable when
coding. One suggestion, is to use "INT 3" a lot, when debugging, it will
stop the code and let you examine the results. When would you want to use
those? well, a good example is this little line of code i have used
various times.

        int 3   ;check before start
        xor ax,ax       ;clear write (0)
        mov cx,ax       ;clear count (65536)
        mov si,ax       ;loation (0) All
clear:  mov [si],al     ;clear
        inc si          ;move up one
        loop short clear;looping now
        int 3           ;ok, see after it's done

 You don't want to click T, for the tracer in debug about 195,000 times..
Do you? Sides, the debugger takes longer to write the line on the screen,
then it does to do the whole job :P. Don't worry, if you leave your INT 3
in the code, usually MSDOS leaves that clear, so nothing happens. Unless
something is left by a debugger, or by your program.

 Also this is FREE software.. Open source, I hold nothing back, and I think
more people should do this. I show this open, free, change as you like, and
do as you want. Just give the appropriate credit to me for the work. Any
changes done by you can be noted. I suggest in the history file.

 And this is to be used under the GPL license.

 This assembler has been completed and compiled, V0.51 on 2/15/02.

 Enough rambling.. on with the next part.
------------------------------------------------------------
2) Using the program

 This will be extensive notes on the assembler, and what to do and what NOT
to do. But every program has it's quirks, right?

 I will try and put this in the most logical order, and some of this
information can be noted from the history file. (History3.txt) This history
file tells what I have worked on, and when.

 ALSO a brief note.. In my previous assembler, it only supported HEX for all
the information. This made it troublesome for some programming. BUT in this
version, these formats are supported. (DECIMAL is default). An important
note to keep in mind, is that every number must start with a number. so
 CCh is a text, but 0CCh is a number. the computer uses the first digit
to help identify number types.

 HEXADECIMAL:
 This format is well known in the computer world. It's 0-9 and A-F, going
16 total numbers (0-F) It's most known in these two formats.
Hex (6) + Dec (10)

0x0000 - 0x This format, I have no idea where it came from, but the X
         identifies it as HEX.. I have seen it done, so I just added it.

0000h  - H  This HEX format is most common. Add the H and it's hex.

 DECIMAL:
 Decimal, Is a format we ALL use naturally. This format is the default one
of them all. I am NOT going to change this... Unless someone likes using
HEX or something else, and then I suggest you STILL use the symbols.

 Dec (10) doesn't use any symbol, so it's on it's own

 OCTAL:
 Octal, is a format used a little different, unlike the others, this has
only 8 (OCT) different choices. Also, it only uses 3 bits, so be sparring,
as it can easily make calculating certain bits hard.

0000o  - O  O, Rarely used, it didn't need much to tell it apart.

 BINARY:
 Binary, this is the SMALLEST format known on computer scales. done with
2 numbers (BI) 0, and 1. This doesn't change, but with a line of these
numbers you can get any number you want. used mostly for multiplying or for
certain results that you need a certain bit on, and all the rest off.. or
certain bits on.

0000b  - B  This format is the only one I know of. Uses 0's and 1's, and
            It does the rest.

 NOTE:   Due to advancement in my code for the number processing, it can
         do complex calculations now. No, don't use () in your code, and
         it doesn't do floating point.... yet... So you can do this.

         MOV, 256*4 ;Area size for pallete

         Without floating point (FPU) i have added 2 divisions. / and \
         but / is Divide
         and \ pulls the remainder. Same as MOD. example

         100 / 3 = 99
         100 \ 3 = 1

--------------------Types and Examples, and uses--------------------

(These types are used before the name)

 ^ - 1 byte
 @ - 2 bytes
 % - 4 bytes

--------------------------------------------------------------------------
 ^: This symbol I choose (I don't know why) for 1 byte. It is for labels
    that don't require a lot of space, simpler, and will help with some
    debugging issues.
--------------------------------------------------------------------------
 @: This symbol I have chosen, works for 2 bytes. This is based off the
    Quickbasic's format choosing of 16 bits. It was also used in my
    previous assembler, and does for most labels.
--------------------------------------------------------------------------
 %: This Symbol, is based off Quickbasic's Format for 32 bits, and will be
    used as such. It's also the default choice for LABELS that are for
    memory locations. This does well with 32 bit memory usage. it can also
    hold large numbers. (use this as default unless you want to do otherwise)
--------------------------------------------------------------------------

NOTE: In a later version, I may add certain support for these symbols, so
      you don't have to use BYTE, WORD, or QUAD to get certain tasks done.
      But for now, those are assumed by the size of the number being moved,
      unless overridden.

 Using them:
 This is simple enough. Just put the type on, and then an answer.
[type]Name number

@Opened 10000       - is 10000
^Opened 10000o      - is 4096 (too large for a byte)
%Opened 100000111b  - is 263

NOTE: names and labels are just that, they are replaced by the numbers they
      represent. So 'MOV [somestuff+3],AX', although it will work.
      make sure the values are what they should be. if somestuff is 226h,
      then to the compiler, it would be 'MOV [226h+3],AX'

--------------------Distance--------------------
   Short, 127   forward and 128   back (not including the size)
   Near,  32767 forward and 32678 back
   Far,   Direct, 16 bit offset, 16 bit segment address
   Ptr,   is a pointer (uses one of the other codes to help it point)
These are simple and to the point. 

 These are to be used with distance related jumps, loops, commands, and
anything requiring change. It is no longer assuming NEAR, but will work
with what you tell it. If you want the smallest size in jumps, the
optimized will get the smallest, and the Quick, will assume NEAR.

Example:
Jmp Short blah  ;this will do a short jump to blah. But if the jump is
                ;too far away, it returns 0, failing the jump

and if you do
je helloworld   ;this assumes the size of the number. in this case, NEAR..
                ;nothing is wrong, but it's 2 bytes larger, and it uses
                ;the 386+ set, so it's compadibility is broken.
                ;but i have added compadibles for 286 instructions.

--------------------Byte's Sizes--------------------
 BYTE - 1 byte big, smallest combined data format
 WORD - 2 bytes long
 QUAD - 4 bytes long. (386+)
 DWORD- 4 bytes long. (Same as Quad)

 This is used with undefined formats.. like the following.

 Mov [1000h],12 ;this has 12, but is that a byte, word, or doubleword?
 use this:
 MOV BYTE PTR [1000h],12 ;and it is defined for the compiler

 If not defined, the size of the number will define it, so the computer
 would have assumed it byte, but if you put in Byte, it will make sure it
 stays that way.

NOTE: In my programs, i don't see a use for PTR, but you can use them anyway
      for compadility if you want.

--------------------Labels--------------------
 Labels is one of the easiest ways to set up pointers for jumps, data and
other important stuff. Most locations are put under 32 bit ones for later
compatibility.

 I've added support so you can change the codes of the labels at any
time you want. the most common use is changing CPX, and adding subtracting
as nessisary. (although you now, can do this to any of the labels. But don't
unless you know what you are doing.)

Examples:

 %cpx 100h      ;256 location start
 +cpx 55        ;add 55
 -cpx 26        ;minus 26
 %cpx 10        ;reset to this number

--------------------Programming Formats--------------------

 The programming is done in different ways, but the most used is this format

Label: Instruction / information ;comment
So this is legal
TESTING: rep movsb          ;move 1 byte at a time

NOTE: Rep is actually another instruction, but it's only used with certain
      data transferring/scanning instructions.

 In my previous format, I didn't see the use of the format at the time, and
you had to do it like this.

TESTING:
rep
movsb

 This, although not hindering, does get irritating. It takes up extra room,
it's chunky, it's pointless... but it had to be used in my previous programs.
I have updated the L-fun.bas to support the new format, and the old format
is still supported, it's just not as... obvious...

Assembler odds and ends:

--------------------------------------------------------------------------
 CPX - This is a REALLY special instruction. It isn't part of the 386
       instructions, rather.. It is part of the compiler, it tracks the
       length and position of each character, giving label's their proper
       locations, and helps with certain tasks. I use it at the end of
       the program quite often, to make structures (without taking up space)
--------------------------------------------------------------------------
 $   - This, is another prefix, like the ^, @ and %. The difference, is this
       is yet another counter. It's treated like a label, but what's special
       about it, is it counts the distance between the last label used, and
       the current label name.
Ex:

Label: db "Testing",13,10
$label1

 This will make Label1 have the value 9, using the 32 bit counter. (just
in case something memory wise :) )
--------------------------------------------------------------------------
 #   - Includes. This is a bit different then other compilers, but in a
       way, very familiar. what it does is open a file for includes, but
       doesn't get anything. This is linked closely with the !.
Ex:

#somefile.txt

 It just opens the file for it, nothing else. read along :)
--------------------------------------------------------------------------
 !   - This takes a certain subroutine, and copies it to the end of the
       assembly file. Or, it will copy it to the location you put the
       <INCLUDE> in at. This is useful for certain types of files, and you
       don't have to copy and paste.. just add in, and it works.
Ex:
#somefile.txt
!Add2things

 NOTE: if you use CPX at the end of your program, like I do sometimes, it
       can REALLY mess up the program. Make a habit of making those at
       the end of the file, but with includes go on the end, so it's
       confusing. With the <INCLUDE> it will add all the includes to that
       location. If include is not there, it goes to the end.


--------------------------------------------------------------------------
 *   - This is a different include, it takes ALL the subroutines in a file
       and adds them onto the program. There is no checking to see if labels
       are used again, so be careful. It's also added to the location that
       THE LINE IS AT. So if you put this in on the first line, it will
       include a bunch at the beginning.

Ex:
*Somefile.txt

 NOTE: On ALL includes, after the information is posted on, all the
       information directly following the !,#, and *'s are deleted, and
       a temp.asm file is made where it is all processed.
--------------------------------------------------------------------------
 L-Fun.bas - THIS program is a really useful essential. For my assembler,
             it tracks the subroutines, and where they are. and the length,
             but that is quite limited on it's own scale. Here's how you
             use it.

Get some subroutines.

test1: adc [bx],4
ret

test3: sub [si],2
ret

 These will do. Now at the VERY beginning of the file, add these codes.
!test1
!test3
 These codes are actually the !'s and the first label of your subroutine.
Put them in order as they are in the file, and when it gets to the next one,
it will keep them in order. So when you run L-Fun.bas, you will get this

!test1 3 5
!test3 6 8
test1: adc [bx],4
ret

test3: sub [si],2
ret

 Simple as that, and now my assembler will work with then.
--------------------------------------------------------------------------
 FASTFILE - I almost forgot about this. This is a feature I added for
            programmers, who when they make a product, ready to compile,
            the ones compiling it doesn't have to wait nearly as long. I
            know that most of the time is used getting it ready for making,
            not making it. So, this skips all that, and gets it all done.
            to use?

            When using a FASTFILE, ALWAYS use O option with it.
            You can use the Q, or lack either, but if you do, remain
            consistant. Otherwise the fastfile will cause more problems then
            it helps with.
------------------------------------------------------------
  "XXX"   - I need to tell you about this. This feature is a little
            different, when you use codes (like MOV) you can use this
            code for comparing, moving, changing, subtracting, adding..
            For Example.
mov al,[bx] ;grab number
sub al,"0"  ;Kill ASCII and make real number
add bx,ax   ;Add?
add al,"1"  ;increase by 1? (I don't know, this is example code!!)

 OR

; (LCASE)
LCASE:          mov al,[bx]       ;grab letter
                cmp al,"A"        ;see if in range
                jb short skipall  ;skip
                cmp al,"Z"        ;see if in range
                ja short skipall  ;not in range
                sub al,"A"        ;Kill Big letter,
                add al,"a"        ;Make Small Letter
skipall:        ret

 Does this look simple or what? :) rather then knowing "A" is 41h,
and "Z" is 5Ah and "a" is at blah blah... (don't forget labels too :) )
(this is one of the best features I could have put in)

NOTE: when it subtracts from ""'s they are turned into numbers before
      hand.. so if you have "S" (53h) you take away 41h from it and get
      12h, then add "a" (61h) and you get "s" (73h) cool huh?
      Also, to the computer, the text is turned into a number, so you can
      subtract two texts together. What purpose that holds, i am not quite
      sure.

------------------------------------------------------------
3) Debugging
 I would take a note now that most problems are from unknowingly setting
up something the computer hasn't completely understood. For example, making
a jump to a label you haven't added. Until it IS added, it will treat it
like a number, rather then a link, and it will try to jump to some far
position rather then a short or near jump it should be.

 To help on this, Compile your code, using QT. that is QUICK, and TEMPS,
this will allow it to keep your temp files, so you can look them over and
see what went wrong. Sometimes it's obvious, sometimes not. Also, the code
is put into a file called DEBUG.TXT, which will say what the computer used
to make the file. The compiler puts in notes on your code so you can
optimize it, and find bugs.

 Now, there are a couple debugging features. Not many, but they can greatly
help you when you are working with your code. these are the features
--------------------------------------------------------------------------
 Debug.txt - This text is made after EVERY compiling. It overwrites all
             data previously entered in there, it tells the locations of
             the instructions, the size, and leaves notes from errors it
             finds. Some errors can be ignored. It doesn't include the
             label names, just straight assembly code
             (as the compiler sees it)
--------------------------------------------------------------------------
 DB.com    - This breaks a file apart into it's Hex formats, one byte at a
             time. This is ALL it does. Use this for files you are working
             with, the programs you build, and others to see what's going on.
             (I use DB for other purposes too)
--------------------------------------------------------------------------
 Justice   - This Qbasic program is unique, it makes a few line codings,
    &      - and compares the data to your code. It will then write out
 Justice2  - anything that's not exact. (Justice 2, is a little more
             complete, but slower.
--------------------------------------------------------------------------

 These are all the debugging tools I have for your programs right now, I
highly suggest using a debugger program, like debug.exe until you know
what's going on. and fix it. it's a great help. And the more you learn from
your mistakes, the fewer mistakes you will later make.

------------------------------------------------------------
4) Compadible Instructions

 This is an important subject, and i should mention it briefly. In coding,
sometimes you want instructions to be compadible to the 286 and before. So
you can't do that with certain instructions, right? Yep. But there are a few
that you can do, with the work of 2 or 3 instructions. But who wants to look
through and find all them and replace them? No one.

 So, i have devised, and written in as part of instructions for those. The
easiest example is that of the Jumps. Example:

 JE NEAR PACMAN         ;386 instruction

 If you wanted this to work in 286, you'd have to do this
 jne short jmptemp1
 jmpe near pacman
 jmptemp1:

 For one instruction, no problem. For 50 - 60? and not knowing where they
are all at? That's almost impossible. So, i have already devised the versions
the instructions will work at. When they don't work, it looks for others that
might work, and when it finds them, it uses them. So it already does the
work for you. Go into my comptest, and add the line at the very beginning.
 <.186>
 And save it, and compile it. The file will be bigger, but run just the same.
 It does all the work for you :)

 I've added other instructions like that.

  LOOP NEAR. Companion to LOOP SHORT, but doesn't exsist. So uses 3
             instructions, only 2 will ever be executed at 1 time.

  Jxxx NEAR. Jump on condition, NEAR is for 386, not 286. So the work took
             up extra bytes to do. in a short, it's 2 bytes, 4 for 386, and
             5 for compadible.

  XLATB      a good instruction, MOV AL,[BX+AL]. That's the formula.

  XLATW      Doesn't exsist, but i made the macro for it. since it's working
  XLATQ      with the larger then 1 byte, it adjusts itself for that size.
             So, for W it's that number jumping every 2 bytes, and for Q
             it jumps every 4 bytes.

  FPU / MMX  I have added these instructions in, but i haven't tested them.

------------------------------------------------------------
5) Other Assembler peices


 From some assemblers are codes in the source to help the compiler with
it's work. Like, what kind of computer is this for? Where does the code
start at? Is it using these or these codes? this will help define these.

 ALL of these specials will start with < and end with >.
And all of these codes, you don't need more then the first symbol or letter
to get it to do it's work. Example, '<I>' '<INCLUDE>' will both do the same
thing.

 <INCLUDE>  -  include here             (for includes and addons)
 <.386>     -  CPU version.             (Adapted from MASM)
 <16 BITS>  -  envirment to work in     (Real Mode)
 <32 BITS>  -  envirment to work in     (Protected mode)
 <ORG 100H> -  Originate. Start of code.(Adapted from MASM)

 Also, for most of my work i tend to do this at the starting of the code.

 %cpx 100h      ;identicle to <ORG 100h>

 For the moment, the compiler will assume all functions on.
 And assume this unless you state otherwise.

 %cpx 0
 <16>
 <.586> ;actually a lot higher, but that's for all the functions.

 Other features.
 +Addition & Subtraction of labels
 +Auto delete of temp files
 +Capable of handling FPU and MMX instructions
 +Code and Instructions in 1 Executable
 +Emulated functions                    (Compadibles Ect)
 +Enhanced Envirment
 +Getline Function                      (Fast Getline, fewer Dos requests)
 +Math Functions in number lines.       (Real math calculations (NON FPU))
 +More Instructions                     (always adding more)
 +Optimized Code                        (For jumps)
 +Unicode Compadible                    (Incomplete, Untested)
 +Supports Old and New CLCR ending types
 +Use different Instruction Sets        (Architecture Crossover (Limited))

------------------------------------------------------------
6) How can YOU help?

 This is Open Source Software, so you can distribute it to everyone, freely,
but DON'T change the contents of this zip file, or the actual programs.
And is under use of the GPL License. (see the 'copying' file)

 If you want to help, if you see any odd bugs, or happenings, write me
about it, what instructions you used, anything really odd that was
happening, and your thoughts on it.

 If you really like my product, and although I am not one to charge for
my services, or for my work, if you really appreciate my work, you can
send $20 (more or less, it's up to you, and Voluntary) to:

 Ryan Cecil
 1203 16th St.
 Wheatland WY, 82201

 Thank you for reading my manual and using my products :)

 Era Scarecrow / Ryan Cecil      4/11/02
