Return multiple values: Difference between revisions

Line 265:
190 LET d = a - b
200 END SUB</lang>
 
=={{header|ARM Assembly}}==
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.
 
<lang ARM Assembly>sum:
;int sum(int a,int b){return a+b;}
;takes R0 and R1 as arguments, outputs their sum to R0.
ADD R0,R0,R1
bx lr</lang>
 
=={{header|Arturo}}==
1,489

edits