-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrands.asm
61 lines (49 loc) · 1.29 KB
/
rands.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
;Imprime por pantalla 10 numeros random en Hexa de 2bytes separados por un espacio
.8086
.model small
.stack 100h
.data
randNum db "0000", 24h
seed dw 0
weylseq dw 0
prevRandInt dw 0
salto db 0dh, 0ah, 24h
.code
;Imports
extrn toAscii:proc
extrn seedInicial:proc
extrn printar:proc
extrn contar:proc
main proc
mov ax, @data
mov ds, ax
int 80h ;CLS
call seedInicial ;Obtengo una semilla inicial
mov seed, ax
mov weylseq, ax
mov prevRandInt, ax
mov cx, 10 ;Cantidad de numeros random a generar
GRN:
mov ax, seed
mov si, weylseq ;Secuencia de Weyl
mov di, prevRandInt
int 81h ;Genero un numero random
mov weylseq, si
mov prevRandInt, ax
push cx ;Necesito usar CX asi que lo mando al stack
mov bx, offset randNum
mov dl, 24h
call contar ;Cuento la cantidad de caracteres donde quiero guardar el num
mov cl, 16 ;Quiero el numero en hexa (base 16)
call toAscii
mov cx, 2024h ;Indico que quiero imprimir hasta un 24h, e imprimir un 20h al final
call printar
pop cx ;Recupero el valor de CX que habia mandado al stack
loop GRN
mov ah, 9
mov dx, offset salto
int 21h
mov ax, 4C00h
int 21h
main endp
end main