View Single Post
Old 25th May 2021, 6:09 pm   #11
Michael Haardt
Triode
 
Join Date: May 2021
Location: Titz, Germany.
Posts: 17
Default Re: New SC/MP II system

I am currently working on a boot ROM, which involves copying program images larger than 4 KB from the boot ROM to RAM. At that point I can use RAM for variables, if I have to, but it makes everything easier if I don't need RAM variables. My naive attempt at memory copy with 16 bit pointers is slow as hell. p1 is the source, p2 the destination and p3 the length:

copyloop1:
ld (p1) ; copy from source to destination
st (p2)

ccl ; 16 bit increment of p1
xpal p1
adi 1
xpal p1
xpah p1
adi 0
xpah p1

ccl ; 16 bit increment of p2
xpal p2
adi 1
xpal p2
xpah p2
adi 0
xpah p2

scl ; 16 bit decrement of p3
xpal p3
cai 1
xpal p3
xpah p3
cai 0
xpah p3

xpal p3 ; jump if p3 is not zero
xae
lde
xpal p3
lde
jnz copyloop1
xpah p3
xae
lde
xpah p3
lde
jnz copyloop1

Apart from unrolling the loop, what else could I do? Pointers are best stored in pointer registers, I guess. ild only does 12 bit arithmetic and does not set carry. The length could benefit from being stored in a variable addressed through p3. It's still clumsy and I guess someone figured out way better code for memcpy(). Suggestions are welcome!

Michael
Michael Haardt is offline   Reply With Quote