plotting a pixel in VGA

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
piranha

plotting a pixel in VGA

Post 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
fascist-fox

Re:plotting a pixel in VGA

Post 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
piranha

Re:plotting a pixel in VGA

Post 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?
fascist-fox

Re:plotting a pixel in VGA

Post 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");
piranha

Re:plotting a pixel in VGA

Post by piranha »

ok, but then I get a "Bad TSS Exception"
whats that?
DynatOS

Re:plotting a pixel in VGA

Post 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.
fascist-fox

Re:plotting a pixel in VGA

Post 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.
piranha

Re:plotting a pixel in VGA

Post 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'
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:plotting a pixel in VGA

Post by Candy »

AFAIK && IIRC, the GNU Intel syntax isn't the normal intel syntax, it's AT&T syntax with the operands swapped.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:plotting a pixel in VGA

Post 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 ?
Post Reply