Retro Lab · Microcomputer Trainer
The Microcomputer Trainer
Radio Shack's Science Fair Microcomputer Trainer (catalog 28-260, 1985) was a 4-bit computer you programmed one hex digit at a time. It had a 20-key pad, seven binary LEDs, one digit of display and a speaker. This emulator follows the original manual instruction by instruction. Load a sample, or key a program in the way you would on the real board.
Program
Shows whichever hex key you hold down. The smallest useful KA loop.
Write mnemonics like TIA 5, CAL TIMR or JUMP loop; the hex is worked out for you. Labels end with a colon, and comments start with a semicolon.
Registers
Memory
next instruction address pointerRunning a program
- Pick a sample and choose Load into memory, or key one in: Reset, then a digit and Increment for each word.
- Press Reset, then a mode digit, then Run. Mode 1 runs, 2 runs and shows the address on the LEDs, 5 and 6 step one instruction per Increment.
- Reset stops the program. 9 then Run plays the built-in Electronic Organ.
- To look at any address, type two digits and press Address set. Registers live at 66–6F.
Instruction set
Sixteen instructions, one hex digit each, some followed by one or two operand digits. Most of them leave FLAG at 1. JUMP and CAL only act when FLAG is 1, which is how the Trainer makes decisions.
| Code | Mnemonic | Does | FLAG after |
|---|---|---|---|
0 | KA | Key → A | 0 if a key is down, 1 if not |
1 | AO | A → display | 1 |
2 | CH | Swap A↔B and Y↔Z | 1 |
3 | CY | Swap A↔Y | 1 |
4 | AM | A → M[50+Y] | 1 |
5 | MA | M[50+Y] → A | 1 |
6 | M+ | A ← M + A | 1 on carry |
7 | M− | A ← M − A | 1 if A > M |
8 n | TIA n | A ← n | 1 |
9 n | AIA n | A ← A + n | 1 on carry |
A n | TIY n | Y ← n | 1 |
B n | AIY n | Y ← Y + n | 1 on carry |
C n | CIA n | Compare A with n | 1 if not equal |
D n | CIY n | Compare Y with n | 1 if not equal |
E n | CAL n | Call a ROM routine, only if FLAG is 1 | see below |
F h l | JUMP hl | Go to hl, only if FLAG is 1 | 1 |
CAL routines
| Code | Name | Does |
|---|---|---|
E0 | CAL RSTO | Blank the display |
E1 | CAL SETR | Light binary LED number Y |
E2 | CAL RSTR | Turn off LED number Y |
E3 | CAL INPT | Read the external port (not wired here) |
E4 | CAL CMPL | A ← F − A |
E5 | CAL CHNG | Swap A, B, Y, Z with A′, B′, Y′, Z′ |
E6 | CAL SIFT | A ← A ÷ 2; FLAG 1 if A was even |
E7 | CAL ENDS | End sound |
E8 | CAL ERRS | Error sound |
E9 | CAL SHTS | Short beep |
EA | CAL LONS | Long beep |
EB | CAL SUND | Play note A (1–E) |
EC | CAL TIMR | Wait (A + 1) × 0.1 s |
ED | CAL DSPR | LEDs ← 5F (left 3) and 5E (right 4) |
EE | CAL DEM- | Decimal M − A, then Y − 1 |
EF | CAL DEM+ | Decimal M + A, then Y − 1 |
Memory map
Program memory is 00–4F, though code may run on into data memory, 50–5F. AM, MA, M+ and M− use address 50 + Y. The registers are memory too: A at 6F, B 6C, Y 6E, Z 6D, and the spare set A′ 69, B′ 67, Y′ 68, Z′ 66.
Where this emulator guesses
The manual doesn't cover everything, so these behaviors are best guesses:
- Speed is about 1,000 instructions a second, and notes are tuned with La at 440 Hz. Sound lengths were chosen by ear.
- KA leaves A alone when no key is down.
- Past address 5F the program counter wraps to 00, and JUMP targets above 7F wrap into memory.
- A CAL skipped because FLAG was 0 leaves FLAG at 1, the same as a skipped JUMP.
- DEM− adds 1 to the next lower address on a borrow, the same way DEM+ carries.
- SETR and RSTR ignore Y values of 7 and up. CAL INPT does nothing, since there is no external port.
- RUN with no mode digit, or with 0, 3, 4, 7 or 8, runs in mode 1. Address set can reach the registers at 60–7F.
- Reset stops a program at once. On the real board you had to hold it until a ROM sound finished.
- The built-in games other than the Organ are Radio Shack's code and aren't included.