Reading serial port bytes/keypresses

38 views
Skip to first unread message

Al L.

unread,
Aug 22, 2025, 4:27:44 PMAug 22
to Altair-Duino
I've got an Altair-duno running BASIC-80 under CP/M.  I'm using a serial terminal as console I/O.

I'd like to be able to read individual bytes as they come in from the serial port (and also be able to check when a new byte has been received) from within BASIC-80. (Kind of like the INKEY$ function in some versions of BASIC).  Traditionally there would be an INP(x) port that would have this data, but I could not identify one (presumable because this is an emulator and not an actual Z80 input port).

I'd be grateful for any feedback on how to read a byte at a time as it comes in from the Altair-duino serial port, as well as when a new byte is received.

Thanks!
Al

Tom Wilson

unread,
Aug 22, 2025, 5:56:16 PMAug 22
to Altair-Duino
Why not just use INKEY$? That works fine on BASIC-80 versions 4 and 5. (I prefer V4 under CP/M, since it gives me more memory than V5.)

You can also directly talk to the serial ports by reading the ports with INP(). The emulator actually emulates a couple of different serial cards, and you can read the status and data ports the same way as on a vintage Altair system. I actually wrote a couple of little utilities in BASIC for doing just this.

This little test program will read from the first 32 input ports and display the results on the screen. You can use this to get an idea of what's happening as you play with the keyboard:


Make note of the ports that change value as you press keys. SIO ports come in pairs: the status port comes first, and the data port is next. IIRC, ports 0 and 1 are the default console port, and you should be able to read those to get information about the keyboard. 

Once you've figured out which ports to use, you can play with my terminal program: https://github.com/tomxp411/altair-toolbox/blob/main/basic/programs/term.bas

Lines 300-310 read from the serial port. Line 240 transmits to the serial port. 

Al L.

unread,
Aug 26, 2025, 10:24:07 PMAug 26
to Altair-Duino
Thanks for the ideas and programs.  This is really helpful!

-- Al

Reply all
Reply to author
Forward
0 new messages