Vanilla_Fury

fasm_4_2

Apr 25th, 2021 (edited)
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. org 100h
  2.  
  3. ESC_ equ 01bh ;ascii code of escape
  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'
  17. jb not_allowed_key_ ;jump if below '0'
  18. cmp al, '9'
  19. ja not_allowed_key_ ; jump if after '9'
  20. mov bl, al
  21. sub bl, '0'
  22. xchg ax, bx
  23. mov cl, 6
  24. mul cl
  25. xchg ax, bx
  26. mov ah, 02h
  27. next_char:
  28. mov dl, [Numbers_ + bx]
  29. int 21h
  30. inc bx
  31. cmp [Numbers_ + bx], ' '
  32. jne next_char
  33. mov dl, ' '
  34. int 21h
  35. jmp main_
  36. display_:
  37. mov dl, al ;display letter
  38. mov ah, 02h
  39. int 21h
  40. jmp main_ ;go back
  41. not_allowed_key_:
  42. mov ah, 02h
  43. mov dl, 07h ; sound
  44. int 21h
  45. jmp main_ ;go back
  46. exit_:
  47. mov ah, 09h ;output - byeStr
  48. mov dx, byeStr
  49. int 21h
  50. mov ah, 07h ;wait for input
  51. int 21h
  52. ret
  53.  
  54. helloStr_ db "This program writes digits as words", $0d, $0a, "You can exit on ESC", $0d, $0a, "Try to input something:", $0d, $0a, "$"
  55. byeStr db 0dh, 0ah, "Press anything to terminate a program...$"
  56. Numbers_ db 'zero one two three four five six seven eight nine '
Advertisement
Add Comment
Please, Sign In to add comment