Meet the Altair · Choosing a reply
A different
reply.
So far, the computer has sent back exactly what it received. Now let the program make a choice: reply to lowercase a with uppercase A, and leave every other character alone.
Begin here: Lowercase a is prepared below. Send it, then step four instructions to receive it. The register A holds 97, and the text display is still empty. The next instruction asks whether this is the character we want to change.
Loaded reply program · reference card All addresses and bytes here are hexadecimal
| Address | Reference | RAM | Check |
|---|
0100–0101: DB 00 reads readiness into A.
0102–0103: FE 00 compares A with zero.
0104–0106: CA 00 01 jumps to 0100 if Z = 1.
0107–0108: DB 01 receives the waiting byte into A.
0109–010A: FE 61 compares A with lowercase a.
010B–010D: C2 10 01 jumps to 0110 if Z = 0.
010E–010F: 3E 41 puts uppercase A into A.
0110–0111: D3 01 sends A to the text display.
0112–0114: C3 00 01 jumps to 0100.
Checking readiness leaves pending input alone. This lesson checks all twenty-one program bytes before executing. RAM is zero outside the program.
This teaching terminal adds a comparison, a conditional jump, and a replacement instruction to the polling program. Start again restores the program, empties both devices and the text display, clears counts and history, prepares lowercase a, and stops at PC 0100. It is not the hardware RESET switch or a model of a particular historical terminal.
Ask about the byte you received.
The first four instructions are familiar: check readiness, compare with zero, decide whether to keep waiting, then receive a byte. The new work begins at 0109, after that byte reaches the register A.
Lowercase a is 97 decimal, or 61 hex. Uppercase A is a different byte: 65 decimal, or 41 hex. The register is also named A; it can hold either value.
CPI 61H compares the received byte with 97. As in our earlier comparison lesson, it sets the zero flag Z when the values match and clears Z when they differ. It leaves the value in A unchanged.
Skip the change, or make it.
The next instruction is JNZ 0110H: jump if Z is zero. A byte that differs from lowercase a takes this jump straight to OUT. Its value in A stays unchanged.
For lowercase a, Z is 1, so the jump is not taken. Execution continues to MVI A,41H at 010E. This instruction copies the following byte, 65, into A. “Immediate” means the value is part of the instruction itself.
There is no output yet. MVI changes A from 97 to 65, while preserving the flags and RAM. The next instruction, OUT 01H, finally sends 65 to the display, where it appears as uppercase A.
| Received | After comparison | JNZ | Reply |
|---|---|---|---|
| a · 97 | Z = 1 | Continue through MVI | A · 65 |
| b · 98 | Z = 0 | Skip MVI | b · 98 |
Look inside the last instruction shows the actual fetched bytes and transfers. Recent instructions lets you compare the two paths after they finish.
Each answer belongs to a particular question.
This program uses Z for two comparisons. At 0102, the question is “is the input device empty?” At 0109, it is “does the received byte equal 97?” The second comparison replaces the first answer.
After the reply, the program returns to checking readiness. A may then hold 0 or 1, and Z describes that new comparison. The output text remains. Use the captured instruction history to inspect the earlier decision.
Test the rule with unfamiliar input.
Try A, z, a digit, punctuation, a space, and line feed. Then try a again. Only lowercase a should change; this program does not convert all lowercase letters to uppercase.
For a longer experiment, RUN and send the characters of “a cat” one at a time, waiting for room in the device. Predict the whole reply before reading the explanation.
Show an explanation
The reply is “A cAt”. Both lowercase a bytes become uppercase A, while the space, c, and t pass through unchanged. Repeated output bytes still produce repeated characters.
The input and display are the same teaching devices as before. The difference is in the program bytes loaded into RAM. The CPU compares numbers and follows instructions; the display still only presents the bytes sent by OUT.
STOP keeps the current decision, pending input, and output intact. Start this lesson again clears the experiment and prepares lowercase a. As before, the text display keeps the latest 256 output bytes. The reference card shows the complete fixed program; changing a program byte pauses execution until it is restored.