Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .data
- m1 db 0ah,0dh,'type a character :','$'
- m2 db 0ah,0dh,'the ascii code of '
- c1 db ?,' in hexa is ','$'
- .code
- main proc
- mov ax,@data
- ;intialize ds
- mov ds,ax
- ;------------
- begin: mov ah,9
- ;prompt user
- lea dx,m1
- int 21h
- mov ah,1
- ;read char.
- int 21h
- cmp al,0dh
- ;if cr exit
- je out_
- mov c1,al
- ;store char
- .
- mov bl,al
- ;take a copy of char
- mov ah,9
- ;display 2
- lea dx,m2
- int 21h
- mov cl,4
- shr c1,cl
- ;prapare for display 1
- ;* note below
- add c1,30h
- ;convert to char.
- mov dl,c1
- jmp exe1
- continue: and bl,0fh
- ;convert 2
- cmp bl,9
- ;if >9 mean a,b,cā¦..hex ch.
- jg error_
- add bl,30h
- ;convert to char
- .
- mov dl,bl
- jmp exe2
- exe1: mov ah,2
- ;1
- int 21h
- jmp continue
- exe2: mov ah,2
- int 21h
- jmp begin
- ;ask if you want to do it again
- ;------------
- error_: add bl,37h
- ;convert to a,b,cā¦. hexa ch
- .
- mov dl,bl
- mov ah,2
- ;display it
- int 21h
- jmp begin
- ;ask if you want to do it again
- out_: mov ah,4ch
- ;return to dos
- int 21h
- main endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement