LinuxQuestions.org
Visit Jeremy's Blog.
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 02-25-2005, 08:53 AM   #1
gursev
LQ Newbie
 
Registered: Feb 2005
Location: india
Posts: 2

Rep: Reputation: 0
Question inline assembly in gcc


Hi All,

I am trying to compile the following the inline assmebly code in linux. But it gives error. Your help will be very useful to me.

void main()
{
__asm__(
"movl %esi, 0x8(%esi)"
"movb $0x0, 0x7(%esi) "
"movl $0x0, 0xc(%esi) "
);

}

These are the errors

/tmp/cc42yoOW.s: Assembler messages:
/tmp/cc42yoOW.s:12: Error: ignoring junk `(%esi)movb $0x0' after expression
/tmp/cc42yoOW.s:12: Error: too many memory references for `mov'
bash-2.04$


Thanks in advance,
Gursev
 
Old 03-01-2005, 07:27 PM   #2
teval
Member
 
Registered: Jul 2003
Location: Toronto, Canada
Distribution: Gentoo
Posts: 720

Rep: Reputation: 30
You forgot semicolons.
"movl %esi, 0x8(%esi);"
"movb $0x0, 0x7(%esi);"
"movl $0x0, 0xc(%esi);"

Multi instruction asm statements are translated into 1 long line by gcc. So without the ; the assembler doesn't know where a instruction ends.

If you get more trouble of this sort, gcc -S is you friend.
It will print out the asm code right before linking. If you were to look at that in your case you'll see what I mean by the 1 long line.
 
Old 03-04-2005, 02:17 AM   #3
gursev
LQ Newbie
 
Registered: Feb 2005
Location: india
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks a lot teval !!!
 
  


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
problems with gcc inline assembly using xmm registers Y0jiMb0 Programming 3 12-05-2004 02:59 PM
puzzle about g++ compile options for inline assembly program markbeth Programming 2 09-20-2004 04:30 AM
Inline Assembly Question tjt Programming 3 08-08-2004 04:38 AM
undefined reference to ... when using inline assembly in C Annie0716 Programming 3 08-01-2004 12:50 AM
subrouine_call in gcc inline assembly sakeeb Programming 4 08-15-2002 10:22 PM

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

All times are GMT -5. The time now is 04:42 PM.

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