delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/12/22:15:31

From: sochaxx AT flash DOT net (art socha)
Newsgroups: comp.os.msdos.djgpp
Subject: more NASM/DJGPP HELP please...
Date: Thu, 12 Mar 1998 20:58:59 -0800
Organization: Flashnet Communications, http://www.flash.net
Lines: 39
Message-ID: <MPG.f725cee3ea1c20298968b@news.flash.net>
NNTP-Posting-Host: iasc1-58.flash.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

okay. so i got video mode 320x200,256 going with nasm/djgpp. next 
problem... should be simple but... i'm probably just blind...

calling a procedure from djgpp like so...

for(y=0;y<199;y++)
 for(x=0;x<319;x++)
  plot(x,y,15);

neat. here is the assembly procedure.

global _plot ;called from c    plot(int x; inty; char col);
_plot:
        push    ebp
        mov     ebp,esp             ;point to stack
        xor     eax,eax             ;eax=0
        xor     ebx,ebx             ;ebx=0
        mov     word eax,[ebp+10]   ;eax = y
        mov     word ebx,[ebp+8]    ;ebx = x
        xchg    ah,al               ;y * 256
        add     bx,ax               ;bx = (y*256)+x
        shr     ax,2                ;ax = (y*64)
        add     bx,ax               ;bx = (y*320)+x
        add     dword ebx,[_vid]    ;add our offset to the video pointer
        mov     byte al,[ebp+12]    ;al = color
        mov     byte [ebx],al       ;draw it!
        pop     ebp
        ret

the _vid address is defined and calculated in the c program. this is the 
flat address of the video segment and works perfectly.

the problem is that apparently i'm not getting my x,y, nor color from the 
stack. according to logic, since we are using 32-bit addressing now, 
[ebp+8] should point to the first parameter. I confirmed this in the 
NASM.DOC file as well. Anyway, I'm stumped for now... I need to find a 
good Protected Mode Debugger so I can see what's going on (if you know of 
one lemme know where to get it eh?) and in the meantime if you have any 
ideas for the above...

- Raw text -


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