6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Mon May 13, 2024 4:14 am

All times are UTC




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Mon Nov 21, 2022 11:50 am 
Offline
User avatar

Joined: Tue Aug 11, 2020 3:45 am
Posts: 311
Location: A magnetic field
Bithacks are surprisingly rare on 6502. Branchless, constant time operations are very useful on a deterministic processor. However, bithacks typically require more clock cycles than ballasted branches. This makes algorithms particularly tedious because it is another constraint in addition to balancing stacks. On 6507, illegal instructions are common and some of these can be used productively to counter the even/odd count of branches. It is also possible to jump into the end of an instruction. Therefore, one byte, two byte and three byte sequences may have very different semantics. This may be combined with address aliasing. Indeed, illegal instructions, instruction aliasing and address aliasing can all be used simultaneously.

_________________
Modules | Processors | Boards | Boxes | Beep, Beep! I'm a sheep!


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 25, 2022 12:34 pm 
Offline

Joined: Thu Jun 17, 2021 7:53 am
Posts: 34
Code:
    (lda <some value>)
    beq zero         ; 2/3 cycles
    lda #255         ; 2 cycles
zero
    beq +            ; 2/3 cycles
+

I think this should work. If you load A with a value first and this code lives in a single page then you can test the Z flag with a constant 6 cycles.

More generally (not depending on the value being in A) e.g. For the N flag, 7 cycles:
Code:
    bpl non_negative
    lda #255
non_negative
    bmi +
    lda #0
+


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: