CorrectTableLookup:
movedp[0], #0800Dh; Point to pointer to function table
moveacc, @dp[0]; acc now has pointer to ftable
add#3; For 2000, GetDP0
movedp[0], acc; Load ptr + offset to dp0
movea[1], @dp[0]; Get address of GetDP0 into A1
movedp[0], #StartOfTable + 08000h
calla[1]; This will call GetDP0, finally!
.
.
.
ret
.
.
.
StartOfTable:
dc1601234h
dc1605678h
dc16098abh
dc160cdefh
SlowTableMove:
movedp[0], #0800Dh; Point to pointer to function table
moveacc, @dp[0]; acc now has pointer to ftable
add#4; For 2000, GetDP0Inc
movedp[0], acc; Load ptr + offset to dp0
movea[1], @dp[0]; Get address of GetDP0 into A1
movedp[0], #StartOfTable + 08000h
movebp, #RAMDest; Set this label to desired dest
moveoffs, #0ffh; Pre-decremented offset
movelc[0], #4; Move four words
TableMoveLoop:
movedp[0], dp[0]; Set source pointer
calla[1]; This will call GetDP0inc
move@bp[++offs], gr; Store retrieved word to dest
djnzlc[0], TableMoveLoop
.
.
.
ret
.
.
.
StartOfTable:
dc1601234h
dc1605678h
dc16098abh
dc160cdefh
FasterTableMove:
movedp[0], #0800Dh; Point to pointer to function table
moveacc, @dp[0]; acc now has pointer to ftable
add#12; For 2000, copyBuffer
movedp[0], acc; Load ptr + offset to dp0
movea[1], @dp[0]; Get address of GetDP0 into A1
movedp[0], #StartOfTable + 08000h
movebp, #RAMDest; Set this label to desired dest
moveoffs, #0; No need to pre-decrement offset
movelc[0], #4; Move four words
calla[1]; This will call copyBuffer
.
.
.
ret
.
.
.
StartOfTable:
dc1601234h
dc1605678h
dc16098abh
dc160cdefh
;
; Output String
;
; Enter with ACC=an index value (one based) indicating which
; string to output.
;
; On exit, LC0=0, DPC=0, ACC, A1, A2, DP0 used.
;
output_string:
movelc[0], acc;Set LC0 to index of string
movedpc, #4;Set DP0 to word mode
movedp[0], #800dh;Point to table of pointers
moveacc, @dp[0];Get address of table
add#3;Offset to GETDP0 routine
movedp[0], acc;Load pointer to table
movea[1], @dp[0]++;Get GETDP0
movea[2], @dp[0];Get GETDP0INC
movedpc, #0;Set DP0 to byte mode
movedp[0], #string_table + 8000h
str_search_loop:
calla[1];Get a string length
djnzlc[0], next_str;If not this string, go to next
movelc[0], gr;Otherwise, put len in LC0
moveacc, @dp[0]++;...and point past length
out_loop:
calla[2];Get a char and bump pointer
callchar_out;Output the character
djnzlc[0], out_loop;If more characters, loop
ret;Otherwise, we're done.
next_str:
moveacc, gr;GR contains len of this string
adddp[0];Add current ptr to current len...
movedp[0], acc;...to create a new pointer
jumpstr_search_loop;Jump back and test index again
;
; Each entry in the string table begins with the string length
; followed by the string characters.
;
string_table:
dc8string1 - string_table
dc8"This is the first string."
string1:
dc8string2 - string1
dc8"This is a second example of a string"
string2:
dc8string3 - string2
dc8"A third string."
string3:
dc8string4 - string3
dc8"Finally, a fourth string in the array!!!"
string4: