Advertisement
madopew

4_2

Mar 28th, 2020
539
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 of escape
  4.     A_UPPER_ equ 65 ;ascii code of A
  5.     Z_UPPER_ equ 90 ;ascii code of Z
  6.     A_LOWER_ equ 97 ;ascii code of a
  7.     Z_LOWER_ equ 122 ;ascii code of z
  8.     BELL_ equ 7 ;ascii code of ring
  9.  
  10. start_:
  11.     mov ah, 09h ;output - helloStr
  12.     mov dx, helloStr_
  13.     int 21h
  14. main_:
  15.     mov ah, 08h ;no echo input with waiting, output al - ascii code of pressed button
  16.     int 21h
  17.     cmp al, ESC_ ;was it escape?
  18.     jne other_ ;if no go to other_
  19.     jmp exit_ ;if yes exit
  20. other_:
  21.     cmp al, A_UPPER_ ;if below A than it's incorrect, jump to err_
  22.     jb err_ ;jump if below
  23.     cmp al, Z_UPPER_ ;if below or equal Z it's uppercase, jump to convert_
  24.     jbe convert_ ;jump if below or equal
  25.     cmp al, A_LOWER_ ;if below a than it's incorrect, jump to err_
  26.     jb err_ ;jump if below
  27.     cmp al, Z_LOWER_ ;if below or equal z it lowercase, jump to display_
  28.     jbe diplay_ ;jump if below or equal
  29.     jmp err_ ;if it's here than it's incorrect, jump to err_
  30.     convert_:
  31.         add al, 32 ;to convert to lowercase you add 32 to ascii code
  32.     diplay_:
  33.         mov dl, al ;display letter
  34.         mov ah, 02h
  35.         int 21h
  36.         jmp main_ ;go back
  37. err_:
  38.     mov ah, 02h ;play ring
  39.     mov dl, BELL_
  40.     int 21h
  41.     jmp main_ ;go back to start
  42. exit_:
  43.     mov ah, 09h ;output - byeStr
  44.     mov dx, byeStr
  45.     int 21h
  46.     mov ah, 07h ;wait for input
  47.     int 21h
  48.     ret
  49. helloStr_ db "This program converts uppercase letters to lowercase", $0d, $0a, "You can exit on ESC", $0d, $0a, "Try to input something:", $0d, $0a, "$"
  50. byeStr db 0dh, 0ah, "The program has now terminated. Press anything to continue...$"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement