AT2k Design BBS Message Area
Casually read the BBS message area using an easy to use interface. Messages are categorized exactly like they are on the BBS. You may post new messages or reply to existing messages!

You are not logged in. Login here for full access privileges.

Previous Message | Next Message | Back to BAT Magic  <--  <--- Return to Home Page
   Local Database  BAT Magic   [154 / 250] RSS
 From   To   Subject   Date/Time 
Message   Visitor    JOE   Random numbers   October 29, 1995
 8:04 PM *  

 J#@> code I would guess that it is pseudo-random seeded by the time.

Correct, the program is taking the hundredth of second from the
DOS time service and using it as the random number. Of course
there is nothing random about the time, but the instant it gets
called by the program is reasonably random. :-)

Here is the source code with comments:

; This program returns a random number between 0 and 99.

.MODEL tiny
.data
RandMessage    DB 'SET RAND=$'
               db 16 dup (00)
.CODE
org	100h
main:
        MOV	AH,2Ch
	INT	21h		       ;Time
	MOV	AL,DL
	Push 	AX                      ;save time
	push	AX                      ;save time
	mov     ax,cs
        mov     ds,ax                   ;set DS to point to the data segment
        mov     ah,9                    ;DOS print string function
        mov     dx,OFFSET RandMessage   ;point to MESSAGE
        int     21h                     ;display MESSAGE
        POP     AX                      ; time for screen display
	xor	ah,ah                   ; clear ah
TOASC:                                  ; number to display as ascii is in ax
        mov     bx, 0Ah                 ; 0Ah = 10
        mov     cx, 2                   ; for 2 digit display
Loop1:
        xor     dx, dx                  ; zero dx - Logical Exclusive OR
        div     bx                      ; div by 10 - Unsigned Divide
        add     dx, 30h                 ; Add
        push    dx
        loop    Loop1                   ; Loop while CX != 0
        mov     cx, 2
        mov     ah, 2
Loop2:
        pop     dx
        int     21h                     ; DOS - DISPLAY OUTPUT
                                        ; DL = character to send to standard
                                        ; output
        loop    Loop2                   ; Loop while CX != 0
        pop     ax                      ; time is in ax
        MOV     AH,4Ch
       INT      21h	        	;TERM with time as errorlevel
end main
___ Blue Wave/QWK v2.12
  Show ANSI Codes | Hide BBCodes | Show Color Codes | Hide Encoding | Hide HTML Tags | Show Routing
Previous Message | Next Message | Back to BAT Magic  <--  <--- Return to Home Page

VADV-PHP
Execution Time: 0.0151 seconds

If you experience any problems with this website or need help, contact the webmaster.
VADV-PHP Copyright © 2002-2024 Steve Winn, Aspect Technologies. All Rights Reserved.
Virtual Advanced Copyright © 1995-1997 Roland De Graaf.
v2.1.241108