GOPHERSPACE.DE - P H O X Y
gophering on sdf.org
On the PDP-10:
  A page is 512 words, numbered from 000 to 777 octal.
  A word is 36 bits, numbered 0 to 35, left to right.  (Bit 0 is the sign
    bit, bit 35 is the least significant bit)
  The page is 512 * 36 = 18432 bits = 4608 nybbles = 2304 octets.

OUTPAG: MOVE T1,[POINT 4,IBUF] ; Read data 4 bits at a time
MOVEM T1,IPTR
MOVE T1,[POINT 8,OBUF] ; Write data 8 bits at a time
MOVEM T1,OPTR
MOVEI T3,^D<512*36/8> ; Number of octets per page
OUTPG1: ILDB T1,IPTR ; Even numbered nybble
ILDB T2,IPTR ; Odd numbered nybble
LSH T1,4 ; First one is more significant
OR T1,T2 ; Combine to make 8 bits
IDPB T1,OPTR ; Store it in output buffer
SOJG T3,OUTPG1 ; Do all 2304 bytes
POPJ P,

IPTR: BLOCK 1
OPTR: BLOCK 1
IBUF: BLOCK ^O<1000> ; 1 page = 1000 (octal) words
OBUF: BLOCK ^D<512*36/8>/4 : 2304 bytes @ 4 per word = 576 words

You will need to reverse this process if you are creating 36-bit data on a
32-bit machine to be sent via FTP.

Each pair of 36-bit words is 72 bits = 9 bytes.
  byte0 = bits 00-07 of even word
  byte1 = bits 08-15 of even word
  byte2 = bits 16-23 of even word
  byte3 = bits 24-31 of even word
  byte4 = bits 32-35 of even word << 4 || bits 00-03 of odd word
  byte5 = bits 04-11 of odd word
  byte6 = bits 12-19 of odd word
  byte7 = bits 20-27 of odd word
  byte8 = bits 28-35 of odd word