; Name: joker.asm ; Author: Matsaridis Panagiotis ; Supervisor: Dasygenis Minas ; Website: http://arch.icte.uowm.gr ; Date: March 2013 ; ; License: Free for personal use, with Creative Commons License ; If you use it, please reference the source website. ; ; Purpose: Compute 5 lucky numbers out of 45 and 1 out of 20 TITLE JOKER DEDOMENA SEGMENT intro db "...::: Tuxeroi arithmoi Joker :::...",10,13,10,13,"$" msg db 10,13,"Vrethike o arithmos : ","$" msgjoker db 10,13,"Vrethike to Joker : ","$" lucky db 5 dup(0) monades db 0 dekades db 0 joker db 0 DEDOMENA ENDS KODIKAS SEGMENT ARXH: MOV AX,DEDOMENA MOV DS,AX mov si,0 ;arxikopoihsh tis timis tou si me miden gia na ksekinisei to loop getnumber: call random_generator ;klisi tis sinartisis pou tha epistrepsei ton tixaio arithmo cmp bh,45 ja getnumber ;sygkrish eisagwmenoy arithmoy me to 45 cmp bh,0 jbe getnumber ;sygkrish eisagwmenoy arithmoy me to 0 mov di,0 ;arxikopoihsh tou DI me 0 checkloop: ;ksekina 2o loop pou elenxei proigoumenous idious tixerous arithmous cmp bh,lucky[di] je getnumber inc di cmp di,si jb checkloop ;to loop sigrinei mexri ton arithmo prin apo afton pou deixnei o SI ;dld an o SI einai 4 ekeini ti stigmi, tha sigrinei me lucky[0], [1], [2] kai [3] mov lucky[si],bh ;afou perasei ola ta check o arithmos mpainei ston pinaka inc si cmp si,5 ;mexri na paroume 5 arithmous jb getnumber getjoker: ;ksekina i diadikasia gia tin evresi joker call random_generator cmp bh,20 ;aporiptetai megaliteros tou 20 ja getjoker cmp bh,0 jbe getjoker ;i mikroteros/isos tou 0 mov joker,bh ;eisagete sti metavliti joker call print ;klisi print! jmp telos random_generator PROC ;Random Generator ;Input: - ;Output: Random number 0-255 stored in BH PUSH AX PUSH DX MOV AH,2Ch INT 21H ADD BL,DH ADD BL,DL ADD BH,BL POP DX POP AX RET random_generator ENDP print proc push ax push dx mov si,0 ;arxikopoioume aftous tous 2 kataxwrites mov cx,5 ;kathws i timi tous exei allaksei apo ta proigoumena loops lea dx,intro ;enfanisi minimatos header mov ah,09 int 21h printloop: ;diadikasia ektipwsis twn 5 arithmwn mov dl,lucky[si] mov al,dl mov ah,0 mov dl,10 div dl ;xwrismos dekadas k monadas mov monades,ah ;eisagwgi twn parapanw se antistoixes metavlites mov dekades,al lea dx,msg ;ektipwsi proporevomenou minimatos mov ah,09 int 21h add dekades,30h mov dl,dekades ;ektupwsh dekadas mov ah,02 int 21h add monades,30h mov dl,monades ;ektupwsh monadas mov ah,02 int 21h inc si loop printloop ;cx=5 gia na ektipwthoun kai oi 5 arithmoi ; ;ektipwsi joker opws kai prin ; mov dl,joker mov al,dl mov ah,0 mov dl,10 div dl mov monades,ah mov dekades,al lea dx,msgjoker mov ah,09 int 21h add dekades,30h mov dl,dekades ;ektupwsh dekadas mov ah,02 int 21h add monades,30h mov dl,monades ;ektupwsh monadas mov ah,02 int 21h pop dx pop ax ret print endp telos: mov ah,4ch int 21h KODIKAS ENDS SOROS SEGMENT STACK db 256 dup(0) SOROS ENDS END ARXH