[SPCA] Add example to ASM

This commit is contained in:
RobinB27
2026-01-10 17:29:22 +01:00
parent 99ee7507a3
commit 59f4151a3e
3 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
sum: // Label
endbr64 // Indirect Branch target (No effect on code's logic)
pushq %rbp // Preserve caller stack frame
movq %rsp, %rbp // Set up new stack frame
movl %edi, -20(%rbp) // Arg1 register -> stack
movl %esi, -24(%rbp) // Arg2 register -> stack
movl -20(%rbp), %edx // stack[Arg1] -> gp register
movl -24(%rbp), %eax // stack[Arg2] -> gp register
addl %edx, %eax // Add Arg1 + Arg2 -> gp register
movl %eax, -4(%rbp) // result -> stack
movl -4(%rbp), %eax // stack[result] -> return register
popq %rbp // Restore caller stack frame
ret // jump back to caller