Overview
This week we will write and run our first programs on the MITS Altair Simulator, learning to program it with machine code.
Thursday, September 10th
Let's load the number 7 into address 0030H:
| STEP | SWITCHES 0-15 | CONTROL SWITCH |
|---|---|---|
| 1 | 0 000 000 000 110 000 | EXAMINE |
| 2 | 0 000 000 000 000 111 | DEPOSIT |
Now load a program to load 0030H into register B, increment it 4 times, and write it out to address 0031H:
| STEP | MNEMONIC | BIT PATTERN | HEX |
|---|---|---|---|
| 3 | 0 000 000 000 000 000 | EXAMINE | |
| 4 | LDA | 00 111 010 | 3A |
| 5 | (address) | 00 110 000 | 30 |
| 6 | (address) | 00 000 000 | 00 |
| 7 | MOV (A→B) | 01 000 111 | 47 |
| 8 | INR B | 00 000 100 | 04 |
| 9 | INR B | 00 000 100 | 04 |
| 10 | INR B | 00 000 100 | 04 |
| 11 | INR B | 00 000 100 | 04 |
| 12 | MOV (B→A) | 01 111 000 | 78 |
| 13 | STA | 00 110 010 | 32 |
| 14 | (address) | 00 110 001 | 31 |
| 15 | (address) | 00 000 000 | 00 |
| 16 | HLT | 01 110 110 | 76 |
Today in class we will present the programs we wrote last class. Chris and Nathan will go last, since they will be introducing the looping and branching instructions they used in their program.
After that we will form new pairs to work on the following project:
Write a program that reads in a starting memory address,The pairs are:m, and a number of bytes,n, and computes the sum of thenbytes beginning at addressm.
- Pair B: Dimitri and Delaine
- Pair C: Mason and Dimitri
- Pair D: Waleed and Stephan
- Pair A: Giselle and Chris
Tuesday, September 8th
Grades are in Synergy for the first assignment: A: 5, C: 1, E: 1. We'll talk briefly at the beginning of class about how to interpret these results.
Today we will work together in pairs to write new programs for our Altair 8800 that we will present at the beginning of class on Thursday.
The pairs are:
- Pair A: Giselle and Stephan
- Pair B: Dimitri and Waleed
- Pair C: Nathan and Chris
- Pair D: Mason and Delanie
Pair A will introduce us to two's complement by substracting two numbers. Pair B will sum four positive numbers. Pair C will find the index of the largest positive integer in a sequence of ten positive integers. Group D will write bytes with values 1-5 to sequential positions in memory (using increment operators, don't just write the immediate values).
Come to class on Thursday ready to present your programs.
What You Will Produce
Prepare a presentation with each of the following:
- A listing of your program like the one below based on the program we entered last class, containing a table with columns for STEP, MNEMONIC, BIT PATTERN and HEX.
- A link to the entry in Appendix A: Alair 8800 Instruction Set and/or our own textbook reference for any new instructions you used in your program that were not in the first demo program (each of the assigned tasks will require at least one new instruction).
- A detailed, step-by-step explaination of how your program works.
You'll have both all class period today and your homework time to work on this project. Have fun!
Process
We are going to perform a modified version of the adding two numbers program presented in Part 3: Operation of the Altair 8800 - B: Loading a Sample Program. This is the program we entered in class last week.
Our modification was to move the to input and output variables to a place in
memory where they can be more easily seen in the Debug window of
our simulator, which shows a view of the computer's memory. We can read the
results of our computuation directly there. To make this more visually
appealing, the two addends were placed at addresses 0x30 and
0x40 respectively, and the sum was placed below them on the
display at address 0x50.
You should make this same consideration when writing your programs this week.
Here is the program ran:
| STEP | MNEMONIC | BIT PATTERN | HEX |
|---|---|---|---|
| 1 | LDA | 00 111 010 | 3A |
| 2 | (address) | 00 110 000 | 30 |
| 3 | (address) | 00 000 000 | 00 |
| 4 | MOV (A→B) | 01 000 111 | 47 |
| 5 | LDA | 00 111 010 | 3A |
| 6 | (address) | 01 000 000 | 40 |
| 7 | (address) | 00 000 000 | 00 |
| 8 | ADD (B+A) | 10 000 000 | 80 |
| 9 | STA | 00 110 010 | 32 |
| 10 | (address) | 01 010 000 | 50 |
| 11 | (address) | 00 000 000 | 00 |
| 12 | JMP | 11 000 011 | C3 |
| 13 | (address) | 00 000 000 | 00 |
| 14 | (address) | 00 000 000 | 00 |
Here are the step-by-step instructions. First load the program:
| STEP | SWITCHES 0-7 | CONTROL SWITCH |
|---|---|---|
| 0 | RESET | |
| 1 | 00 111 010 | DEPOSIT |
| 2 | 00 110 000 | DEPOSIT NEXT |
| 3 | 00 000 000 | DEPOSIT NEXT |
| 4 | 01 000 111 | DEPOSIT NEXT |
| 5 | 00 111 010 | DEPOSIT NEXT |
| 6 | 01 000 000 | DEPOSIT NEXT |
| 7 | 00 000 000 | DEPOSIT NEXT |
| 8 | 10 000 000 | DEPOSIT NEXT |
| 9 | 00 110 010 | DEPOSIT NEXT |
| 10 | 01 010 000 | DEPOSIT NEXT |
| 11 | 00 000 000 | DEPOSIT NEXT |
| 12 | 11 000 011 | DEPOSIT NEXT |
| 13 | 00 000 000 | DEPOSIT NEXT |
| 14 | 00 000 000 | DEPOSIT NEXT |
Now load the data to add 19 and 23 together and run the program:
| STEP | SWITCHES 0-15 | CONTROL SWITCH |
|---|---|---|
| 15 | 0 000 000 000 110 000 | EXAMINE |
| 16 | 0 000 000 000 010 011 | DEPOSIT |
| 17 | 0 000 000 001 000 000 | EXAMINE |
| 18 | 0 000 000 000 010 111 | DEPOSIT |
| 19 | RESET | |
| 20 | RUN |
You will know everything worked as intended if you see 0x2A (42)
at address 0x50.
Use this as a model for your own program presentations on Thursday.