remove deprecated code
This commit is contained in:
1 file changed
+11
-7
+11
-7
@@ -1,5 +1,9 @@
|
|||||||
|
# Since we use GNU Assembler, the AT&T Syntax is used
|
||||||
|
# to make it more familiar, we have added the following
|
||||||
|
# to allow the use of the Intel syntax
|
||||||
.intel_syntax noprefix # allow mov rax, 1 syntax in GAS (GNU Assembly)
|
.intel_syntax noprefix # allow mov rax, 1 syntax in GAS (GNU Assembly)
|
||||||
.global _start
|
|
||||||
|
.global _start # Define the entry point to the assembly, where to start executing
|
||||||
|
|
||||||
# factorial
|
# factorial
|
||||||
# - rdi (n) as input number
|
# - rdi (n) as input number
|
||||||
@@ -16,9 +20,8 @@ factorial:
|
|||||||
imul rax, rdx # rax = factorial(n - 1) * n
|
imul rax, rdx # rax = factorial(n - 1) * n
|
||||||
jmp done
|
jmp done
|
||||||
|
|
||||||
base_case:
|
# done is used to return
|
||||||
mov rax, 1
|
# from the factorial
|
||||||
|
|
||||||
done:
|
done:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@@ -63,16 +66,17 @@ print_rax_digit:
|
|||||||
add rsp, 16
|
add rsp, 16
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
# new line character
|
||||||
nl:
|
nl:
|
||||||
.byte 0x0A # '\n'
|
.byte 0x0A # '\n'
|
||||||
|
|
||||||
|
# where the program starts executing
|
||||||
_start:
|
_start:
|
||||||
mov rdi, 5 # Use 5 for our example input
|
mov rdi, 5 # Use 5 for our example input
|
||||||
mov rax, 1 # Set starting result to 1
|
mov rax, 1 # Set starting result to 1
|
||||||
|
|
||||||
call factorial
|
call factorial # initial factorial call
|
||||||
|
call print_rax_digit # print result to prove it works
|
||||||
call print_rax_digit
|
|
||||||
|
|
||||||
mov rax, 60 # syscall exit - 64 bit
|
mov rax, 60 # syscall exit - 64 bit
|
||||||
mov rdi, 0 # exit code
|
mov rdi, 0 # exit code
|
||||||
|
|||||||
Reference in new issue
Block a user