This is sort of redundant by now but..
welcome DonnaD
You're still not quite giving enough information
I'll assume that that bytes for individual characters
are in ascending order in the table.
ie location 521 is the first byte of "A" 522 is the
second 523 the third etc.
(a quibble here, I'd start counting with 0 and put
the first byte of "A" at 520)
Also assuming that the character codes correspond
to table locations so that they can be used as
indexes to the corrresponding block in the table
(ie that's how I interpret what you've said)
Let me apologize in advance if I'm being needlessly
verbose or pedantic (I'm guessing it will be useful
or you wouldn't be asking the question in the first
place)
Also for doing goofy things like counting from
0 instead of 1 and including instructions in the
code that really aren't needed
I guess the straight forward way would be to form
a base address for the character data in the table
by multipying the character code by 8 and adding
the value of the start of the table to that to get
the start of the block for that character, then count
through the individual bytes with Y register
The Y register is used with the indirect indexing
mode of addressing, which is precisely for this
sort of situation.
You supply a zero page location, the cpu retrieves
the two bytes of a 16 bit address from it,
lo byte first, ie the zp location you specify in
the instruction contains the lo byte and the next
location contains the high byte, it then adds the
the value in the Y register to that 16 bit value
and uses the result as the address for the data
So, conceptually, you'd mutiply your character by 8
add the base address of the table to that put it
in a zeropage location and point your indirect
addressed instuction at that, manipulating the
Y register to get the individual bytes
I say conceptually 'cause (I think) that's the
straight forward way to think of it, but for
practical reasons you'd do it in a slightly different
order, multply by 8 as you store it to zero page then
add the base-of-the-table address.
Since you want a 16 bit address and the cpu only deals
with 8 bits of data at a time (the address is data
while you're multiplying and adding) you need temporary
storage for the piece of the address you're not working on
at the moment.
Might as well be your zero page pointer location and you
can do some of it in place (shifting, specifically) with
out moving stuff in and out of the accumulator.
You multiply by 8 by shifting.
we're working in binary so shifting one bit position
has the effect of multiplying or dividing by 2
three shifts to the left to multiply by 8
Code:
; Assuming the character code is in the accumulator
; And we've chosen a start address for the table
; that's a mutiple of 256 so that the lo byte is 0
; so we only have to add the hi byte.
; pointerhi and pointerlo are the zp locations
; of the pointer
; tblebaseaddresslo and tablebaseaddresshi
; are the lo byte and the hi byte of the address
; of first entry of the character data table
ldy #$00 ; clear the hi byte of the zp pointer
sty pointerhi ; we'll deal with the zp lo byte later
; for now it's, in the accumulator
asl ; acc x 2, the lo byte of the offset
rol pointerhi ;now the hi byte x 2 and shift the previous
; hi bit of the lo byte into the lo bit
; of the hi byte of the pointer
asl ; do it again to get character x 2 x 2
rol pointerhi
asl ; again for character x 2 x 2 x 2 = character x 8
rol pointerhi
; we've got our character offset now we can add our table base
; address to it, the lo byte of the offset is still in the accumulator
;clc "normally" we'd insert a clc here
; in preparation for addition, but
; we should have just rol'd a 0 into
; the C flag so it's already cleared
;adc tblbaseaddresslo assuming we chose a starting address
; for the table such that the lo byte of
; the table address is 0 we can skip adding
; the lo byte, adding 0 wouldn't change it
; so we may not need this instruction
sta pointerlo ; move it from the acc to the lo byte of the zp pointer
lda pointerhi ; get the hi byte of the pointer
adc tblbaseaddresshi ; and add the hi byte of the table base address
sta pointerhi ; put the result back in tho the pointer
; the zp pointer should now contain the address of the start of
; data for the individual character
;ldy #$00 here we'd "normally" intialze Y.
; the first byte is the zeroth byte,
; I start my counting at 0 not 1
; but we don't actually need this instruction
; here, Y should still be zero
loop
lda (pointerlo),y ; here's your indirect indexed adressing
sta lcd
iny
cpy #$08 ; the last byte of character data is the 7th,
bne loop ; did we just pass it? if not go back and
; get another byte of character data
Garth Wilson left out a rol but you did specify a 2k table
with 8 bytes for each entry, 256 characters, so I left it in.
That's (I think) the straight forward way
but there's lots of room to fiddle with details
particularly if you're willing to reorder your table
You could treat the character code in the accumulator as the hi byte and
shift it right in to the lo byte (it may or may not save you anything
it's just another posibility to consider)
You could put the character data in reverse order and so that the first
is in the 7th location, second in the 6th location, etc so that you decrement
the Y register and quit when it reaches 0 (the decrement instruction sets
the Z flag) that could save you doing the cpy #$08 in the loop (but it
might not save you anything over all)
You could split the tabel in to individual character byte positions
ie a table of all of the first character bytes, another table of all the second
bytes another of all the third etc
and index them directly with the character code and save the mutiplying and adding
Code:
tya
lda table1,y
sta lcd
lda table2,y
sta lcd
.
.