[Return to Main Page]

Print Immediate (PRIMM) from Commodore 128 KERNAL ROM
[Up to Source Code Repository]


Print Immediate (PRIMM)

This clever routine lets you inline data to be printed in your assembly code like this:

To use it, insert your text to be printed immediately after the call to PRIMM, terminated by a null byte. When the routine is finished the program counter will be pointing the instruction immediately following the text, in this case RTS. The program is presented here in three different versions, all fully tested and functionally equivalent. Each version requires two bytes in the zero-page, any two consecutive bytes will do. Change the call to CHAROUT to your character printing subroutine, the byte to be printed will be loaded into the accumulator prior to the call.

The version below was obtained from disassembling the Commodore 128 KERNAL ROM. It can also be found in a few other Commodore computers such as the Plus/4 and 16 but is surprisingly absent in the VIC-20 and C64.

Lee Davison was not impressed with the efficiency of the above routine so he condensed it into this version. This alternate version was provided by Ross Archer. Mike Barry provided another version. This one requires 65C02 opcodes but is shorter and preserves the Y register.

Last page update: May 7, 2019.