Intel 8080 Assembler
The following text is an exert from the Assembly language article.
In computer programming, assembly language (or assembler language), sometimes abbreviated asm, is any low-level programming language in which there is a very strong correspondence between the instructions in the language and the architecture's machine code instructions. Assembly language usually has one statement per machine instruction (1:1), but constants, comments, assembler directives, and symbolic labels of, e.g., memory locations, registers, and macros are generally also supported.
Intel 8080 Assembly Language Programming Manual
For more information, refer to:
- Intel 8080 Assembly Language Programming Manual
- CP/M Assembler
- CP/M Dynamic Debugging Tool
- CP/M 2 System Interface
Assemble assembly applications
The CP/M disk image includes two demo assembly applications, DEMO.ASM and SLEEP.ASM. Follow these steps to edit, assemble, and load the demo file:
The DEMO.ASM example
List the DEMO.ASM file
type sleep.asm
ORG 0100H ; CP/M base of TPA (transient program area)
OUT 30
MVI C,09H ; Print string function
LXI D,MESSAGE ; Point
CALL 0005H ; Call bdos
RET ; To cp/m
MESSAGE:DB 0DH,0AH,'Hello, World!',0DH,0AH,'$'
ENDAssemble the DEMO.ASM file:
asm demo
Load and link the assembled code:
load demo
Run the demo application:
demo
Edit a file with Word-Master
in the following steps use the Word-Master text editor to edit a file. It's highly recommended to edit files with Visual Studio Code and then copy the file to the Altair filesystem using the CP/M gf command.
Edit the DEMO.ASM file with Word-Master:
wm demo.asm
Switch the web terminal to character input mode by selecting Ctrl+L.
Edit the demo.asm file. For example, change Hello, World! text to your name.
Save your updates to the demo.asm file:
- Select the Esc key.
- Select E to exit. Your file changes are saved to disk.
Switch the web terminal to line input mode by selecting Ctrl+L.
Then assemble, load, and run the updated demo.asm application.
Sleep assembly example
The SLEEP.ASM example uses Intel 8080 input and output port instructions. The SLEEP.ASM application sets a sleep period of 2 seconds using output port 30, waits on input port 30 for the delay period to expire, and then publishes weather data to Azure IoT Central. For more information about Intel 8080 IO port mappings, refer to Intel 8080 input and output ports.
List the SLEEP.ASM file
type sleep.asm
ORG 0100H ;CP/M base of TPA (transient program area)
MVI C,09H ;Print string function
LXI D,MSG ;Point to waiting message
CALL 0005H ;Call bdos
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: MVI C,09H ;Print string function
LXI D,PUB ;Point to publish message
CALL 0005H ;Call bdos
MVI A,0H ;Move zero to the accumulator
OUT 32 ;Publish to Azure IoT Central
MVI C,09H ;Print string function
LXI D,FINI ;Point to Finished message
CALL 0005H ;Call Bdos
RET
MSG: DB 'Sleeping 2 seconds$'
FINI: DB 0DH,0AH,'Finished$'
PUB: DB 0DH,0AH,'Publishing to Azure IoT Central$'
ENDAssemble the SLEEP.ASM file:
asm sleep
Load and link the assembled code:
load sleep
Run the demo application:
sleep