mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-01-12 01:58:24 +00:00
[SPCA] more assembly
This commit is contained in:
8
semester3/spca/code-examples/01_asm/04_factorial.s
Normal file
8
semester3/spca/code-examples/01_asm/04_factorial.s
Normal file
@@ -0,0 +1,8 @@
|
||||
factorial:
|
||||
movl $1, %eax # Setup
|
||||
.AGAIN:
|
||||
imull %edi, %eax # %eax *= %edi
|
||||
subl $1, %edi # %edi--
|
||||
cmpl $1, %edi # 1 < %edi ?
|
||||
jg .AGAIN # go back, if yes
|
||||
ret
|
||||
9
semester3/spca/code-examples/01_asm/05_factorial.s
Normal file
9
semester3/spca/code-examples/01_asm/05_factorial.s
Normal file
@@ -0,0 +1,9 @@
|
||||
factorial:
|
||||
jmp .COMP # Check condition
|
||||
.LOOP:
|
||||
imull %edx, %eax # %eax *= %edx
|
||||
decl %edx # %edx--
|
||||
.COMP:
|
||||
cmpl $1, %edx # 1 < %edx ?
|
||||
jg .LOOP # if yes, go to loop
|
||||
ret
|
||||
Reference in New Issue
Block a user