我有一个简单的功能使用DJGPP和256的VGA DOS框绘制在C联汇编像素:情节像素VGA与内联汇编
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上翻译它内联汇编工作,我有这个:
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);"
);
}
}
但是我在编译器上得到几个错误。我不熟悉GCC内联程序集,因此在纠正我的代码方面的任何帮助都将得到澄清。
可能的重复[打印字符与C(gcc编译器)中的内联汇编](http://stackoverflow.com/questions/34748733/printing-character-with-inline-assembly-in-c-gcc-compiler ) – Olaf