All right, so here's my disassembly and analysis of two different paper tape booloaders. The first is
one I find in every place instructions are given for loading from tape. The second is from the
instructions in the Altairduino documentation.
1 MVI A,03h ; Load 3 into A register
2 OUT 10h ; and send that to port 10h.
3 MVI A,15h ; load 15h into A
4 OUT 10h ; and send that.
5 LXI H,0FAEh ; Load 0FAEh into the memory pointer.
; (M is H and L combined as a 16 bit value)
6 LXI SP,001Ah ; Set the stack pointer to 1Ah. That's the DCX B instruction below.
7 IN 10h ; Read from the same port... again
8 RRC ; Rotate right (moves all bits right 1 position, aka divide by 2)
9 RNC ; If even number, goes back up to line 6.
10 IN 11h ; read from port 11h... not sure what 11 is yet.
11 CMP L ; Checks the just-read data against the L register (AEh)
12 RZ ; Go to line 6 if values match.
13 DCR L ; Reduces memory counter by 1.
15 MOV M,A ; Sets memory address 0FADh with what we read from port 11h.
15 RNZ ; Jumps to line 6 and repeat until memory counter is 0F00h.
16 PCHL ; Sets the program counter with the value in HL (0F00h by now)
17 0Bh 00h ; this memory place holds the value 0B00h, or 000B as a 16-bit number
So as far as I can tell without watching this in operation, the program attempts to read
from ports 10h and 11h to pull data from the tape. The DCR L statement implies that the
data is loaded in reverse order - from top to bottom. This will start at memory location
0FAEh and read down to 0F00h.
Finally, the PCHL statement jumps to address 0F00h and executes the program loaded from tape.
There are a couple things I don't get yet. The IN, followed by RRC and RNC are interesting.
This basically reads from the port, then checks to see if the value read is an even number (or 0).
If the value is even, then it reads from port 11 and saves it.
The other thing going on is the Compare in line 10. The tape file appears to have AE bytes
at the beginning, so this skips the repeating "AE" values, then reads "AE" actual bytes, then
jumps to that program in order to finish loading the actual program.
And here's the paper tape loader from the altairduino documentation:
1 LXI H,0FAEh ; Set the starting location to 0FAEh. Same as the first loader
2 LXI SP,0012h ; Set the stack pointer to 12h (line 2)
3 IN 00h ; Read from port 0
4 RRC ; Rotate right one
5 RC ; Jumps to location 12h if the data we just read
; is 0 (or another even value)
6 IN 01h ; Read from port 1
7 CMP L ; Compared what we just read to L (AEh)
8 RZ ; If they match, jump to line 2
9 DCR L ; Count down in our memory pointer
10 MOV M,A ; Store the read data in memory
12 RNZ ; Jumps to line 2 if L is not zero
13 PCHL ; Jump to 0F00h (L must be zero to get here)
14 03h 00h ; Address 3, the opcode starting in line 2.
Again, we see the program reading from two different ports (00 and 01 in this case), the
Decrement L - the bottom half of the memory pointer, and jumping to the
final value of M, which will be 0F00h.
So my guess is that if you want to load paper tapes from an external reader, you'll need
to modify the address in line 3 and line 6 to match the ports you're using. Since
I haven't figured out what the port numbers are for the serial port yet, I'll have to
come back with that info in a future message.