Last active
December 21, 2015 18:19
-
-
Save wjlafrance/6346995 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; $ nasm -f macho rng.asm && ld -macosx_version_min 10.7 -e _main -lc -o rng rng.o && ./rng | |
BITS 32 | |
%define sys_exit 1 | |
%define EXIT_SUCCESS 0 | |
; ---------------------------------------- | |
section .text | |
global _main | |
extern _printf | |
extern _arc4random | |
; ---------------------------------------- | |
section .data | |
format db "%d", 0xA, 0 | |
; ---------------------------------------- | |
_main: | |
sub esp, 8 | |
xor ecx, ecx | |
top: | |
mov [esp+8], ecx | |
call _arc4random | |
xor edx, edx | |
mov ecx, 35 | |
div ecx | |
add edx, 15 | |
mov [esp+4], edx | |
mov [esp], dword format | |
call _printf | |
mov ecx, [esp+8] | |
inc ecx | |
cmp ecx, 10 | |
jne top | |
bottom: | |
add esp, 8 | |
push dword EXIT_SUCCESS | |
mov eax, sys_exit | |
int 0x80 | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment