Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE3013574DD@probe-2.acclaim-euro.net> From: Shawn Hargreaves To: djgpp AT delorie DOT com Subject: Re: Problem with following code Date: Thu, 29 Apr 1999 16:51:10 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.0.1460.8) Content-Type: text/plain Reply-To: djgpp AT delorie DOT com nchuming writes: > void putpixel(int x,int y,unsigned char color) > { > int vid_descriptor; > > vid_descriptor = __dpmi_segment_to_descriptor(0xa000); I would recommend using the existing _dos_ds selector instead of this, or if you want one that can't write outside the video memory, allocate your own selector and then free it at the end of your program. It will be terribly inefficient to make this call for every pixel that you plot, and also not very polite to the DPMI server to use this call that allocates non-freeable selectors (they are a scarce resource). > __asm__ __volatile__ > (" > movw _vid_descriptor,%%es _vid_descriptor is a local variable, so you can't access it directly like that. I'm surprised that you don't get link errors with this code! You need to pass it as an argument using the extended asm syntax, or make it into a global. > xorw %%di,%%di > movw %1,%%ax > imulw $320,%%ax > addw %0,%%ax > addw %%ax,%%di > movb %2,%%al > stosb There are a couple of problems with this: - You are only filling the 16 bit registers, which isn't enough in a 32 bit program. Replace all register names with 32 bit versions, eg. %di -> %edi, and change the w opcode suffix to l. - You change %es, but don't restore it. Instant crash results. This whole thing is an unnecessarily complex way to plot a pixel, though. You could rewrite it much more simply as: _farpokeb(_dos_ds, 0xA0000+offset, color); Shawn Hargreaves.