I have a simple function to plot a pixel with inline assembly in c using djgpp and 256 VGA in DOS Box:
byte *VGA = (byte *)0xA0000;
void plot_pixel(int x, int y, byte color){
int offset;
if(x>32 && x <=320 && y>0 && y<180){
//x=x-1;
//y=y-1;
if(x<0){x=0;}
if(y<0){y=0;}
offset = (y<<8) + (y<<6) + x;
VGA[offset]=color;
}
}
I´m working on translating it to inline assembly and I have this:
void plot_pixel(int x, int y, byte color){
int offset;
if(x>32 && x <=320 && y>0 && y<180){
//x=x-1;
//y=y-1;
if(x<0){x=0;}
if(y<0){y=0;}
// offset = (y<<8) + (y<<6) + x;
// VGA[offset]=color;
__asm__ (
"mov $0xA000,%edx;"
"mov $320,%ax;"
"mul y;" //not sure how to reference my variable here
"add x,%ax;" //not sure how to reference my variable here
"mov %ax,%bx;"
"mov color,%al;" //not sure how to reference my variable here
"mov %al,%bx:(%edx);"
);
}
}
However I´m getting several errors on the compiler. I´m not familiarized with the GCC inline assembly so any help in correcting my code will be apreciated.