; Name: lotto.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 6 lucky numbers out of 49 TITLE LOTTO DEDOMENA SEGMENT intro db "...::: Tuxeroi arithmoi Lotto :::...",10,13,10,13,"$" msg db 10,13,"Vrethike o arithmos : ","$" lucky db 6 dup(1) num db 0 monades db 0 dekades db 0 DEDOMENA ENDS KODIKAS SEGMENT ARXH: MOV AX,DEDOMENA MOV DS,AX mov si,0 getnumber: call random_generator ;klisi tis sinartisis pou tha epistrepsei ton tixaio arithmo cmp bh,49 ja getnumber ;sygkrish eisagwmenoy arithmoy me to 49 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 inc si cmp si,6 ;mexri na paroume 6 arithmous jb getnumber call printdec 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 printdec proc push ax push dx mov si,0 ;arxikopoioume aftous tous 2 kataxwrites mov cx,6 ;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 6 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=6 gia na ektipwthoun kai oi 6 arithmoi pop dx pop ax ret printdec endp telos: mov ah,4ch int 21h KODIKAS ENDS SOROS SEGMENT STACK db 256 dup(0) SOROS ENDS END ARXH