Skip to content
Dave Glover edited this page Jul 5, 2022 · 14 revisions

Welcome to the AzureSphereAltair8800 Ver 2 Wiki

Welcome to the Altair 8800 emulator repo. If you're interested in retrocomputing, software development, AI, cloud services, and climate monitoring you've arrived at the right repo.

The Altair 8800 kick-started the personal computer revolution. Microsoft's first product was Altair BASIC written for the Altair 8800 by Bill Gates and Paul Allen. At the time, Altair BASIC was a huge step forward as it allowed people to write programs using a high-level programming language.

The Altair project can run standalone and is a fantastic safe way to explore machine-level programming, Intel 8080 Assembly programming, along with C and BASIC development.

Optionally, the project integrates free weather and pollution cloud services from Open Weather Map, along with Azure IoT Central, and Azure Anomaly Detection Cognitive Service. The following reports were generated from data published by the Altair emulator using data sourced from Open Weather Map.

IoT Central Sydney pollution report Azure Anomaly Detection report
The images shows pollution report for Sydney The following images shows temperature based anomalies

What's new in version 2

This is version 2 of the Azure Sphere Cloud Enabled Altair 8800 and shares the same code base as the Cloud-Enabled Altair 8800 Emulator project that runs on Windows, Linux, macOS, and Raspberry Pi.

The main differences in version 2 are:

  1. The web terminal now connects over WebSockets. This reduces the solution complexity and allows a local connection from the web terminal the the Azure Sphere device running the Altair emulator.
  2. There are two mutable storage options for the Altair emulator on Azure Sphere. Either SD Card or 100kB of transient storage provided by the real-time difference disk service.
  3. Greater focus on the Altair developer experience. There are more examples across BASIC, C, and Assembly programming languages with richer access to climate data and timing services.
  4. Integration with cloud based AI services, notably Anomaly Detection API. This enables the opportunity to explore AI services using climate data.
  5. Significant expansion of Intel 8088 IO ports allow for access to climate, timing and publishing services.

Documentation and source code

Run your own Altair

The Altair emulator is supported on Azure Sphere devices from Avnet and Seeed Studio. If an Azure Sphere device is paired with the Altair front panel kit or the Mikroe Altair Retro Click, the Altair address and data bus activity is displayed.

Azure Sphere with the Altair front panel kit MikroE Retro Click
The gif shows the Altair on Azure Sphere with the Altair front panel The gif shows the address and data bus LEDs in action

Altair 8800 emulator architecture

The following diagram summarizes the Altair emulator architecture.

Starting from the bottom left and moving up and then to the right.

  • POSIX Compatible OS:. The Altair 8800 emulator runs on POSIX compatible operating systems, including Linux, macOS, Windows WSL 2, and Raspberry Pi OS.
  • WebSocket & Azure IoT C: These communication libraries connect the Altair emulator to the web terminal and cloud services. The Altair terminal IO messages are routed over WebSockets, and the Azure IoT C SDK connects the Altair to Azure IoT Central.
  • libuv library: The Altair coordinates activities on the main thread using the uvlib library event loop services.
  • EdgeDevX: This library simplifies access to Azure IoT services, provides event-timer services, along with several useful utilities.
  • Terminal IO & Cloud Services: The Intel 8080 CPU provides 256 input ports and 256 output ports. The Intel 8080 ports were used to integrate peripherals such as disk drives, printers, and modems. However, for the Altair emulator, these ports are used to integrate communications and cloud services. Terminal input and output ports are routed over WebSockets, other ports are used for timing services, access to weather and pollution data, plus Azure IoT services.
  • Intel 8080 emulator: This is an open-source software implementation of the Intel 8080 CPU. The Intel 8080 emulator executes Intel 8080 applications including the CP/M operating system, compilers, apps, and games.
  • CPU Monitor: The CPU monitor implements the virtual Altair front panel, along with memory disassembler, tracer, and Altair emulator reset.
  • CP/M: CP/M originally stood for Control Program/Monitor. Later, CP/M became known as Control Program for Microcomputers. It was a mass-market operating system created in 1974 for Intel 8080/85-based microcomputers by Gary Kildall of Digital Research, Inc.
  • Programming languages: Included on the main disk image are the Microsoft BASIC interpreter, the BDS C compiler, and the Intel and Microsoft assemblers and linkers.
  • Altair BASIC: By default the Altair emulator boots CP/M, but it is easy to boot the original Altair BASIC program.
  • Altair Web Terminal: Provides a web-browser hosted Altair terminal. The web terminal is built using the Xterm library. Xterm.js provides a web browser-hosted terminal, a WebSocket integrates Xterm with the Altair emulator.
  • Open Weather Map: Open Weather Map provides planet-scale weather and pollution data services. Open Weather Map provides free access to weather and pollution data by geographic location.
  • Azure IoT Central: Azure IoT Central is a customizable cloud-based Internet of Things (IoT) application platform. You can report, analyze, and export IoT data.

Intel 8080 input and output 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.

Example of i8080 IO ports used to integrate peripherals

The image shows an example of Intel 8080 IO port usage

Extended Altair emulator software-enabled ports

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

  • You can access Intel 8080 IO ports from BASIC, C, 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 shows output port numbers and port data values. Typically, calling an output port will load data to be read via an input port.

Utility ports

Port Port data Loads
29 0-255 Set timer period in milliseconds
30 0-255 Set timer period in seconds
33 ASCII CopyX filename
41 0 System tick count
42 0 Current UTC date and time
43 0 Current local date and time
44 0 Generates a random number between -32000 and 32000

Weather ports

Port Port data Loads
34 0 "Celsius" string literal
34 1 "Millibar" string literal
34 2 "Humidity %" string literal
34 3 "Wind km/h" string literal
34 4 "Wind degrees" string literal
34 5 "Observation" string literal
35 0 Temperature (Note 1)
35 1 Pressure (Note 1)
35 2 Relative humidity (Note 1)
35 3 Wind speed (Note 1)
35 4 Wind direction (Note 1)
35 5 Weather observation (Note 1)

Location ports

Port Port data Loads
36 0 "Latitude" string literal
36 1 "Longitude" string literal
36 2 "Longitude" string literal
36 3 "City" string literal
37 0 Latitude (Note 2)
37 1 Longitude (Note 2)
37 2 Country name (Note 2)
37 3 City name (Note 2)

Pollution ports

Port Port data Loads
38 0 "AQI(CAQI)" string literal
38 1 "CO" string literal
38 2 "NO" string literal
38 3 "NO2" string literal
38 4 "O3" string literal
38 5 "SO2" string literal
38 6 "NH3" string literal
38 7 "PM2.5" string literal
38 8 "PM1.0" string literal
39 0 Air quality index (Note 1)
39 1 Carbon monoxide level (Note 1)
39 2 Nitrogen monoxide level (Note 1)
39 3 Nitrogen dioxide level (Note 1)
39 4 Ozone level (Note 1)
39 5 Sulphur dioxide level (Note 1)
39 6 Ammonia level (Note 1)
39 7 Particulate matter 2.5 level (Note 1)
39 8 Particulate matter 1.0 level (Note 1)

Publish to Azure IoT ports

Port Port data Loads
31 ASCII Publish JSON to IoT Hub/Central (Max 256 characters) (Note 3)
32 0 Publish weather and pollution data to IoT Hub/Central (Note 3)

Azure Sphere specific ports

Port Port data Loads
60 1 or 0 Turn Red LED on or off
61 1 or 0 Turn Green LED on or off
62 1 or 0 Turn Blue LED on or off
63 0 Loads onboard temperature
63 1 Loads onboard pressure
63 2 Loads onboard light sensor
64 0 Loads accelerometer X axis
64 1 Loads accelerometer Y axis
64 2 Loads accelerometer Z axis
64 3 Calibrate then start accelerometer
64 4 Stop the accelerometer readings
64 5 One off accelerometer reading

General ports

Port Port data Loads
70 0 Loads Altair emulator version number

Display 8x8 LED panel ports

Port Port data Loads
80 0, 1, 2 0 = Bus mode, 1 = Font mode, 2 = Bitmap mode
81 0, 1, 2 8x8 LED Panel RGB color. 0 = Red, 1 = Green, 2 = Blue
82 0..255 Set 8x8 LED Panel Red palette
83 0..255 Set 8x8 LED Panel Green palette
84 0..255 Set 8x8 LED Panel Blue palette
85 0..255 Display ASCII character

Input ports

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

Port Description
29 Query milliseconds timer status. Enabled or expired (true or false)
30 Query seconds timer status. Enabled or expired (true or false)
31 Query publish json pending status. Enabled or expired (true or false)
32 Query publish weather pending status. Enabled or expired (true or false)
33 CopyX end-of-file (true or false)
200 Read loaded byte stream
201 Read CopyX file stream

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 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

Clone this wiki locally