Woha! Lots of responses here.. wonderful!
My explanation was probably poor. The registers point to a memory location with the register content being the address. So the basic "instruction" of
MAB $AA, $BB
would be (with X=0):
LDA ($AA,X)
STA ($BB,X)
which is two bytes shorter than 6502 code. And in the basic 6502 you have an address range of 16 bits. With the 6509 that would be 20 bits, or with some other clever banking you can have as many bits as you like...
MAB $AA $00 $ADD $SUB in 6502 terms would be (with X=0):
LDA ($AA,X)
ADC ($ADD,X)
SBC ($SUB,X)
STA ($AA,X)
which is 4 bytes shorter than 6502 code..
An interpreter may look something like (for a short program):
Code:
LDY #0
loop:
LDX $program,Y
INY
LDA $program,Y
BEQ zero2
CPX #0
BEQ zero1
STA $00 // save second register
LDA ($00,X) // move data from address in first register
LDX $00
STA ($00,X) // move data to address in second register
INY
JMP loop
zero1: // first byte is zero
TAX
INY
LDA $program,Y
STA ($00,X) // save LSB into register
INY
INX
LDA $program,Y
STA ($00,X) // save MSB into register
INY
JMP loop
zero2: // second byte is zero
CPX #0
BEQ zero3
LDA ($00,X)
INY
ADC $program,Y
INY
SBC $program,Y
CMP ($00,X)
BNE noclear
LDA $program,Y // store value if both ADD and SUB are zero
noclear:
STA ($00,X)
INY
JMP loop
zero3: // both bytes zero means a branch
LDA $00
BEQ nobranch // branch if last register load was not zero
INY
LDA $program,Y // Y is PC so modify that
TAY // Ok, I limited it to 256 bytes of code here, but just for simplicity
nobranch:
JMP loop
program:
data $01, $02, $03, $04, and so on....
I think the point of this was to see if one could make code that would be more condensed than basic 6502 assembly, in 6502 assembly. It is certainly not easy and neither obvious how to do it. It may also be hard with respect to what rules to use and were to apply them. The interpreter would bloat it if it is too complicated, and a small program would neither help.
The Huffman coding and URISC was interesting read.... it will certainly keep me exited and thinking through the holidays.
Thanks!
Edit: I just saw BigEd's response. The Z-machine (or other high-level languages) reuse more complicated code in order to condense that is being done. I was thinking more towards basic assembly rather than complicated instructions, but I do see the parallel there.