1,105,331 Community Members

ARM asm, how to return a value -- Please help

Member Avatar
baldwindc
Light Poster
35 posts since Nov 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi, in a given c program where you have

myvar = sumR(char * arg1, int arg2)

sumR is a function in an assembly .s file. I have done all the calculations, but I have no idea how to return the value to the calling c program.

Any ideas?

Thanks so much.

Member Avatar
GunnerInc
xor eax, eax
91 posts since Jan 2011
Reputation Points: 7 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 0 [?]
Team Colleague
 
0
 

Usually the value is returned in R0. So in your sumR, after you do your stuff, place what you want myvar to equal in R0

Member Avatar
baldwindc
Light Poster
35 posts since Nov 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 3 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks. If you don't mind one more, how do you print the contents of a register which contains an int.

Member Avatar
GunnerInc
xor eax, eax
91 posts since Jan 2011
Reputation Points: 7 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 0 [?]
Team Colleague
 
0
 

Eh, Not sure, I am an x86 guy - sorry. Check the ARM website for debug stuff you can use.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: