Jump to content
IGNORED

Forcing a 4 cycle branch


Mikes360

Recommended Posts

Hi Guys,

 

I have a situation where forcing a 4 cycle branch without actually crossing a page boundary would really help me out with my main drawing kernel.

 

I know you can do a sta.w to force that extra cycle is there an equivalent for the branch opcodes?

 

Thanks,

Mike

Link to comment
Share on other sites

Don't think so. Failed branch = 2 cycles, taken = 3, taken with page crossing = 4.

There's illegal opcodes that do NOP that takes >2 cycles.

There's the trick of branching into the operand of a BIT <abs> instruction that can give variable delay.

 

You might try and squeeze the extra cycle in elsewhere but it can be tricky given it's a conditional thing.

Link to comment
Share on other sites

  • 1 month later...

If you are only branching over one or two bytes, using a superfluous opcode could work.

 

Example:

 

   LDX $80
   BNE  Non_Zero
   .byte $2C
Non_Zero:
   LDX $90

 

Assuming the destination "Non_Zero" isn't crossing a page, that example burns 9 cycles whether or not the branch is taken. Byte $2C is read as BIT $abs (using 4 cycles, misinterpreting LDX $90 as it's 2-byte argument). If you need to preserve status flags, you can use a triple-NOP opcode ($0C).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...