Demonstrate how to pick a random element from a list.




    .model small
    .stack 1024
 
    .data
TestList byte 00h,05h,10h,15h,20h,25h,30h,35h
 
    .code
 
start:
	mov ax,@data
	mov ds,ax
 
	mov ax,@code
	mov es,ax
 
	call seedXorshift32				;seeds the xorshift rng using the computer's date and time
 
	call doXorshift32
	mov ax,word ptr [ds:xorshift32_state_lo]	;retrieve the rng output
	and al,00000111b				;constrain the rng to values 0-7
 
	mov bx,offset TestList
	XLAT						;translate AL according to [DS:BX]
 
	call PrintHex					;display AL to the terminal
 
 
	mov ax,4C00h
	int 21h						;exit program and return to MS-DOS
        end start