Return multiple values: Difference between revisions

m
→‎{{header|68000 Assembly}}: actually did what the task asked me to do
m (→‎{{header|68000 Assembly}}: actually did what the task asked me to do)
Line 46:
A function's "return value" is nothing more than the register state upon exit. However, to ensure compatibility between software, there are general calling conventions that compiler-written code will follow that standardizes which registers are used to return values from a function.
 
This code returns the sum and difference of two integers, which will be passed in via registers D2 and D3.
<lang 68000devpac>sum:
D2+D3 is returned in D0, D2-D3 is returned in D1.
;Equivalent C code:
 
;int sum(int a,int b)
<lang 68000devpac>sumfoo:
;{
MOVE.L D2,D0
; return a+b;
MOVE.L D3,D1
;}
ADD.L D1,D0
SUB.L D2,D3
MOVE.L D3,D1
RTS</lang>
 
1,489

edits