Return multiple values: Difference between revisions
m
→{{header|ARM Assembly}}
Puppydrum64 (talk | contribs) |
Puppydrum64 (talk | contribs) |
||
Line 297:
When programming without any rules governing the way you write functions, a function's "return value" is nothing more than the register state upon exit. However, the [https://www.eecs.umich.edu/courses/eecs373/readings/ARM-AAPCS-EABI-v2.08.pdf AAPCS] calling convention dictates that the <code>R0</code> register is used to store a function's return value. (If the return value is larger than 32 bits, the registers <code>R1-R3</code> can also be used.) Following this standard is necessary for human-written assembly code to properly interface with code written by a C compiler.
This function takes two numbers in <code>R0</code> and <code>R1</code>, and returns their sum in <code>R0</code> and their difference in <code>R1</code>.
<lang ARM Assembly>sum:▼
MOV R3,R1
bx lr</lang>▼
ADD R0,R2,R3
SUB R1,R2,R3
=={{header|Arturo}}==
|