Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- ESC_ equ 01bh ;ascii code of escape
- A_UPPER_ equ 65 ;ascii code of A
- Z_UPPER_ equ 90 ;ascii code of Z
- A_LOWER_ equ 97 ;ascii code of a
- Z_LOWER_ equ 122 ;ascii code of z
- BELL_ equ 7 ;ascii code of ring
- 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, A_UPPER_ ;if below A than it's incorrect, jump to err_
- jb err_ ;jump if below
- cmp al, Z_UPPER_ ;if below or equal Z it's uppercase, jump to convert_
- jbe convert_ ;jump if below or equal
- cmp al, A_LOWER_ ;if below a than it's incorrect, jump to err_
- jb err_ ;jump if below
- cmp al, Z_LOWER_ ;if below or equal z it lowercase, jump to display_
- jbe diplay_ ;jump if below or equal
- jmp err_ ;if it's here than it's incorrect, jump to err_
- convert_:
- add al, 32 ;to convert to lowercase you add 32 to ascii code
- diplay_:
- mov dl, al ;display letter
- mov ah, 02h
- int 21h
- jmp main_ ;go back
- err_:
- mov ah, 02h ;play ring
- mov dl, BELL_
- int 21h
- jmp main_ ;go back to start
- exit_:
- mov ah, 09h ;output - byeStr
- mov dx, byeStr
- int 21h
- mov ah, 07h ;wait for input
- int 21h
- ret
- helloStr_ db "This program converts uppercase letters to lowercase", $0d, $0a, "You can exit on ESC", $0d, $0a, "Try to input something:", $0d, $0a, "$"
- byeStr db 0dh, 0ah, "The program has now terminated. Press anything to continue...$"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement