LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-31-2008, 12:45 PM   #1
gvp87
Member
 
Registered: Mar 2007
Location: Boston
Distribution: Ubuntu Gutsy
Posts: 50

Rep: Reputation: 15
c++ asm statement for MCGA mode


void MCGA() {
asm("movl $0x13 %ax");
asm("int $0x10");
}

this is my function to set MCGA mode...for somereason it wont compile, but i've looked at like, every single HOWTO on asm and c++ inline asm, and still can't figure out what i'm doing wrong.

the compiler is telling me this:

Error: suffix or operands invalid for `mov'


Does anyone know how I can fix this??
 
Old 01-31-2008, 04:24 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Code:
void MCGA() {
asm("movl $0x13, %eax");
asm("int $0x10");
}
Two things: comma between the arguments and change of ax to eax because you use movl, not mov.
 
Old 02-01-2008, 08:32 AM   #3
gvp87
Member
 
Registered: Mar 2007
Location: Boston
Distribution: Ubuntu Gutsy
Posts: 50

Original Poster
Rep: Reputation: 15
Thanks a lot! Omg i couldn't figure it out for the life of me and it was driving me crazy
 
Old 02-04-2008, 08:31 AM   #4
Dox Systems - Brian
Member
 
Registered: Nov 2006
Posts: 344

Rep: Reputation: 31
While using EAX works and won't hurt anything, it'd be more technically correct to just use MOV with AX, since that's all that BIOS call is looking for. But clearing the upper half of EAX isn't going to hurt anything either. The only real downside I can think of is future readability. Someone looking at the code might wonder "why on earth is EAX used? what might break if I change anything?, etc)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Case statement with If statement cbo0485 Linux - Newbie 4 11-07-2007 08:05 PM
I/O in ASM Mercurius Programming 10 11-16-2006 07:02 PM
asm Question Whiteghost Programming 2 09-03-2005 09:26 AM
How to use C functions in asm? LongName Programming 4 08-29-2004 12:25 AM
How can I change display mode from character mode to graph mode wuzhong Linux - Hardware 1 08-08-2004 09:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration