I'm not sure how to get a random number within a specific range in x64 Assembly. Most of the examples I've seen on SO and around the web have been on Linux, so advice on how to do it on Windows would be greatly appreciated!
default rel
extern printf
extern scanf
extern rand_s
section .rdata ;; constants
prompt: db "What is your guess? (Answer is: %d) ", 0
congrats: db "You guessed it!", 10, 0
section .data ;; mutable variables
num_guess: dq 0
num_target: dq 0 ; assumed constant, but technically not
section .text
global main
main:
stack_reserve: equ 40
sub rsp, stack_reserve
;; let's assign our random target
;; rand(num_target) % 100 + 1
;call rand_s
lea rcx, [prompt]
call printf
add rsp, stack_reserve
ret
Aucun commentaire:
Enregistrer un commentaire