18-bit SRAM
The Eval board has 1 Mw of 16-bit SRAM. That makes it awkward to store 18-bit instructions. This code packs and unpacks 18-bit data into 16-bit memory. It is surprisingly easy to do. Words are left-justified in a and right-justified in T, then T is right-shifted into a by +*.
Block 1158 is loaded into node 108, next to node 008 which is the SRAM controller.
9/8
Converts a count of 18-bit words to a count of 16-bit words. Multiples by 9/8.
- Send the read/write command to 008
- Add 1 to the ether 0-based count to get true count
- Add 1/8 to that
- Subtract 1 back to 0-based count
- Send to 008
- Send address to 008
- Divide original count, which must be a multiple of 8 (-1), by 8
rd
Reads from memory 9 16-bit words and sends 8 18-bit ones.
- Read first word
- Loop 8 times
- Shift word left 2 bits
- Read next word, storing first in a. Low-order bits are 0
- Get loop index and or with 7. This counts up from 0
- Save on return for 2nd unext
- Use unext to shift T and a right. The +* instruction won't add register S to T
- Send 18-bit a
- Shift T back left, clearing low-order bits
+read
Analogous to +read in code for 008. Takes count and address and returns 18-bit words.
- Pops ether focus into register b as where data should go
- 5617: Tell 008 to read count and call address 17
- 9/8 returns 0-based count /8. This is the number of 9-word packs to process
wr
Receives 8 18-bit words and writes 9 16-bit ones to memory. The inverse of rd.
- Set T and S to zero
- Loop 8 times:
- Save left-justified copy of previous word in a
- Get next word and copy both S (0) and it
- Retrieve loop index
- Shift T and a right. +* may add S to T, but S is 0
- Retrieve left-justified a, right-justify and write (sign bits ignored)
- Write last word
+write
Analogous to +write in code for 008. Takes count and address and writes 18-bit words.
- Pops ether focus into register b as to where data comes from
- 5625: Tell 008 to read count and call address 25
- 9/8 returns count of packs
init
Sets a and awaits instruction with 4-port read.