mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-01-12 08:08:25 +00:00
[SPCA] Format
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
sum: // Label
|
sum: # Label
|
||||||
endbr64 // Indirect Branch target (No effect on code's logic)
|
endbr64 # Indirect Branch target (No effect on code's logic)
|
||||||
pushq %rbp // Preserve caller stack frame
|
pushq %rbp # Preserve caller stack frame
|
||||||
movq %rsp, %rbp // Set up new stack frame
|
movq %rsp, %rbp # Set up new stack frame
|
||||||
movl %edi, -20(%rbp) // Arg1 register -> stack
|
movl %edi, -20(%rbp) # Arg1 register -> stack
|
||||||
movl %esi, -24(%rbp) // Arg2 register -> stack
|
movl %esi, -24(%rbp) # Arg2 register -> stack
|
||||||
movl -20(%rbp), %edx // stack[Arg1] -> gp register
|
movl -20(%rbp), %edx # stack[Arg1] -> gp register
|
||||||
movl -24(%rbp), %eax // stack[Arg2] -> gp register
|
movl -24(%rbp), %eax # stack[Arg2] -> gp register
|
||||||
addl %edx, %eax // Add Arg1 + Arg2 -> gp register
|
addl %edx, %eax # Add Arg1 + Arg2 -> gp register
|
||||||
movl %eax, -4(%rbp) // result -> stack
|
movl %eax, -4(%rbp) # result -> stack
|
||||||
movl -4(%rbp), %eax // stack[result] -> return register
|
movl -4(%rbp), %eax # stack[result] -> return register
|
||||||
popq %rbp // Restore caller stack frame
|
popq %rbp # Restore caller stack frame
|
||||||
ret // jump back to caller
|
ret # jump back to caller
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
max:
|
max:
|
||||||
cmpl %esi, %edi // Set condition flags
|
cmpl %esi, %edi # Set condition flags
|
||||||
jle .IF // Conditional jump if %edi <= %esi
|
jle .IF # Conditional jump if %edi <= %esi
|
||||||
movl %edi, %edx // %edi -> return register
|
movl %edi, %edx # %edi -> return register
|
||||||
jmp .ELSE
|
jmp .ELSE
|
||||||
.IF:
|
.IF:
|
||||||
movl %esi, %edx // &esi -> return register
|
movl %esi, %edx # &esi -> return register
|
||||||
.ELSE:
|
.ELSE:
|
||||||
ret
|
ret
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
absdiff:
|
absdiff:
|
||||||
movl %edi, %eax
|
movl %edi, %eax
|
||||||
subl %esi, %eax // arg2 - arg1 -> eax
|
subl %esi, %eax # arg2 - arg1 -> eax
|
||||||
movl %esi, %edx
|
movl %esi, %edx
|
||||||
subl %edi, %edx // arg1 - arg2 -> edx
|
subl %edi, %edx # arg1 - arg2 -> edx
|
||||||
cmpl %esi, %edi // Set condition flags
|
cmpl %esi, %edi # Set condition flags
|
||||||
cmovle %edx, %eax // edx -> eax, only if eax <= edx
|
cmovle %edx, %eax # edx -> eax, only if eax <= edx
|
||||||
ret
|
ret
|
||||||
|
|||||||
@@ -12,4 +12,4 @@ A function using an \verb|if/else| construct to choose the maximum of $2$ number
|
|||||||
|
|
||||||
A function computing the absolute difference $|x-y|$ using an \verb|if/else| construct, might use a conditional \verb|move| instead:
|
A function computing the absolute difference $|x-y|$ using an \verb|if/else| construct, might use a conditional \verb|move| instead:
|
||||||
|
|
||||||
\inputcodewithfilename{gas}{code-examples/01_asm/}{03_absdiff.s}
|
\inputcodewithfilename{gas}{code-examples/01_asm/}{03_absdiff.s}
|
||||||
|
|||||||
Reference in New Issue
Block a user