%include "MY_IO.h" extern GET_RANDOM extern SEED_RANDOM extern RANDOM_SEED segment .data label1 db "rdtes " size1 equ $ - label1 label2 db "getrandom " size2 equ $ - label2 label3 db "time " size3 equ $ - label3 label4 db " makes random value " size4 equ $ - label4 label5 db " % 100 = " size5 equ $ - label5 segment .bss segment .text global _start _start: ; generate with method 0 ; srand(method = 0) mov rdi,0 call RANDOM_SEED mov r15, rax; ; cout << "rdtes " << srand(0) << endl; mov rdi, label1 mov rsi, size1 call PRINT_STRING mov rdi, r15 call PRINT_INT call PRINT_NEWLINE ; generate with method 1 mov rdi,1 call RANDOM_SEED mov r15, rax; ; cout << "getrandom " << srand(1) << endl; mov rdi, label2 mov rsi, size2 call PRINT_STRING mov rdi, r15 call PRINT_INT call PRINT_NEWLINE ; try method 2 mov rdi,2 call RANDOM_SEED mov r15, rax; ; cout << "getrandom " << srand(2) << endl; mov rdi, label3 mov rsi, size3 call PRINT_STRING mov rdi, r15 call PRINT_INT call PRINT_NEWLINE ; let's try some random numbers ; I would like ; for i = 10; i > 0; --i ; cout << i << "makes random value " << rand() << endl; ; ; but my print_int adds an endl. mov r8, 10 top: dec r8 ; r15 = rand() call GET_RANDOM mov r15, rax ; cout << i << endl; mov rdi, r8 call PRINT_INT ; cout << "makes random value " mov rdi, label4 mov rsi, size4 call PRINT_STRING ; cout << rand() mov rdi, r15 call PRINT_INT mov rdi, label5 mov rsi, size5 call PRINT_STRING ; % by 100 mov ecx, 100 mov rax, r15 mov edx, 0 div ecx mov rdi, rdx ; cout << rand() % 100 << endl; call PRINT_INT call PRINT_NEWLINE test r8,r8 jnz top ; exit mov eax, SYS_EXIT mov edx, SUCCESS syscall