BDOS Direct console IO

67 views
Skip to first unread message

Robb Bates

unread,
Nov 20, 2025, 9:54:47 PM (8 days ago) Nov 20
to RC2014-Z80
Another BDOS weirdness

I am trying to use BDOS function 6 to get a non-block keypress.  E=$FF

I call the BDOS function every maybe 50 instructions, but rarely get a capture.  It returns zero even though I'm holding down a key.

It's not like it's slow.  More like it's very sporadic and very occasionally captures the keypress.

Any ideas?

Robb

Wayne Warthen

unread,
Nov 20, 2025, 10:34:07 PM (8 days ago) Nov 20
to RC2014-Z80
I'm not sure if I am understanding exactly.

If you hold a key down, then the key will "repeat" 10 times per second (or some rate like that).  When you call BDOS #6, it should return a keystroke at the same rate.  If you are in a tight loop, it will return 0 most of the time, but return the keystroke 10 times each second.  To say it another way, holding down a key does not cause BDOS #6 to continuously return the keystroke.

Thanks, Wayne

Michelle Lawson

unread,
Nov 21, 2025, 6:27:38 PM (7 days ago) Nov 21
to RC2014-Z80
FWIW, I'm trying to do the same thing. I have the code written, but I haven't tested it out yet.
;------------------------------------------------------
;Check to see if there is a Console Command request
;------------------------------------------------------
Con_Chk: ld      b,stat_loop_cnt         ;load B with the 256 loops
Con_In: ld e,FFh ;value for single status checking
ld c,condir ;BDOS function 6 for direct I/O
call bdos
jp nz,con_valid ;jump if A contains a character
dec b ;one less loop to go
ld a,b
cp 00h ;have all loops been executed?
jp nz,Con_In ;if not, keep looping

Ed Silky

unread,
Nov 21, 2025, 9:45:25 PM (7 days ago) Nov 21
to rc201...@googlegroups.com
Hi Michelle,

I'm not sure if you are looking for any tips on Z80 assy... if not, just say so. Anyway, you can shorten your code a bit if you want.

(existing)
Con_Chk: ld b,stat_loop_cnt ;load B with the 256 loops
Con_In:  ld e,FFh           ;value for single status checking
         ld c,condir        ;BDOS function 6 for direct I/O
         call bdos
         jp nz,con_valid    ;jump if A contains a character
         dec b              ;one less loop to go
         ld a,b
         cp 00h             ;have all loops been executed?
         jp nz,Con_In       ;if not, keep looping

(this part)  
         dec b              ;one less loop to go
         ld a,b
         cp 00h             ;have all loops been executed?
         jp nz,Con_In       ;if not, keep looping
(can be)
         djnz Con_In        ;check again

Also, the BDOS calls don't guarantee that they don't use/modify registers, so you should push BC before making the BDOS call (since you care about the value in B).

Another tip, if you did need to check B for zero (not using the DJNZ to decrement and jump), the DEC B instruction sets the Z flag if the result is 0, so there isn't a need to load it into A and CP 0. If you weren't decrementing B, and just need to check it for zero, you can LD A,B then OR A, that will set the Z flag if B was zero, and it takes 2 bytes of code.

-Ed 

--
You received this message because you are subscribed to the Google Groups "RC2014-Z80" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rc2014-z80+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/rc2014-z80/3bdf0e96-11a8-4c51-abe5-74f87043f21an%40googlegroups.com.

Michelle Lawson

unread,
Nov 21, 2025, 10:31:13 PM (7 days ago) Nov 21
to rc201...@googlegroups.com
Thanks Ed. I've used DJNZ before, not sure why I overlooked that.

Reply all
Reply to author
Forward
0 new messages