GIDForums  

Go Back   GIDForums > Computer Programming Forums > Assembly Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 08-Jan-2009, 01:33
vikramaditya vikramaditya is offline
New Member
 
Join Date: Dec 2008
Posts: 2
vikramaditya is on a distinguished road
Question

32 bit assembly code doesn't work on 64 bit


Hi,

The code snippet below works for Linux 32 bit but does NOT work for Linux 64 bit :
Code:
movl %edi, -4(%rbp) movq %rsi, -16(%rbp) movl $.LC0, %edi call puts mov $1447909480,%eax mov $10,%ecx mov $22104,%edx inl (%dx) movl $.LC1, %edi call puts leave ret

If i change the position of print command (print command below) to print just before IN(inl) instruction, the code works.
Code:
movl $.LC0, %edi call puts

The below code works on Linux 64 bit, the print command place is changed. It is moved just above the IN(inl) command.
Code:
movl %edi, -4(%rbp) movq %rsi, -16(%rbp) mov $1447909480,%eax mov $10,%ecx mov $22104,%edx movl $.LC0, %edi call puts inl (%dx) movl $.LC1, %edi call puts leave ret

Can any one tell me how can solve this problem ( i dont want to use print command to make the code work) and why is this happening.

For the reference complete assembly file is attached (It works on Linux 32 bit).
Thanks
Attached Files
File Type: txt asm.txt (1.5 KB, 11 views)
  #2  
Old 08-Jan-2009, 17:49
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: 32 bit assembly code doent work on 64 bit


I presume you obtained that code by using something like:
Code:
gcc -S yourfile.c
Could you post the C code as well?
I do not have a 64 bit system so can't be of much help (even if I did I wouldn't be of much help)
I would run the program within gdb and see what exactly is going on (and not).

As you can tell this forum does not get a lot of traffic.
Did you consider posting the C code which fails on the C forum which does?
Also tell what exactly happens when the program is successful and when it fails.
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
my code has errors.. HELP bengt23648 C Programming Language 5 18-Aug-2007 10:48
Database Program goldfish C Programming Language 6 13-May-2006 14:12
Random access files Krazy_yA C Programming Language 6 07-May-2006 02:44
functions seems not to exit from a certain code block jaro C Programming Language 3 22-Mar-2006 00:08
Help in C Print is not working with LinkList batman3280 C Programming Language 3 09-Mar-2006 20:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:34.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.