Author Topic: Reading the Status Register of the Parallel Port (solved)  (Read 1062 times)

FORTRANS

  • Member
  • *****
  • Posts: 1109
Re: Reading the Status Register of the Parallel Port (solved)
« Reply #15 on: June 04, 2021, 03:07:29 AM »
Hi,

By the way, is there a way to read the keyboard and, if there's nothing there, just continue instead of waiting for a key to be pressed?

   INT 16H is the BIOS keyboard functions.  Functions 0 and 10H
return a key when one is available.  Functions 1 and 11H check
the status of the keyboard buffer.

INT 16,01   Check Keyboard Status

   Checks the input buffer to see if there is a key waiting.
If a key is available, the codes are returned in AX, but not
removed from the buffer.  If no key available, the Zero Flag
is set.

INPUT  AH = 1

OUTPUT Zero Flag = 1, Buffer is empty
       Zero Flag = 0, AH = Scancode, AL = Character or 0


Cheers,

Steve N.

P.S.
minerio got to be first.  I'm just a slow typist.
SRN

popcalent

  • Regular Member
  • *
  • Posts: 24
Re: Reading the Status Register of the Parallel Port (solved)
« Reply #16 on: June 04, 2021, 11:45:33 AM »
Thank you both!
 :thumbsup:

popcalent

  • Regular Member
  • *
  • Posts: 24
Re: Reading the Status Register of the Parallel Port (solved)
« Reply #17 on: June 05, 2021, 03:12:04 AM »
I'm trying to use INT16H to check if the keyboard buffer is empty or not, if it's empty, then go back to beginning of loop, if it's not do whatever... But I can't get it to work... This is my code:

0 MAIN_LOOP:
1    MOV AH, 1
2    INT 16H
3    JZ  READ_KB
4    ;DO STUFF THAT NEEDS TO BE DONE EVERY ITERATION
5    JMP MAIN_LOOP

6 READ_KB:
7    MOV AH, 0 ;READ KB BUFFER
8    INT 16H
9    ;DO STUFF ACCORDING TO THE KEY THAT WAS PRESSED
10   JMP MAIN_LOOP


The program never goes to line 4, whether I press a key or not. Then it stops at line 8 waiting for me to press a key. I understand that lines 7, and 8 are necessary because lines 1 and 2 do not remove a keystroke from the buffer. If I remove lines 7,and 8. The loop iterates really fast and the program ends after a second (it doesn't crash). What am I doing wrong?

FORTRANS

  • Member
  • *****
  • Posts: 1109
Re: Reading the Status Register of the Parallel Port (solved)
« Reply #18 on: June 05, 2021, 04:21:38 AM »

Hi,

   The zero flag is set if the buffer is empty.  So you
would jump to the none ready code with JZ.  You
would jump to character available code with JNZ.

Regards,

Steve N.

popcalent

  • Regular Member
  • *
  • Posts: 24
Re: Reading the Status Register of the Parallel Port (solved)
« Reply #19 on: June 05, 2021, 05:02:42 AM »
Thanks, FORTRANS.

I knew ZF=1 means no keystroke, and vice versa. And, I checked, and rechecked, and double checked, but, for some reason, this escaped me!