www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/22/05:04:18

Xref: news2.mv.net comp.graphics.algorithms:20670 comp.os.msdos.djgpp:4125
From: "Matthew J. Freyman" <flatline AT postoffice DOT ptd DOT net>
Newsgroups: comp.os.msdos.djgpp,comp.graphics.algorithms
Subject: Inline ASM, Mode 13h problem
Date: Tue, 21 May 1996 20:44:39 -0400
Organization: ProLog - PenTeleData, Inc.
Lines: 76
Message-ID: <31A26377.29C6@postoffice.ptd.net>
Reply-To: flatline AT postoffice DOT ptd DOT net
NNTP-Posting-Host: cs4-06.all.ptd.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm an experienced C, C++ programmer, but I admit to know little about 
assembly language, especially the AT&T Syntax.  I picked up some ASM 
FAQs and Tutorials off the net.  I've been toying with various graphic 
libs for Turbo C(initially), and more recently DJGPP, and I decided to 
code my own routines so I could get a better understanding of the low 
level stuff.  

Here's my problem:  I managed to set mode 13h under DJGPP v2, and 
restore the text mode, but I am not having luck using the inline 
assembler to work on a put-pixel routine.  

Here's the code:

#include <go32.h>
#include <dpmi.h>
#include <pc.h>

#define VGA256  0x13
#define TEXT    0x03

short glib_current_vidmode=0x03;
short glib_selector;

void setmode(short);   
void putpixel(short,short,short);

int main() {
setmode(VGA256);
putpixel(160,100,4);
while(!kbhit());
setmode(TEXT);
return 0;
}

void setmode(short mode) {
  __dpmi_regs r;
  r.x.ax = mode;
  __dpmi_int(0x10,&r);
  glib_selector = _dos_ds;
  glib_current_vidmode=mode;
}//END SETMODE FUNCTION
  
void putpixel(short x,short y,short c) {
  __asm__ __volatile__("
    movw %0, %%es;
    movl $0xA0000, %%edi;
    movw %2, %%ax;
    imulw $320, %%ax;
    addw %1, %%ax;
    addw %%ax, %%di;
    movb %3, %%es:(%%edi);"
    :
    : "g" (glib_selector), "g" (x), "g" (y), "g" (c)
    );
}//END PUTPIXEL ROUTINE        

I'm developing under RHIDE beta4.  I get an assembler error in the 
putpixel function, and I believe it is with the following line:  
	movb %3, %%es:(%%edi);"  

ERROR:  OPERANDS GIVEN DON'T MATCH ANY KNOWN 386 INSTRUCTION.

I don't know enough about inline ASM to find what I'm doing wrong.  
Most of that function was taken from a snipped of ASM code from a 
tutorial that I converted inline.  

Any help would be appreciated.
  
-- 
***********************************************************
* FLATLINE:              * flatline AT prolog DOT net            *
*   Stone Cold Dream of  *                                *
*   a Dead-Hot Cyberjock *                                *
***********************************************************
* Matthew J Freyman      *
**************************

- Raw text -


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