AS.EXE


If you are a beginner at assembly language programming you should click here
As.exe is a GNU public lisence assembler.which comes with GCC c-compiler and mingw.
You can also download it here
It is capable of making real 32-bit executables there are two types which i will talk about.
(i)console apps -- called go32coff
(ii)PE win32 executables.

i have included the docs that i got with them,which are fairly extensive,but it will still be useful for me to give a brief overview of what i have discovered about it.
i have put the version of as.exe which comes with mingw which is the best version for anything,and two linkers.as.exe accepts a plain text file with an assembly language program in it.you should put on the 1st line of this txt file:
.intel_syntax noprefix
this will allow you to write in the sort of syntax in all the intel docs.(like debug.exe),the alternative is to use the AT&T syntax,which has loads of extra symbols in it and the arguments are the wrong way round.to assemble your file just make a dos window,move to the appropriate directory and type:
as yourfile.s
(your file being the name of the txt file to assemble.)Also notice that any hex numbers should be prefixed with 0x , e.g. int 21 would become int 0x21.
this is a C convention for hex numbers.So after you have run as,you will find that a new file has appeared called a.out
this now has to be processed again by the linker.i have included two linkers.
i have included two linkers.
LD.EXE this is from the GCC c compiler. and this one should be used for console apps.programs using this linker may easily use interrupt service routines.the default load address seems to be 18a8.
LW.EXE is the linker that comes with mingw.it was origionally also called ld.exe,but works fine with its new name.you should use this for making windows exe;s.programs made with this cannot use interrupt service routines,but can use windows system calls.(in dll's).the default load address is something like 00400000 hex.
Assembler directives start with a point (.) eg .intel_syntax noprefix
jump labels are used to show the assembler where jumps go to. jump labels end with a colon. eg.
main:
nop
jmp main

note that in the actual jmp command, the label does not have a colon.
the addresses at which you store data are given by memory labels. eg.
main:
lea edx,fred
mov eax,fred
mov ah,0x4c
int 0x21

fred:
.byte 0xde
.byte 0xad
.byte 0xbe
.byte 0xef

the mov command gives eax the data at fred: ie eax==deadbeef.
the lea command gives edx the offset into the loaded executable at which the data is stored, and mov ah,4c int 21 is the way to stop an executable and return control to the opperating system.
other useful data types beside .byte are:
.ascii "hello world"
.asciz "hello world"
the difference is that the .asciz has a zero byte at the end of it.
you can also include another file in your assembly language program,the directives for this are:
main:
blah,blah,balh
 .....
# incidently,comments are written like this (starting the line with a
# ...
jmp main

myfiles: 
# myfiles is just a memory label
.include "/windows/desktop/codefile.s"
# path+filename is quoted,
# use forward slash not backslash in path.
.incbin "/mydata.bin"
The .include directive expects the file to be an assebler source file. i.e. one containing machine instructions, jump labels, assembler directives etc. The .incbin directive is for including binary data. HOWEVER this directive is completely faulty as it seems to use a function which is a bit like LINE INPUT in basic and consequently it often fails to read many bytes like carriage returns and line feeds and also many others. Because the .incbin directive is completely unsatisfactory, I have written a little qbasic script which takes a binary as its input and reads it byte by byte it outputs a file which will be included using the .include directive, and when you assemble your exe file the binary data will apear in it in the correct place. You can download my little bug fix utility here . my script is called MN which stands for 'Make Nice'. it reads the first byte of the binary input file which has the value say 0xn, then it outputs the assembler directive .byte 0xn (carriage return, line feed). then it inputs the second byte and does the same etc. until the end of the input file. the resulting output file can then be included by using the ordinary .include directive which works fine.