Advertisement
madopew

4_1

Mar 28th, 2020
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     org 100h
  2.  
  3.     ESC_ equ 01bh ;ascii code escape
  4.     COLON_ equ 58 ;ascii code :
  5.     AT_ equ 64 ;ascii code @ (< > ? ; - are between : and @)
  6.     BELL_ equ 7 ;ascii codering
  7.  
  8. start_:
  9.     mov ah, 09h ;output - helloStr_
  10.     mov dx, helloStr_
  11.     int 21h
  12. main_:
  13.     mov ah, 08h ;no echo input with waiting, output al - ascii code of pressed button
  14.     int 21h
  15.     cmp al, ESC_ ;was it escape?
  16.     jne other_ ;if no go to other_
  17.     jmp exit_ ;if yes exit
  18. other_:
  19.     cmp al, COLON_ ;if letter is less than : it's incorrect, go to err_
  20.     jb err_ ;jump if below
  21.     cmp al, AT_ ;if letter is greater than @ it's incorrect, go to err_
  22.     ja err_ ;jump if above
  23.     mov dl, al ;else just display that letter
  24.     mov ah, 02h
  25.     int 21h
  26.     jmp main_ ;go back to start
  27. err_:
  28.     mov ah, 02h ;play ring
  29.     mov dl, BELL_
  30.     int 21h
  31.     jmp main_ ;go back to start
  32. exit_:
  33.     mov ah, 09h ;output - byeStr
  34.     mov dx, byeStr
  35.     int 21h
  36.     mov ah, 07h ;wait for input
  37.     int 21h
  38.     ret
  39. helloStr_ db "This program filters input text according to", $0d, $0a, ":, ;, <, =, >, ?, @", $0d, $0a, "You can exit on ESC", $0d, $0a, "Try to input something:", $0d, $0a, "$"
  40. byeStr db 0dh, 0ah, "The program has now terminated. Press anything to continue...$"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement