Return multiple values: Difference between revisions

m (→‎{{header|68000 Assembly}}: actually did what the task asked me to do)
Line 60:
{{trans|ARM Assembly}}
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.
 
<lang asm>sum:
This function takes two 16-bit numbers in CX and DX, and outputs their sum to AX and their difference to BX.
;Equivalent C code:
 
;int sum(int a,int b)
<lang asm>sum:mov ax,cx
;{
mov bx,dx
; return a+b;
;}
add ax,bx
sub cx,dx
mov bx,cx
ret</lang>
 
1,489

edits