Page 1 of 1
plotting a pixel in VGA
Posted: Sat Sep 23, 2006 2:13 pm
by piranha
I have 2 questions:
1) How do you change graphics modes in Pmode?
2) How do you plot a pixel?
Help me please!
thx
Re:plotting a pixel in VGA
Posted: Sat Sep 23, 2006 5:26 pm
by fascist-fox
1. Use V86mode. Check here for more info:
http://www.mega-tokyo.com/osfaq/How%20d ... %20mode%3F
2. Check out this tutorial:
http://www.brackeen.com/home/vga/
covers everything from basic pixel plotting to primatives such as rectangles
Re:plotting a pixel in VGA
Posted: Sat Sep 23, 2006 7:15 pm
by piranha
so, here is what i have:
asm ("mov ah, 0\n\t"
"mov al, 13\n\t"
"int 10\n");
the problem is that the compiler outputs this:
/tmp/ccKWd5AP.s:124: Error: too many memory references for `mov'
/tmp/ccKWd5AP.s:125: Error: too many memory references for `mov'
/tmp/ccKWd5AP.s:126: Error: suffix or operands invalid for `int'
whats the problem?
Re:plotting a pixel in VGA
Posted: Sat Sep 23, 2006 7:22 pm
by fascist-fox
You need to use AT&T syntax if you are using GCC since it is then compiled by GAS
asm ("mov $0, %ah\n\t"
"mov $13, %al\n\t"
"int $10\n");
Re:plotting a pixel in VGA
Posted: Sat Sep 23, 2006 10:49 pm
by piranha
ok, but then I get a "Bad TSS Exception"
whats that?
Re:plotting a pixel in VGA
Posted: Sun Sep 24, 2006 2:02 am
by DynatOS
fox wrote:
You need to use AT&T syntax if you are using GCC since it is then compiled by GAS
This used to be the case some time ago, but Intel Syntax is supported by GAS these days.
Take a look at this define statement...
Code: Select all
#define x86(s) asm(".intel_syntax"); asm(s);asm(".att_syntax");
This will allow you to embed your Intel-based inline ASM syntax in blocks of "x86()" (or whatever else you wish to call it) while maintaining "asm()" for the AT&T stuff
As for the "Bad TSS Exception", that sounds like the Protected Mode version of Interrupt 10 (0Ah) is firing and not the Real Mode (BIOS) one. It could also be a genuine TSS Exception if the v86 Monitor is bug-prone.
Took a look at
THIS v86 Mode Monitor Example and compare it to how you are doing things.
Re:plotting a pixel in VGA
Posted: Sun Sep 24, 2006 9:02 am
by fascist-fox
This will allow you to embed your Intel-based inline ASM syntax in blocks of "x86()" (or whatever else you wish to call it) while maintaining "asm()" for the AT&T stuff
I guess you learn something new each day
If I would have known that I wouldn't have been sticking to the ugly AT&T syntax all this time. Thanks for the heads up.
Re:plotting a pixel in VGA
Posted: Sun Sep 24, 2006 10:48 am
by piranha
ok, so using the defined x86, do you do:
x86("mov ah,0\n\t"
"mov al,13\n\t"
"int 0x10\n");
?
or something?
the compiler says
/tmp/ccIkcdQK.s:125: Error: ambiguous operand size for `mov'
/tmp/ccIkcdQK.s:126: Error: ambiguous operand size for `mov'
Re:plotting a pixel in VGA
Posted: Sun Sep 24, 2006 11:22 am
by Candy
AFAIK && IIRC, the GNU Intel syntax isn't the normal intel syntax, it's AT&T syntax with the operands swapped.
Re:plotting a pixel in VGA
Posted: Tue Oct 03, 2006 4:26 am
by Pype.Clicker
Candy wrote:
AFAIK && IIRC, the GNU Intel syntax isn't the normal intel syntax, it's AT&T syntax with the operands swapped.
which suggests you should use "movb" rather than just "mov" ... btw, you've noticed that even if you got it compiled fine, it won't work because that's real-mode-only code, right ?