Category : Files from Magazines
Archive   : CLM89DEC.ZIP
Filename : RNG.ASM

Output of file : RNG.ASM contained in archive : CLM89DEC.ZIP
;Random Number Generator and ASCII translating Program,
;by Professor T. A. Elkins
;copyright 1989

cseg Segment

assume cs:cseg, ds:cseg
org 100h

beg: jmp s
db 0dh,0ah ;cr/lf for jump bytes
asm db 9000 dup(' 0',0dh,0ah) ;buffer for ASCII numbers
db 1ah ;EOF mark
rs db ' 0',0dh,0ah ;bytes to clear old numbers
author db 'Professor Elkins'
db 'PE1' ;filespec marker
fspec db '' ;Controlling filespec
db 15 dup(0) ;change up to 21 bytes
;leave trailing 0.
mes db 'File creation or I/O error$'
t db 0 ;toggle variable
d dw 10

db 'PE2'
h1 dw 7397 ;Initial seeds
h2 dw 29447 ;can be changed
h3 dw 802 ;if desired.

f1 dw 179 ;change these three words
f2 dw 183 ;only if you know what you
f3 dw 182 ;are doing.
m2 dw 32779 ;words!
m3 dw 32783

s: mov cx,9000 ;set loop at 9000 steps
mov di,offset asm ;aim first ASCII write
l: mov t,0 ;Random Number sequence start
l0: mov ax,h1 ;Began section one
mul f1
div m1
mov h1,dx
dec dx
cmp dx,32767
jb l1
inc t ;set toggle
l1: mov bx,dx
mov ax,h2 ;Began section two
mul f2
div m2
mov h2,dx
dec dx
cmp dx,32767
jb l2
inc t
l2: add bx,dx
mov ax,h3 ;Began section three
mul f3
div m3
mov h3,dx
dec dx
cmp dx,32767
jb l3
inc t
l3: cmp t,0 ;Discard if any section is out of bounds.
jne l
mov ax,dx
add ax,bx
and ax,32767 ;Fifteen bit number in AX
;sequence ends.

;ASCII conversion section
mov si,offset rs ;Clear old random number space start
push di
push cx
mov cx,7
repe movsb ;clear write
pop cx
pop di

mov bx,4 ;translation begins
l13: cmp ax,0 ;case: rn=0
je l15
cmp ax,10 ;case: rn<10
jl l14
xor dx,dx
div d
add dl,48 ;change number to ASCII format
mov [bx+di],dl ;store ASCII digit
dec bx
jmp l13
l14: add al,48
mov [bx+di],al
add di,7
loop l16
jmp short l17
l16: jmp l0

;Recreate file for write.
mov dx,offset fspec ;Int 21h sub 3ch creates the file if
xor cx,cx ;it does not exist or truncates it to
mov ah,3ch ;zero length if it does exist.
int 21h ;NOTE: This interrupt places the program
jc c ;file is some danger if the pwr fails.
;A backup is recommended where needed.

;Write file.
mov cx,offset x ;get file length plus 100h
sub cx,100h
mov bx,ax ;move handle to bx
mov dx,100h
mov ah,40h
int 21h
jc c
;Close file.
;Terminate program.
mov ax,4c00h
int 21h

mov dx,offset mes ;print error message if needed
mov ah,9
int 21h

mov ax,4c01h ;Set error level to one.
int 21h ;Terminate program.


cseg ends
end beg

  3 Responses to “Category : Files from Magazines
Archive   : CLM89DEC.ZIP
Filename : RNG.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: