Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model tiny
- .stack
- .data
- nr dw ?
- mesaj1 db "Introduceti un numar:",10,13,"$"
- mesaj2 db "Numarul nu poate incepe cu 0, incercati din nou:",10,13,,"$"
- mesaj3 db "Numarul nu poate avea decat cifre, incercati din nou:",10,13,,"$"
- mesaj4 db "Numarul introdus este:",10,13,,"$"
- .code
- main proc
- citire:
- mov ax,seg mesaj1
- mov ds,ax
- lea dx,mesaj1
- mov ah,09h
- int 21h
- init:
- mov nr,0h
- mov bl,10d
- mov cx,0000h
- mov dx,0000h
- jump3:
- mov ah,01h
- int 21h
- mov ah,0h
- cmp al,0Dh
- je iesire
- mov cl,al
- mov ax,nr
- sub cl,30h
- mul bl
- add ax,cx
- mov nr,ax
- call verify
- jmp jump3
- iesire:
- mov ax,seg mesaj4
- mov ds,ax
- lea dx,mesaj4
- mov ah,09h
- int 21h
- mov ax,nr
- mov cx,0h
- jump1:
- mov dx, 0000h
- div bx
- push dx
- inc cx
- cmp ax, 0
- jne jump1
- jump2:
- pop dx
- add dx,30h
- mov ah,02h
- int 21h
- loop jump2
- mov ah,4ch
- int 21h
- main endp
- verify proc
- add cl,30h
- cmp ax,39h
- jbe numar
- ja numar2
- numar:
- cmp cl,31h
- jb eroare1
- cmp cl,39h
- ja eroare1
- jmp jump3
- numar2:
- cmp cl,30h
- jb eroare2
- cmp cl,39h
- ja eroare2
- jmp jump3
- eroare1:
- mov ax,seg mesaj2
- mov ds,ax
- lea dx,mesaj2
- mov ah,09h
- int 21h
- jmp init
- eroare2:
- mov ax,seg mesaj3
- mov ds,ax
- lea dx,mesaj3
- mov ah,09h
- int 21h
- jmp init
- ret
- verify endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement