; Build/run from examples/: ; ../utils/mcpu-as -o call.o call.s ; ../utils/mcpu-ld --stack-size=128 -o call call.o ; ../utils/mcpu-run --int-reg=r64@0x00010 call ; ; Expected output: 33 ; ; LibCPU CALL ABI example. ; ; add2(a,b): this two-r64 argument block is exactly 16 bytes, so the ; traditional right-to-left PUSH sequence also satisfies the formal ABI. ; CALL then pushes ; the 64-bit return PC, therefore on callee entry: ; SP+0 = return address ; SP+8 = first argument a ; SP+16 = second argument b ; ; Before CALL, SP is 16-byte aligned. The r64 result is returned in the canonical ABI return view ; r64@0x7fff8. The caller removes its own arguments with ADJSP. .text _start_life: LDI r64@0x00000, 11 LDI r64@0x00008, 22 PUSH r64@0x00008 ; second/rightmost argument b PUSH r64@0x00000 ; first/leftmost argument a CALL add2 ADJSP 16 ; caller cleanup MOV r64@0x00010, r64@0x7fff8 HALT add2: LDSP r64@0x00100, 8 ; a LDSP r64@0x00108, 16 ; b IADD r64@0x7fff8, r64@0x00100, r64@0x00108 RET