SlowTableMove:
move dp[0], #0800Dh ; Point to pointer to function table
move acc, @dp[0] ; acc now has pointer to ftable
add #4 ; For 2000, GetDP0Inc
move dp[0], acc ; Load ptr + offset to dp0
move a[1], @dp[0] ; Get address of GetDP0 into A1
move dp[0], #StartOfTable + 08000h
move bp, #RAMDest ; Set this label to desired dest
move offs, #0ffh ; Pre-decremented offset
move lc[0], #4 ; Move four words
TableMoveLoop:
move dp[0], dp[0] ; Set source pointer
call a[1] ; This will call GetDP0inc
move @bp[++offs], gr ; Store retrieved word to dest
djnz lc[0], TableMoveLoop
.
.
.
ret
.
.
.
StartOfTable:
dc16 01234h
dc16 05678h
dc16 098abh
dc16 0cdefh
FasterTableMove:
move dp[0], #0800Dh ; Point to pointer to function table
move acc, @dp[0] ; acc now has pointer to ftable
add #12 ; For 2000, copyBuffer
move dp[0], acc ; Load ptr + offset to dp0
move a[1], @dp[0] ; Get address of GetDP0 into A1
move dp[0], #StartOfTable + 08000h
move bp, #RAMDest ; Set this label to desired dest
move offs, #0 ; No need to pre-decrement offset
move lc[0], #4 ; Move four words
call a[1] ; This will call copyBuffer
.
.
.
ret
.
.
.
StartOfTable:
dc16 01234h
dc16 05678h
dc16 098abh
dc16 0cdefh
;
; 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:
move lc[0], acc ;Set LC0 to index of string
move dpc, #4 ;Set DP0 to word mode
move dp[0], #800dh ;Point to table of pointers
move acc, @dp[0] ;Get address of table
add #3 ;Offset to GETDP0 routine
move dp[0], acc ;Load pointer to table
move a[1], @dp[0]++ ;Get GETDP0
move a[2], @dp[0] ;Get GETDP0INC
move dpc, #0 ;Set DP0 to byte mode
move dp[0], #string_table + 8000h
str_search_loop:
call a[1] ;Get a string length
djnz lc[0], next_str ;If not this string, go to next
move lc[0], gr ;Otherwise, put len in LC0
move acc, @dp[0]++ ;...and point past length
out_loop:
call a[2] ;Get a char and bump pointer
call char_out ;Output the character
djnz lc[0], out_loop ;If more characters, loop
ret ;Otherwise, we're done.
next_str:
move acc, gr ;GR contains len of this string
add dp[0] ;Add current ptr to current len...
move dp[0], acc ;...to create a new pointer
jump str_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:
dc8 string1 - string_table
dc8 "This is the first string."
string1:
dc8 string2 - string1
dc8 "This is a second example of a string"
string2:
dc8 string3 - string2
dc8 "A third string."
string3:
dc8 string4 - string3
dc8 "Finally, a fourth string in the array!!!"
string4: