;============================================================================== ;file :mainRandom.asm ;author :Andre Long ;due :March 6, 2006 ;description :Main application program which will call subprocedures reseed.asm ; and random.asm(the actual random number generator which gets its ; seed value from reseed.asm) ;============================================================================== ;procedures to INCLUDE Pcmac.inc EXTRN NEWLINE:FAR ;display a new line EXTRN GETDEC$:FAR ;gets 16 bit decimal value unsigned EXTRN PUTDEC$:FAR ;display 16 bit value unsigned EXTRN PUTSTRNG:FAR ;display charactor string EXTRN random:NEAR ;subprodecure EXTRN reseed:NEAR ;sunprocedure ;============================================================================== .MODEL SMALL .586 .STACK 100h .DATA Welcome DB "Welcome to the wild world of random numbers ", 13, 10, '$' PUBLIC seed PUBLIC randomNumber seed DW ? randomNumber DW ? counter DW 0 spaceBlank DB " ",'$' lineCounter DW 0 xOOD DW 0 xEVEN DW 0 xHIGH DW 0 xLOW DW 9999 messCount DB " Counter= ", '$' messOod DB " ood= ", '$' messEven DB " even= ", '$' messHigh DB " high= ", '$' messLow DB " low= ", '$' messClock DB " Random Clock Numbers ", 13, 10, '$' ;============================================================================== .CODE mainRandom proc _Begin ;Macro for boiler plate sPutStr Welcome ;Safe version of putStr call Newline mov bl, 1 mov ax, 5555h ;inital seed value for ressed call reseed ;call subprocedure red: call random mov ax, randomNumber ;came from random ntest: push ax ;save a copy of ax on the stack push bx push dx mov bx, 2 mov dx, 0 div bx ;Ax = Dx:Ax / bx cmp dx, 0 ;dx is where the remainder is pop dx pop bx pop ax je nEven jmp nOdd nEven: inc xEven jmp ntest2 nOdd: inc xOOD jmp ntest2 ntest2: cmp ax, xHIGH ja numHigh jmp ntest3 ntest3: cmp ax, xLow jb numLow jmp after numHigh: mov xHIGH, ax jmp ntest3 numLow: mov xLow, ax jmp after after: mov bh, 1 call PUTDEC$ ;display random number in ax sPutStr spaceBlank inc lineCounter cmp lineCounter, 9 ja nextL jmp CONTINUE nextL: mov lineCounter, 0 call Newline CONTINUE: inc counter cmp counter, 100 jb red jmp exit1 exit1: call Newline sPutStr messCount mov ax, counter call PUTDEC$ sPutStr messOod mov ax, xOOD call PUTDEC$ sPutStr messEven mov ax, xEven call PUTDEC$ sPutStr messHigh mov ax, xHigh call PUTDEC$ sPutStr messLow mov ax, xLow call PUTDEC$ call Newline call Newline mov counter, 0 mov lineCounter,0 mov xOOD, 0 mov xEven, 0 mov xHigh, 0 mov xLow, 9999 sPutStr messClock mov bl, 0 call reseed call random blue: call random mov ax, randomNumber nntest: push ax push bx push dx mov bx, 2 mov dx, 0 div bx cmp dx, 0 pop dx pop bx pop ax je nnEven jmp nnOdd nnEven: inc xEven jmp nntest2 nnOdd: inc xOOD jmp nntest2 nntest2: cmp ax, xHigh ja nnumHigh jmp nntest3 nntest3: cmp ax, xLow jb nnumLow jmp nafter nnumHigh: mov xHigh, ax jmp nntest3 nnumLow: mov xLow, ax jmp nafter nafter: call PUTDEC$ sPutStr spaceBlank inc lineCounter cmp lineCounter, 9 ja nnextL jmp nCONTINUE nnextL: mov lineCounter, 0 call Newline nContinue: inc counter cmp counter, 100 jb blue jmp exit2 exit2: call Newline sPutStr messCount mov ax, counter call PUTDEC$ sPutStr messOod mov ax, xOOD call PUTDEC$ sPutStr messEven mov ax, xEven call PUTDEC$ sPutStr messHigh mov ax, xHigh call PUTDEC$ sPutStr messLow mov ax, xLow call PUTDEC$ exit3: _Exit mainRandom ENDP END mainRandom