Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; x[i + 1] = (A * x[i] + B) mod N - pseudo-random numbers formula
- ; N depends on platform (for example, 32-bit -> 2^32)
- org 100h
- EntryPoint:
- call Random.Initialize
- .GenerateLoop:
- call Random.Get
- push ax
- call PrintHex
- mov ax, $0C08
- int 21h
- test al, al
- jnz @F
- mov ah, $08
- int 21h
- @@:
- jmp .GenerateLoop
- ret
- ; Registers:
- ; Overwrites AX, CX, DX.
- ;
- PrintHex:
- push bp
- mov bp, sp
- push bx
- mov bx, [bp + 4]
- mov cx, 4
- .PrintLoop:
- rol bx, 4
- mov ax, bx
- and ax, 0000'0000_0000'1111b
- cmp al, $0A
- sbb al, $69
- das
- mov dl, al
- mov ah, $02
- int 21h
- loop .PrintLoop
- pop bx
- pop bp
- ret 2
- Random.Initialize:
- mov ah, 02Ch
- int 21h
- mov [Random.wPrev], dx
- ret
- Random.Get:
- mov ax, [Random.wPrev]
- rol ax, 7
- adc ax, 23
- mov [Random.wPrev], ax
- ret
- Random.wPrev dw ?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement