Slide 9.1: Procedures
Slide 9.3: This book's link library (cont.)
Home

This Book's Link Library


Randomize
It initializes the starting seed value of the Random32 and RandomRange procedures.

RandomRange
It produces a random integer within the range of 0 to (n – 1), where n is an input parameter passed in the EAX. The random integer is returned in EAX.

Clrscr
It clears the console screen.

Crlf
It advances the cursor to the beginning of the next line in the console window. It writes a string containing the values 0Dh and 0Ah.

Delay
It pauses the program for a specified number of milliseconds. Before calling Delay, set EAX to the desired interval.

GetCommandtail (not working)
It copies the program's command line into a null-terminated string, whose offset is saved in EDX.

Note that this procedure is not working because of unknown reasons.


 Generating 5 Randomized Numbers   Counting n (< 10) Seconds 
 NUMBER = 5
 .code
     call  Clrscr
     
     mov   ecx, NUMBER
 L1: mov   eax, 10
     call  RandomRange
     call  WriteInt
     mov   al, ' '
     call  WriteChar
     loop  L1
 
 .code
     call   ReadChar
     call   WriteChar
     call   Crlf    
      
movzx ecx, al L1: mov eax, ecx call WriteInt call Crlf mov eax, 1000 call Delay loop L1