LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-14-2006, 02:52 PM   #1
debiant
Member
 
Registered: Jul 2006
Distribution: Source Mage 0.9.6
Posts: 196

Rep: Reputation: 30
Assembling a 32 bit sample program in a 64 bit world


Or argggg!

Ok So I'm trying to get a bit of sample code working so I did a little modification of a book example because in amd64 you can no longer use pushl, so I'm using pushq:

Code:
# cmovtest.s - An example of the CMOV instructions
.section .data
output:
   .asciz "The largest value is %d\n"
values:
   .int 105, 235, 61, 315, 134, 221, 53, 145, 117, 5
.section .text
.globl _start
_start:
   nop
   movl values, %ebx
   movl $1, %edi
   loop:
      movl values(, %edi, 4), %eax
      cmp %ebx, %eax
      cmova %eax, %ebx
      inc %edi
      cmp $10, %edi
   jne loop
   pushq %rbx
   pushq $output
   call printf
   addl $8, %esp
   pushq $0
   call exit
I have debugged and the seg fault occurs during the call to printf. Everything seems to function fine through the loop (all of the register values are what they should be). I guess I don't understand the magic going on with pushq enough to fix this myself. Any help would be greatly appreciated.

PS: This is being assembled on an amd64 Ubuntu with gas linking against ld-linux-x86-64.so.2

Last edited by debiant; 10-14-2006 at 02:54 PM.
 
  


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
Memory bus is 64 bit but data access and register is only 32 bit for i386 lilzz Linux - Newbie 3 09-02-2006 12:35 AM
32 bit or 64 bit install - is 32 bit easier for a newbie? dms05 Linux - Newbie 3 05-19-2006 03:05 PM
Which version of 32 bit redhat will install on IBM xSeries 366 (64 bit)? Hello123 Linux - Hardware 2 09-14-2005 05:50 AM
When is Linux moving into the 64 bit world? sergeantroach Linux - Software 17 12-18-2003 03:08 PM
Graphic Card that Supports displaying 8-bit and 24-bit images simultaneously yrraja Linux - Hardware 2 04-30-2003 06:41 AM

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

All times are GMT -5. The time now is 10:09 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