1

I want to build a tetris game in assembly (tasm) and I want the cubes to go left/right according to what I press on the keyboard. I used this code:

mov ah, 00h
int 16h ;al=ascii charachter

but it waits for the keyboard press and I want it to keep going on and only if I press < or > it'll change, what can I write instead of this?

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
maya
  • 51
  • 2
  • 3
    You may wish to use AH=1/Int 16h that checks for a keystroke without actually waiting. Then if if there is a keystroke available use AH=0/int 16h to read it. http://www.ctyme.com/intr/rb-1755.htm – Michael Petch May 13 '22 at 12:50
  • 2
    Terminology: what you're looking for is a "**non-blocking**" read of a character or keypress. When an I/O function sleeps (aka blocks) until input is ready, that's called "blocking". Knowing that terminology let me search and find [Check for keypress without blocking if no key was pressed](https://stackoverflow.com/q/38755476) which explains the API Michael Petch suggested. – Peter Cordes May 13 '22 at 13:58

0 Answers0