Skip to main content

Intel 8080 IO Ports

The Intel 8080 CPU can address up to 256 input ports and 256 output ports; allowing for virtually unlimited system expansion. Access to the ports is via the IN and OUT Intel 8080 CPU instructions, see page 38.

Intel 8080 IO ports and peripherals

The image shows an example of Intel 8080 IO port usage

Altair emulator software-enabled ports

The Altair emulator uses Intel 8080 IO ports to provide time services, random numbers, and access to cloud services.

  • You can access Intel 8080 IO ports from BASIC, C, and Assembly programming languages, and directly using Intel 8080 opcodes. See Using Intel 8080 Input Output ports.
  • The Intel 8080 software-enabled IO ports are implemented in the io_ports.c file.
  • You can extend the Altair 8800 by adding additional IO port functions, for example, integrating machine learning capabilities.

Output ports

The following tables show output port numbers and port data values. Typically, calling an output port will load data to be read via an input port.

Utility ports

PortPort dataLoads
290-255Set timer period in milliseconds
300-255Set timer period in seconds
410System tick count
420Current UTC date and time
430Current local date and time
440Generates a random number between -32000 and 32000
68ASCIISet getfile (gf) filename
110ASCIISet getfile (gf) custom endpoint url
1110Load getfile (gf) custom endpoint url
1120Select getfile (gf) endpoint to use
1130Load getfile (gf) selected endpoint
114ASCIISet web request file name and call on NULL

Weather ports

PortPort dataLoads
340"Celsius" string literal
341"Millibar" string literal
342"Humidity %" string literal
343"Wind km/h" string literal
344"Wind degrees" string literal
345"Observation" string literal
350Temperature (Note 1)
351Pressure (Note 1)
352Relative humidity (Note 1)
353Wind speed (Note 1)
354Wind direction (Note 1)
355Weather observation (Note 1)

Location ports

PortPort dataLoads
360"Latitude" string literal
361"Longitude" string literal
362"Longitude" string literal
363"City" string literal
370Latitude (Note 2)
371Longitude (Note 2)
372Country name (Note 2)
373City name (Note 2)

Pollution ports

PortPort dataLoads
380"AQI(CAQI)" string literal
381"CO" string literal
382"NO" string literal
383"NO2" string literal
384"O3" string literal
385"SO2" string literal
386"NH3" string literal
387"PM2.5" string literal
388"PM1.0" string literal
390Air quality index (Note 1)
391Carbon monoxide level (Note 1)
392Nitrogen monoxide level (Note 1)
393Nitrogen dioxide level (Note 1)
394Ozone level (Note 1)
395Sulphur dioxide level (Note 1)
396Ammonia level (Note 1)
397Particulate matter 2.5 level (Note 1)
398Particulate matter 1.0 level (Note 1)

Publish to Azure IoT ports

PortPort dataLoads
31ASCIIPublish JSON to IoT Hub/Central (Max 256 characters) (Note 3)
320Publish weather and pollution data to IoT Hub/Central (Note 3)

Azure Sphere specific ports

PortPort dataLoads
601 or 0Turn Red LED on or off
611 or 0Turn Green LED on or off
621 or 0Turn Blue LED on or off
630Loads onboard temperature
631Loads onboard pressure
632Loads onboard light sensor
640Loads accelerometer X axis
641Loads accelerometer Y axis
642Loads accelerometer Z axis
643Start the accelerometer timer
644Stop the accelerometer timer
645One-off accelerometer reading
646Calibrate accelerometer for angular rate
647Load accelerometer for angular rate
648Get latest movement inference result
660Power management disable
661Power management enable
662Power management sleep
671..255Power management wake from sleep (seconds)
710Get Azure Sphere OS version number
720Get first 8 characters of Azure Sphere device ID

8x8 LED Panels

  • Pi Sense HAT
  • Mikroe Retro 8800 Click
PortPort dataLoads
650..8Power management LED brightness

General ports

PortPort dataLoads
700Loads Altair emulator version number

Display 8x8 LED panel ports

PortPort dataLoads
800, 1, 20 = Bus mode, 1 = Font mode, 2 = Bitmap mode
810, 1, 28x8 LED Panel RGB color. 0 = Red, 1 = Green, 2 = Blue
820..255Set 8x8 LED Panel Red palette
830..255Set 8x8 LED Panel Green palette
840..255Set 8x8 LED Panel Blue palette
850..255Display ASCII character
900..255Set row 0 bitmap
910..255Set row 1 bitmap
920..255Set row 2 bitmap
930..255Set row 3 bitmap
940..255Set row 4 bitmap
950..255Set row 5 bitmap
960..255Set row 6 bitmap
970..255Set row 7 bitmap
980..63Turn pixel n on
990..63Turn pixel n off
1000..63Pixel flip
1010Clear, turn all pixels off
1020Draw bitmap

OpenAI ChatGPT

PortPort dataLoads
1200..255Set system Message
1210..255Set user message
1220..255Set assistant message
1230Clear all messages
1240Load ChatGPT stream

Input ports

Typically, input ports will read data loaded by an output port.

PortDescription
29Query milliseconds timer status. Enabled or expired (true or false)
30Query seconds timer status. Enabled or expired (true or false)
31Query publish JSON pending status. Enabled or expired (true or false)
32Query publish weather pending status. Enabled or expired (true or false)
68devget eof
69Is network ready
200Read loaded byte stream
201Read webget file stream
202Read devget file stream
123Read OpenAi ChatGPT stream
120Read OpenAI streaming status
121Read OpenAI message
122Read OpenAI finished status

Notes.

  1. Requires an Open Weather Map API Key, and an active internet connection.
  2. Requires an active internet connection to call the geojs.io web service.
  3. Requires an active internet connection and a free or paid tier or Azure IoT Central.

Using Intel 8080 Input Output ports

The following code snippets use the Intel 8080 IO ports. The code samples included on the CP/M boot disk expand on these snippets.

Assembler access to Intel 8080 IO Ports

The following assembly code demonstrates the use of the Intel 8080 IO port 30 timer. The code sets a 2-second delay, and then waits for the timer to expire. This is a snippet of the SLEEP.ASM sample included on drive B: of the Altair emulator.

      ORG 0100H   ;CP/M base of TPA (transient program area)
MVI A,2 ;Move 2 to the accumulator to set a 2 second delay
OUT 30 ;Start timer
LOOP: IN 30 ;Get delay timer state into the accumulator
CPI 00H ;If accumulator equal to 0 then timer has expired
JZ BACK ;Jump on zero
JMP LOOP
BACK: RET

BSD C access to Intel 8080 IO Ports

The following C code demonstrates the use of the Intel 8080 IO port 30 timer. The code sets a 1-second delay, and then waits for the timer to expire. This is a snippet of the HW.C sample included on drive B: of the Altair emulator.

outp(30,1);      /* Enable delay for 1 second */
while(inp(30)); /* Wait for delay to expire */

BASIC access to Intel 8080 IO Ports

The following BASIC code demonstrates the use of the Intel 8080 IO port 30 timer. The code sets a 1-second delay, and then waits for the timer to expire. This is a snippet of the COUNT.BAS sample included on drive A: of the Altair emulator.

Delay IO ports

900 REM This sleep subroutine sleeps or delays for 1 second
1000 OUT 30, 1
1100 WAIT 30, 1, 1
1200 RETURN

Weather IO ports

The following BASIC code demonstrates the use of Intel 8080 output port 35 to load the current temperature, and the input port to read the temperature. This is a snippet of the WEATHER.BAS sample included on drive A: of the Altair emulator.

500 PORT = 34 : REM Set the output port number
510 PDATA = 0 : REM Set the port data value to 0 for temperature
520 GOSUB 4800 : REM Loads the temperature and then reads the temperature string
530 PRINT RSTRING$
540 END

4800 REM SUBROUTINE READS STRING DATA FROM PORT UNTIL NULL CHARACTER
4900 OUT PORT, PDATA
5000 RSTRING$ = ""
5100 C=INP(200) : REM Read the temperature character by character until NULL returned
5200 IF C = 0 THEN RETURN
5300 RSTRING$ = RSTRING$ + CHR$(C)
5400 GOTO 5100

Font support

The following example shows how to use the Intel 8080 IO ports to display characters on the Pi Sense HAT or Retro Click 8x8 LED panels. To understand IO ports, refer to the io_ports.c source code. This example is included on drive A: in a file named FONT.BAS.

100 REM 8x8 LED Panel Demo
200 OUT 80,1 : REM Flip the 8x8 LED panel to FONT mode
300 FOR J = 1 TO 10
400 FOR I = 33 TO 122
500 OUT 81, I MOD 3 : REM Cycle font color
600 OUT 85, I : REM Display character on the 8x8 LED panel
700 PRINT CHR$(I)
800 OUT 29, 250 : WAIT 29, 1, 1 : REM Pause for 250 milliseconds
900 NEXT I
1000 NEXT J
1100 OUT 80,0

Azure Sphere Blinky

The following example shows how to use the Intel 8080 IO ports to blink LEDs on an Azure Sphere. To understand how IO ports are implemented, refer to the io_ports.c source code.

5 OUT 80, 1 : REM switch display to font mode
10 WHILE 1=1 : REM Loop forever
20 OUT 60, 1 : REM switch on the red LED
30 OUT 29, 250 : WAIT 29, 1, 1 : REM delay 250 milliseconds
40 OUT 61, 1 : REM switch on the green LED
50 OUT 29, 250 : WAIT 29, 1, 1 : REM delay 250 milliseconds
60 OUT 62, 1 : REM switch on the blue LED
70 OUT 29, 250 : WAIT 29, 1, 1 : REM delay 250 milliseconds
80 OUT 60, 0 : OUT 61, 0 : OUT 62, 0 : REM Turn off all LEDs
85 OUT 29, 250 : WAIT 29, 1, 1 : REM delay 250 milliseconds
90 WEND
100 OUT 80, 0 : REM switch display to bus mode