www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/16/17:31:22

From: "Andrew Crabtree" <andrewc AT rosemail DOT rose DOT hp DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Assembly
Date: Fri, 14 Nov 1997 09:54:15 -0800
Organization: Hewlett Packard
Lines: 67
Message-ID: <64i388$kki$1@rosenews.rose.hp.com>
References: <64hnus$dr9 AT mtinsc02 DOT worldnet DOT att DOT net>
NNTP-Posting-Host: ros51675cra.rose.hp.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019