"Don't tell me how hard you work. Tell me how you get done."
- James J. Ling

Pseudo-Random Numbers in ASM

September 1, 2006

;———————–get system time—————————
mov ah, 02ch
int 21h

;————————get hour (00-24)————————

xor ax, ax
xor dx, dx

mov al, ch  

call display

mov dl,’:’
int 21h

;————————–get minute—————————
xor ax, ax
xor dx,dx

mov al, cl  
call display
;—generate 10 3-digit “random” numbers——
mov ch, 10
num:
   xor ax, ax
   xor bx, bx

   mov dh, dl

;————————3 digit numbers————————-
 mov cl,3

 digits:
 
    mov al, dl            ; get millisec
    mov bl, 10
    div bl
 
    add ah, 30h
    mov dl, ah
    mov ah, 02 
    int 21h
    shr dl,1               ; digits seem to random
    dec cl 
 
 jnz digits
 
   mov ah,02           ; go to nxt line
   mov dl,0ah
   int 21h
   mov dl,0dh
   int 21h

   mov dl, dh           ; generate more 3-digit numbers
   add dl, 17   

   dec ch
jnz num
 
int 20h

;————–display hour/minute———————
display:
   mov bl, 10  
   div bl

   add al, 30h  

   add ah, 30h
   mov dh, ah

   mov ah, 02  
   mov dl, al
   int 21h
   mov dl,dh
   int 21h
  
ret 

 

 

 

Posted by phengpheng at 10:24 pm | permalink

Previous Comments

Sir Eugene's pseudo-random numbers… IDOL!

lea di, numb
call xxx
inc di
call delay
call xxx
inc di
call delay
call xxx
mov ah, 09
lea dx, numb
int 21h
int 20h

xxx:
    mov ah, 02ch
    int 21h

    and dl, 0f
    cmp dl,9
    ja xxx

    add dl, 30h
    mov [di], dl
ret

delay:
    mov cx,0
    yyy:
        mov dx, 0a00h
        zzz:
            xor ax, ax
            dec dx
            cmp dx,0
            jne zzz
    loop yyy
ret

numb db 4 dup('$') 

Posted by phengpheng at October 17, 2006, 2:46 pm

All comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.

Add a comment








     

September 2006
M T W T F S S
« Aug   Oct »
 123
45678910
11121314151617
18192021222324
252627282930  

About Me

A Computer Science graduate who is a fanatic in assembly, java, and j2me programming. Developed BlueVoice system (Direct Voice Communication in Mobile Phones), this system allows mobile users to experience FREE VOICE CALLS

Subscribe

Technorati
Bloglines

Tagboard

phengpheng:

Haven’t managed my blog for a long time already because I’m so busy now… Sorry to cause you guyz trouble…

Jun Mark:

hoW tO creaTE a PrOGram thAT woULD oUTpuT ascii table???

Jun Mark:

pLZ anSwer mY qUEstions

cutieGurl:

how to convert binary to hexadecimal, decimal and octal?????????please. answer me??????????

mary ann:

kuya, ung binary to decimal converter nyo. mali man? ung sa mga compare mo. ung may 0,9,A,F etc… bad character lumalabaspls rep asap po. tnx

carol:

how to convert decimal to binary to octal and hexadecimal

Galwin:

been here!

galwin:

nice site. hope you could visit mine, too.

pathy:

FRIENDS FOREVER!! Miss you na!!!

ridvan:

aus, i seldom see lady programmers. hehe. keep it up. and oh yeah, i guess i saw you during the MICT Quiz Show held in cdo. :)
keep up the codes!

phengpheng:

I miss updating this blog… Sana may time and pc ako to learn new stuffs aside from my work…

support:

Congratulations, you’ve just completed the installation of this shoutbox.

pheng:

uy! you’re here again!

Jay:

Woooohhhh orange…sweat… nakakasilaw! hehe :)

jay:

tagboard flood hehe sensya… had nothing fun to do. :)

pheng:

jaaaaayyyyy….:) ketal man?:)

niel:

no spamming please :p hehehe joke lang jay.

Jay:

Uyyyyyy!!!! Grraaaaaaaiiiinnnneeee
:)
Sssshhhh, el sikret! :)
Niiiiiiiiiiiiieeeeeel
Sup dude!!!!
Paaaaaaaaaaaaaathy
Ketal!?

niel:

ei pheng! :D slick-elegant layout! love it!

yue:

phengpheng!

Leave a message ▼