Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- r
- section .data
- format db "%d", 0
- section .bss
- num resd 1
- section .text
- extern printf
- extern rand
- extern srand
- extern time
- global _start
- _start:
- ; Seed the random number generator
- call time
- push rax
- call srand
- pop rax
- ; Generate a random number between 1 and 10, you can adjust this if neccesary
- call rand
- mov rax, rdx
- xor rdx, rdx
- mov rbx, 10
- xor rdx, rdx
- div rbx
- add rax, 1
- mov [num], eax
- ; Print the number
- mov rdi, format
- mov rsi, [num]
- xor rax, rax
- call printf
- ; Exit the program
- mov rax, 60
- xor rdi, rdi
- syscall
Advertisement
Comments
-
- with external functions all can do random number generator
Add Comment
Please, Sign In to add comment