Seed the RNG based on current date

This commit is contained in:
Juhani Krekelä 2022-02-24 21:33:35 +02:00
parent 0661eb0f06
commit ae8e8e69ce
1 changed files with 28 additions and 6 deletions

View File

@ -5,13 +5,31 @@ org 0x100
section .code
seed equ 20220224
seed_rng_date:
; Get date
mov ah, 0x2a
int 0x21
mov [year], cx
mov [month], dh
mov [day], dl
; Seed the rng
mov ax, seed & 0xffff
mov dx, seed >> 16
mov bp, rng_seed
call store32
; addl32 = year * 10000
mov ax, 10000
mul word [year]
mov bp, addl32
call store32
; addr32 = month * 100 + day
mov ax, 100
mul word [month]
add ax, [day]
mov bp, addr32
call store32
; rng_seed = addl32 + addr32 = year * 10000 + month * 100 + day
call add32
mov bp, rng_seed
call store32
select_target:
; Call rng to get a number
@ -716,6 +734,10 @@ mulr32 dd 0
addl32 dd 0
addr32 dd 0
year dw 0
month dw 0
day db 0
section .rodata
not_found_str db ' - word not found$'