Mail Archives: djgpp/1999/12/23/06:40:52
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 -