Data output using Extended Instructions (PIC 18Fx)
The 18Fx extended instruction set supports a 'Call via Acc' (1 word, 2 CLK's) instruction, which used with a classic RETurn with Acc=data LUT speeds up output
To output character shapes at maximum speed, the code is :-
Location 0xnn00: ; start of LUT for scan line N, 96 words, one per shape byte
POP ; ascii code 0 = end of lookup sequence, so this location is the exit point (and drops through)
RET shape for ascii code 1 (0x01) scanLine N
RET shape for ascii code 2 (0x02) scanLine N
...
RET shape for ascii code1 95 (0x5F) scanLine N
; end of table, start of control code
;
; main-line code calls here with Acc=0 to output the scanline
LineNout:
ROTL RegN, Acc ; get the ascii code (byte) as a word offset (1)
CALL Acc ; 2 CLK's to arrive at table, 2 CLK's to return with value, total (4)
COPY Acc,PORTx ; output the value (1)
; and repeat for next register N
....
Total 6 CLK's , including 'early exit', when RegN is 0 and Call Acc lands on start of table which then POP's the in-line return and drops through to a main-line code return.
However this is 'in-line' code and costs 3 instruction words per byte output. Since it all has to fit within a 128 word page, the max output 'run' is (128-96)/3 = 10 !!
Of course, reducing the character FONT table then allows a 'deeper' stack (so there should be no problems accommodating a Video Time Inserter (VTI), even one using 3 character Months)
The same as loop gets us :-
LineNout:
ROTL INDR, Acc ; get the ascii code (byte) as a word offset (1)
CALL Acc ; 2 CLK's to arrive at table, 2 CLK's to return with value, total (4)
INC FSR ;Inc the INDR pointer (1) - note this is done here so the CLR PORT timing after RETurn to main-line is correct after the POP delay
COPY Acc,PORTx ; output the LUT value (1)
BRA LineNout: ; and back to loop (2)
Total 9 CLK's.