Vanilla_Fury

fasm_4_1

Apr 25th, 2021 (edited)
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. org 100h
  2. ESC_ equ $1b ;ascii code escape
  3. BELL_ equ 7 ;ascii codering
  4.  
  5. start_:
  6. mov ah, 09h ;output - helloStr_
  7. mov dx, helloStr_
  8. int 21h
  9. main_:
  10. mov ah, 08h ;no echo input with waiting, output al - ascii code of pressed button
  11. int 21h
  12. cmp al, ESC_ ;was it escape?
  13. jne other_ ;if no go to other_
  14. jmp exit_ ;if yes exit
  15. other_:
  16. cmp al, '0' ;if letter is less than '0' it's incorrect, go to err_
  17. jb err_ ;jump if below
  18. cmp al, '9' ;if letter is greater than '9' it's incorrect, go to err_
  19. ja err_ ;jump if above
  20. mov dl, al ;else display that letter
  21. mov ah, 02h
  22. int 21h
  23. jmp main_ ;go back to start
  24. err_:
  25. mov ah, 02h ;play ring
  26. mov dl, BELL_
  27. int 21h
  28. jmp main_ ;go back to start3
  29. exit_:
  30. mov ah, 09h ;output - byeStr
  31. mov dx, byeStr
  32. int 21h
  33. mov ah, 07h ;wait for input
  34. int 21h
  35. ret
  36.  
  37. helloStr_ db "This program allows as input only digits", $0d, $0a, "You can exit on ESC", $0d, $0a, "Try to input something:", $0d, $0a, "$"
  38. byeStr db 0dh, 0ah, "Press anything to terminate program...$"
Add Comment
Please, Sign In to add comment