How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the Z80 Assembly programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the Z80 Assembly programming language
Table of Contents
Problem Statement
Obtain a valid Y or N response from the keyboard. The keyboard should be flushed, so that any outstanding key-presses are removed, preventing any existing Y or N key-press from being evaluated. The response should be obtained as soon as Y or N are pressed, and there should be no need to press an enter key.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Keyboard input/Obtain a Y or N response step by step in the Z80 Assembly programming language
Source code in the z80 programming language
wait_for_key_input:
call &BB06 ;bios call, waits until key is pressed, returns key's ASCII code into A
and %11011111 ;converts to upper case
cp 'Y'
jp z,User_Chose_Yes
cp 'N'
jp z,User_Chose_No
jp wait_for_key_input
User_Chose_Yes:
;your code for what happens when the user types "Y" goes here
ret
User_Chose_No:
;your code for what happens when the user types "N" goes here
ret
You may also check:How to resolve the algorithm Old lady swallowed a fly step by step in the Julia programming language
You may also check:How to resolve the algorithm Anadromes step by step in the Rust programming language
You may also check:How to resolve the algorithm Sudan function step by step in the Arturo programming language
You may also check:How to resolve the algorithm Camel case and snake case step by step in the Julia programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Make programming language