delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/17/19:02:31

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: rep stosb generates a gpf:-(
Date: Fri, 17 Sep 1999 13:00:43 -0700
Organization: Harvey Mudd College
Lines: 37
Message-ID: <37E29DEB.3961CD69@hmc.edu>
References: <Pine DOT SOL DOT 3 DOT 96 DOT 990915144809 DOT 14092B-100000 AT giasbgb>
NNTP-Posting-Host: mercury.st.hmc.edu
Mime-Version: 1.0
X-Trace: nntp1.interworld.net 937598425 15251 134.173.45.219 (17 Sep 1999 20:00:25 GMT)
X-Complaints-To: usenet AT nntp1 DOT interworld DOT net
NNTP-Posting-Date: 17 Sep 1999 20:00:25 GMT
X-Mailer: Mozilla 4.61 [en] (X11; U; Linux 2.2.13pre7 i586)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Santosh H." wrote:
> 
> Hi,
>   I was trying today to port some of my graphics functions I'd written for
> borland C to DJGPP(why prot mode u knucklehead!sorry:-)).Right , So i have
> a procedure which i converted from TASM to NASM syntax.the procedure is as
> below
> 
> _Drawhorizline:
>    push ebp
>    mov ebp,esp
>    push es
>    push ds
> 
>    mov es,_VideoSegmentSelector ;which I get by push word 0a000h
>                                                call ___dpmi_segment_to_descriptor
>                                                mov [_Videosegmentselector],ax
>    mov di,0                ;0 just for eg
>    mov cx,80
>    rep stosb              "BANG!"<-generates a gpf

You're in 32-bit mode now, but you're only loading the low 16 bits of
edi.  The high half still contains garbage.  The same goes for ecx.  You
want to do:

mov edi, 0
mov ecx, 80

Btw, "rep stosd" will be on the order of 4 times faster, since it moves
4 bytes at a time instead of 1.  You'll just have to duplicate the value
to be stored (from al) 4 times in eax.  This is left as an exercise for
the reader. :)

-- 

Nate Eldredge
neldredge AT hmc DOT edu

- Raw text -


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