Mail Archives: djgpp/1997/11/16/17:31:22
>Now, I believe I can figure out the
>syntax differences but, my problem is understanding the differences between
>16 bit real mode and 32 bit protected mode.
The syntax differences between TASM and NASM are fairly trivial.
Also, the differences between assmebly programming in 16 and 32 bit
mode aren't that bad either. What is difficult, is interacting with DOS
(such as calling the DOS print function). This is changed in a major
way, since you must go through a DPMI server. Probably much easier to call
the
printf function.
> For example, this piece of code
>is supposed to print "hello world" to the screen (and yes, I know a printf
>function in C would be much easier but, just entertain me, ok...?)
>
>.model small
>.stack
>.data
This is from memory so you will need to check my directive syntax.
If you want to generate a standalone 16 bit com file (like tasm would do)
try this.
Ditch this stuff. I think you want to do a
[bits 16]
[section text]
[org 0x100]
>
>Message db "Hello World$"
>mov dx,OFFSET Message
>mov ax,SEG Message
>mov ds,ax
You can assume that ds is loaded properly I think. Just use
mov dx, Message
Don't muck around with OFFSET and SEG. Or use a lea call.
>mov ah,9
>int 21h
>mov ax,4c00h
>int 21h
This is OK.
>If I try to compile this in NASM, I get errors galore. I believe I know
how
>to fix some of the problems but, others just elude me. If anyone could
>explain how to modify this to get it to work with NASM, compiling it as a
>coff obj file and then linking that in DJGPP, I'd much appreciate it.
To get a dj coff file you should do the following.
set bits = 32.
don't use a '$' terminated string. Thats for dos only.
Call printf. Just push the offset of Message onto the stack and call
_printf. Also,
remember to use 32 bit registers. Last, I'd make your routine a function,
and have
a main routine in a separate C file and call it from there.
HTH
Andy
- Raw text -