The "PDP8 8/e 8/f 8/m Pocket Reference Card" lists some single-instruction constant idioms.
These are "one word wonders" that load the AC with a given value:
CLA CLL / loads 0000 (0 decimal)
CLA CLL IAC / loads 0001 (1 decimal)
CLA CLL IAC RAL / loads 0002 (2 decimal)
CLA CLL CML RTL / loads 0002 (2 decimal)
CLA CLL CML IAC RAL / loads 0003 (3 decimal)
CLA CLL IAC RTL / loads 0004 (4 decimal)
CLA CLL CML IAC RTL / loads 0006 (6 decimal)
CLA IAC BSW / loads 0100 (64 decimal)
CLA CLL CML RTR / loads 2000 (1024 decimal)
CLA CLL CMA RAR / loads 3777 (2047 decimal)
CLA CLL CML RAR / loads 4000 (-2048 decimal. See Note 1, below)
CLA CLL CMA RTR / loads 5777 (-1025 decimal)
CLA CLL CML IAC RTL / loads 6000 (-1024 decimal)
CLA CLL CMA RTL / loads 7775 (-3 decimal)
CLA CLL CMA RAL / loads 7776 (-2 decimal)
CLA CLL CMA / loads 7777 (-1 decimal)
If you consider the fact that the accumulator and link are cleared before these constants are loaded, it's really equivalent to a CLA CLL followed
by a TAD instruction, which makes the argument for two or three word variations as still being code and data space efficient (i.e., you'd need
the CLA CLL, the TAD, and the actual data value, thus consuming three words to load an arbitrary constant with the accumulator
and link in an arbitrary state initially.)
Note 1: The pocket reference card lists the constant 4000 as "-0 decimal", but if you add it to 2048 you end up with zero, so
it really behaves more like -2048. YMMV :-)
|
Traditional C language programmers will recognize the setjmp() and longjmp() functions in PDP-8 assembler:
SETJMP,
0 / return area
JMP I SETJMP / return
LONGJMP,
0 / unused return area
JMP I SETJMP / return to previously established address
I first encountered this while doing some disassembly and couldn't understand why the code kept calling a subroutine that always just
immediately returned. The longjmp() part of the equation was buried in another subroutine call somewhere else, so I
didn't make the connection right away.
|