Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 100h
- .data
- msg1 db 0dh,0ah,'Do U want to convert or exit? Enter Y or N: $'
- msg2 db 0dh,0ah,'How many digits your number has? $'
- msg3 db 0dh,0ah,'Result in Octal: $'
- msg4 db 0dh,0ah,'Invalid $'
- msg5 db 0dh,0ah,'Enter the decimal number: $'
- msg6 db 0dh,0ah,'Enter the 1st Digit: $'
- msg7 db 0dh,0ah,'Enter the 2nd Digit: $'
- .code
- main proc
- mov ax,@data
- mov ds,ax
- option:
- mov ah,9
- lea dx, msg1
- int 21h
- mov ah,1
- int 21h;Enter y or n
- cmp al,'y'
- je y
- cmp al,'Y'
- je y
- jmp n
- y:
- mov ah,9
- lea dx,msg2
- int 21h
- mov ah,1
- int 21h
- cmp al,'1'
- je one
- cmp al,'2'
- je two
- jmp invalid
- one:
- mov ah,9
- lea dx,msg5
- int 21h
- mov ah,1
- int 21h
- mov bh,al
- cmp bh, 30h
- jl n
- cmp bh,'7'
- jg one_2
- mov ah,9
- lea dx,msg5
- int 21h
- mov ah,2
- mov dl, bh
- int 21h
- jmp option
- one_2:
- cmp bh,38h
- je cont
- cmp bh, 39h
- je cont
- cont:
- mov ah,9
- lea dx, msg3
- int
- mov ah,2
- mov dl,'1'
- int 21h
- sub bh,8
- mov dl,bh
- int 21h
- jmp option
- two:
- mov ah,9
- lea dx,msg6
- int 21h
- mov ah,1
- int 21h
- mov bh,al;for 1st digit
- mov ah,9
- lea dx,msg7
- int 21h
- mov ah,1
- int 21h
- mov ch,al;for 2nd digit
- cmp bh,'1'
- je t1
- cmp bh,'2'
- je t2
- jmp invalid
- t1:
- cmp ch,'0'
- jge c1
- jmp c2
- c1:
- cmp ch,'5'
- jle l1
- jmp c2
- l1:
- add ch,2
- mov ah,9
- lea dx,msg3
- int 21h
- mov ah,2
- mov dl,'1'
- int 21h
- mov dl,ch
- int 21h
- jmp option
- c2:
- sub ch,6
- mov ah,9
- lea dx,msg3
- int 21h
- mov ah,2
- mov dl,'2'
- int 21h
- mov dl,ch
- int 21h
- jmp option
- t2:
- cmp ch,'0'
- jg invalid
- mov ah,9
- lea dx,msg3
- int 21h
- mov ah,2
- mov dl,'2'
- int 21h
- mov dl,'4'
- int 21h
- jmp option
- invalid:
- mov ah,9
- lea dx,msg4
- int 21h
- jmp option
- n:
- mov ah,4ch
- int 21h
- main endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement