Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- ESC_ equ $1b ;ascii code escape
- BELL_ equ 7 ;ascii codering
- start_:
- mov ah, 09h ;output - helloStr_
- mov dx, helloStr_
- int 21h
- main_:
- mov ah, 08h ;no echo input with waiting, output al - ascii code of pressed button
- int 21h
- cmp al, ESC_ ;was it escape?
- jne other_ ;if no go to other_
- jmp exit_ ;if yes exit
- other_:
- cmp al, '0' ;if letter is less than '0' it's incorrect, go to err_
- jb err_ ;jump if below
- cmp al, '9' ;if letter is greater than '9' it's incorrect, go to err_
- ja err_ ;jump if above
- mov dl, al ;else display that letter
- mov ah, 02h
- int 21h
- jmp main_ ;go back to start
- err_:
- mov ah, 02h ;play ring
- mov dl, BELL_
- int 21h
- jmp main_ ;go back to start3
- exit_:
- mov ah, 09h ;output - byeStr
- mov dx, byeStr
- int 21h
- mov ah, 07h ;wait for input
- int 21h
- ret
- helloStr_ db "This program allows as input only digits", $0d, $0a, "You can exit on ESC", $0d, $0a, "Try to input something:", $0d, $0a, "$"
- byeStr db 0dh, 0ah, "Press anything to terminate program...$"
Add Comment
Please, Sign In to add comment