delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/23/06:40:52

Date: Thu, 23 Dec 1999 11:53:19 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "mus.bouayad" <mus DOT bouayad AT wanadoo DOT fr>
cc: djgpp AT delorie DOT com
Subject: Re: Djgpp and Nasm
In-Reply-To: <01bf4e8c$665fb700$33e58aa4@kalashnikow>
Message-ID: <Pine.SUN.3.91.991223114526.5945K-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 23 Dec 1999, mus.bouayad wrote:

> Hello,I have still problems with using nasm with DJGPP.
> Here is the code : 
> [...]
> _CLVga:       push ebp 
>               mov ebp,esp 
>                
>               push dword[VideoRAM] 
>               pop es 
>               xor di,di 
>               xor eax,eax 
>               mov cx,0x3E80
>               rep stosd

See section 17.4 of the DJGPP FAQ list.  You must save and restore all 
registers except EAX, ECX, and EDX, otherwise bad things will happen.

Specifically, your code clobbers ES (which absolutely MUST be preserved, 
since GCC-generated code assumes DS=SS=ES) and EDI.

In addition, there might be a much more serious problem here: if VideoRAM 
stores a real-mode segment of the video memory, this will crash in 
protected mode, because in protected mode you cannot load segment 
registers such as ES with arbitrary values, only with valid selectors.  
In this case, you need to use the _dos_ds selector and compute the offset 
as 16*VideoRAM.  (It might be much easier to simply use provided library
functions _farpokel or dosmemput.)

- Raw text -


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