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

Date: Sun, 16 Nov 1997 19:21:41 -0800 (PST)
Message-Id: <199711170321.TAA02300@adit.ap.net>
Mime-Version: 1.0
To: "Risto J. Sutinen" <risto DOT sutinen AT pp DOT inet DOT fi>,
"'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Could someone help me with Nasm module linking?

At 05:35  11/16/1997 +-200, Risto J. Sutinen wrote:
>I have tryed to compile and link following source files using Nasm and DJGPP. 
>So far I have got only error messages. What the heck is wrong?? Someone
help me 
>out please!

>[EXTERN _color]
>[GLOBAL _Fillscrn(int color)]
                  ^^^^^^^^^^^
Unless this is a new extension to NASM that I haven't heard about, parameter
passing can't work automatically. Also, the EXTERN makes it think `color'
will be a global variable, not an argument. You'll have to just declare
`Fillscrn' as a normal GLOBAL and then get its arguments by their stack
offset. I believe the first argument is 8 bytes up on the stack (above the
return address and the pushed ebp).
>[SECTION .text]
>
>;prototype: Fillscrn(int color);
>
>
>_Fillscrn:
>        push    ebp
>	mov	ebp, esp
>	
>        mov     ax, 0A000h
>        mov     es, ax
This looks like 16-bit code. You can't access conventional memory just by
loading its segment part into a segment register. You'll need to load the
`_dos_ds' selector into es for this to work (this could be tricky since
`_dos_ds' is a macro alias for a struct field), then use the video memory's
linear address and use the 32-bit form of movs. Here's a quick example (not
tested):
; Load es with _dos_ds somehow
mov edi,0A0000h  ; note 4 trailing 0's!
mov ecx,320*200/2 ; use ecx instead
rep stosw
>        rep     rep stosw
What is two `rep's supposed to mean? I think you only want one.
Also, if you use `stosd' instead, it will do 32-bit stores and work twice as
fast. You'll have to use a little cleverness to fill eax with bytes of
`color' (hint: use another register and `rol eax,16')...

>extern void Fillscrn(int color);                
Declare this as `extern "C"' to avoid confusions from the C++ compiler's
name mangling.
>
>void main(void)
`main' should always return `int'.
>        void Fillscrn(t);
The `void' is not valid syntax; I think the compiler will think it's a
declaration. `Fillscrn(t);' is sufficient.

HTH

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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