Jump to content
Sign in to follow this  
RSS Bot

EricBall's Tech Projects - self-modifying code HELP!

Recommended Posts

My Propeller video driver is almost done, but I've run into a snag. The following is a snippet from the pixel byte to long lookup routine.

 

CODE SHR sprgfx1, #8 ' shift byte into position

MOV sprbyte, sprgfx1

AND sprbyte, #$0FF wz

MOVS :byte6, sprbyte ' update source pointer

MOVD :byte6, sprdata ' update destination pointer

ADD sprdata, #1

:byte6 IF_NZ MOV sprdata, sprbyte ' copy color lookup table entry to lineRAM

SHR sprgfx1, #8 wz

MOVS :byte7, sprgfx1

MOVD :byte7, sprdata

:byte7 IF_NZ MOV sprdata, sprbyte ' won't work due to pipeline

DJNZ count2, #:nxtspr ' decrement active sprite counter

JMP #doblank ' max number of active sprites reached

:nxtspr ADD sprptr, #4

DJNZ count1, #:loop ' 48+16+223 = 287 (288) max cycles / sprite

doblank

What's going on here is some self-modifying code 'cause the Propeller doesn't have any indirect addressing. My problem is the propeller is moderately pipelined, so the next instruction is fetched before the current instruction has been executed. So :byte7 MOV won't reflect the MOVD as it currently stands. For all of the other cases I've been able to slip the ADD instruction back before the MOV, but I don't have that option for :byte7. I could just put a NOP in there, but that adds 4 cycles to the loop, which effectively adds 16 cycles due to external memory timing. (ick!) Other options:

 

1. Slide back the DJNZ. But then I need to copy :byte7 so it gets executed before the JMP. That's 3 opcodes (again due to the pipeline) and I'd like to only add max 2 for other reasons.

2. Roll up the byte to long translation. Code space efficient, but more cycles.

 

Any other suggestions?

 

 

(The wz / IF_NZ are to make color 0 transparent. The condition codes are under application code and every instruction may be optionally executed. So wz sets/clears the Zero condition code and IF_NZ executes the MOV only if the Zero condition code is cleared, i.r. the value of sprbyte is non-zero.)

 

 

http://www.atariage.com/forums/index.php?a...;showentry=3390

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...