Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- ESC_ equ 01bh ;ascii code of escape
- 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, '0'
- jb not_allowed_key_ ;jump if below '0'
- cmp al, '9'
- ja not_allowed_key_ ; jump if after '9'
- mov bl, al
- sub bl, '0'
- xchg ax, bx
- mov cl, 6
- mul cl
- xchg ax, bx
- mov ah, 02h
- next_char:
- mov dl, [Numbers_ + bx]
- int 21h
- inc bx
- cmp [Numbers_ + bx], ' '
- jne next_char
- mov dl, ' '
- int 21h
- jmp main_
- display_:
- mov dl, al ;display letter
- mov ah, 02h
- int 21h
- jmp main_ ;go back
- not_allowed_key_:
- mov ah, 02h
- mov dl, 07h ; sound
- int 21h
- jmp main_ ;go back
- exit_:
- mov ah, 09h ;output - byeStr
- mov dx, byeStr
- int 21h
- mov ah, 07h ;wait for input
- int 21h
- ret
- helloStr_ db "This program writes digits as words", $0d, $0a, "You can exit on ESC", $0d, $0a, "Try to input something:", $0d, $0a, "$"
- byeStr db 0dh, 0ah, "Press anything to terminate a program...$"
- Numbers_ db 'zero one two three four five six seven eight nine '
Advertisement
Add Comment
Please, Sign In to add comment