The 16F54 2 character font

There is insufficient space available in the 16F54 for a full 3 character month font, even if we 'substitute' 1 for l and 0 for O. However, a 2 character month can still be understood and requires only 16 characters be defined:- Ja, Fe, Mr, Ap, My, Jn, Jy, Ag, Sp, Oc, No, De a A c D e F g J M n N o O r S y = 16 char maps (112 Table entries) Adding the 10 numeric maps, we need a total look-up-table of 26x7 = 182 (leaving 74 to do the look-ups, plus an extra 7 if we use 0 for O)) Using 'all caps', we can further reduce the count :- JA, FE, MR, AP, MA, JN, JY, AG, SE, OC, NO, DE A C D E F G J M N O R S Y = 13 char maps (91 Table entries) Looking up the bit maps To go from the Month number to a Month character string 'codes' requires another table, however so long as we keep the charter 'count' to 16 (or less) this requires only 12 entries (since looking up the month number returns 2 characters in a single byte at 4 bits per character). Note that, the shape pixels required are those for the 'current' scan line. To avoid a 'multiply' during shape look-up, the Table is held in 'scan line' order. This means that the 'scan line' register will hold the look-up-table base address (rather than a simple 0-6 count) - at the end of each scan line we 'add' the offset to the next table base to the current 'scan line' (base address) register (rather than just 'incrementing' it) We will need to 'detect' the end of the 'insert' sequence. The 'easy' way to do this is to reorganise the tables so the 'top' scan line is held at the highest location and thus uses the 'top' offset. As each scan line os output, we SUBtract an offset from the ScanLine register. After outputting 6 lines, on the 7th the ScanLine register will reach zero and on the '8th' it will underflow allowing us to use CY to detect the 'end of the insertion' sequence Of course this means the shapes are split into 7 look-up-tables, one for each scan line (i.e. 'top lines for all chars', then '2nd lines for all' and so on, rather than 'char0 all lines', 'char1 all lines') To do the shape look-up, we load the character code to the Acc and CALL the look-up-table. This adds the ScanLine (offset to table base address) to the Acc and then adds the result to PCL, so a jump is performed into the look-up-table (where a RET with shape pixels in Acc is performed). getMchar: ; Call here to look up a shape for the current scan line and return the bit map in m10s / m1s registers ; NOTE, this routime loads the first char into m10s, but the main line code has to perform a 'COPY Acc,m1s' ; (to save the second char pixels) ; Mreg = a date count register, holding the month number as a binary value (0-11) ; ScanLineBase is the base address offset into the table for the current scan line ; ; start by getting the char code for the current month CALL getMcode ;get 2 number value for month characters COPY Acc,m1s ;use m1s as a temp reg AND 0x0F,Acc ; mask off hi bits (= second char) CALL getMpixels ; get map for this char COPY Acc,m10s ; save the map ; now do the second char NIBswap m1s,Acc ; get the hi value into the lo bits AND 0x0F,Acc ; mask off hi bits JUMP getMpixels ; exit via the table look-up ; NOTE, on return, the main line code has to perform a 'COPY Acc,m1s' to save the pixels ; getMcode; ; LUT to get code for current Month ; note the codes are held 'backwards' because the 'low nibble' will be processed first Copy Mreg,Acc ; ADD Acc,PCL ; RET 'aJ' RET 'eF' RET 'rM' RET 'pA' RET 'yM' RET 'nJ' RET 'yJ' RET 'gA' RET 'pS' RET 'cO' RET 'oN' RET 'eD' ; ; getMpixels: ; LUT containing the character pixel maps in scanline order ADD ScanLineBase,Acc ;add the scan line (table base) ADD Acc,PLC ; jump into pixel table RET (top scan line, char a ) RET (top scan line, char b (or whatever)) ... RET (2nd scan line, char a ) .. RET (last scan line, char a ) Total low address instructions required :- getMchar = 8 getMcode = 14 getMpixels = 2 + (16 x 7) = 114 Total 136 The numeric look up will be about 90, so we have (256 - 136 - 90) = only 30 'spare' locations The 0-O substitution By combining the character and numeric bit-map Tables, and overlapping the end of character with start of the numeric table it should be possible to save at least 8 low space locations (we save 7 from not needing to store 'O', and another 2 for not having a separate Table, but it 'costs' at least one instruction to 'offset' the numeric look-up into the combined Table)