Untitled
By: a guest | Mar 18th, 2010 | Syntax:
ASM (NASM) | Size: 1.26 KB | Hits: 85 | Expires: Never
.model small
.386
.stack 200h
.data
c dd 1013904223
a dd 1664525
seed dd ?
text db 'Initial random seed: $'
.code
start:
mov ax, @data
mov ds, ax
mov dx, offset text
mov ah, 9h
int 21h
call Randomize
call Print
mov cx, 20
main_loop:
push cx
call Random
shr eax, 24
call Print
pop cx
dec cx
jnz main_loop
mov ax, 4c00h
int 21h
Randomize proc
mov ah, 2ch
int 21h
mov bx, dx
shl ebx, 16
mov bx, cx
mov seed, ebx
mov eax, ebx
ret
Randomize endp
Random proc
xor edx, edx
mov eax, seed
mul a
add eax, c
mov seed, eax
ret
Random endp
Print proc
mov ebx, 10
xor cx,cx
print_calc:
xor edx, edx
div ebx
push dx
inc cx
test eax, eax
jnz print_calc
mov ah, 2h
print_out:
pop dx
add dl, '0'
int 21h
dec cx
jnz print_out
mov dl, 13
int 21h
mov dl, 10
int 21h
ret
Print endp
end start