These are some issues which bothered me a lot when I started to code ASM. I hope to note down and share it with people.
The first fact on ASM tutorial and sample code for beginners, most of them are written for 16 bit environment!!! And, what does that mean? it means you have to compile them with 16 bit assembler and link them with 16 bit linker. If you happen to start with Microsoft MASM v8 (like me), you may use the 'ml.exe' for 16 bit or 32 bit code assembling by a command option switch, however, the default 'Link.exe' included with the package is a 32 bit linker and it does not link 16 bit object files!!!
so??? so you have to download a separate 16 bit linker(supposeably, 'lnk16.exe'), and put it in the /bin directory of your assembler installation, and specifically use it.
now that is how your compile your 16-bit code,
C:\masm32\bin\ML /c /Cp /nologo /I"C:\masm32\include" A16bit.ASM
C:\masm32\bin\Lnk16 /SUBSYSTEM:CONSOLE A16bit.obj /o A16bit.exe
(the /c option force the ML.exe to do assembling only, no linking.
/Cp keep user case sensitive symbols)
or alternatively, you can compile and link in one go,
C:\masm32\ML /Bl .\Lnk16.exe /SUBSYSTEM:CONSOLE /Cp /nologo /I"C:\masm32\include" A16bit.ASM /o A16bit.exe
then how do we compile 32-bit code? using the /coff switch. This is how you compile them in one go,
C:\masm32\ML /coff /Cp /nologo /SUBSYSTEM:WINDOWS /I"C:\masm32\include" A16bit.ASM /o A16bit.exe
(this will use the default 'link.exe')
There are actually quite a lot of options for ML and link, and you can find them out by
ML /?
link /?
2007. June. 11
some more comment regarding the 16bit issue, when you see the following code snippet in asm, they mean to be compiled by 16 bit environment,
==================
mov ax, code ; or mov ax, @data
mov ds, ax
mov es, ax
==================
such statement is NOT allowed by 32bit compilers. Under 32 bit environment, segment concept is totally different.