johncl Posted December 29, 2008 Share Posted December 29, 2008 (edited) I like that version, nice use of LAX, but you gotta be brave and not use the temp LAX word INX AND #$F0 STA word TXA AND #$0F ORA word STA word A late reply to the starting hack of this thread. If you got a free byte of memory space and you could initialise that before the loop this should be faster: At an init stage store the top 4 bits in a variable: lda word and #$f0 sta hi And in your loop when you are iterating and need the wraparound increment on lower 4 bits: ldx word ; 3 inx ; 2 txa ; 2 and #$0f ; 2 ora hi; 3 sta word ; 3 Uses a total of 15 cycles, 4 less than the one quoted assuming word and hi are in zero page. Well, if you can assume that your "word" variable bit 4 is always zero (so counter starts from one of $00,$20,$40,$60,$80,$a0,$c0,$e0) you could do this also: ldx word; 3 inx ; 2 txa ; 2 and #$ef; 2 sta word; 2 Which is only 11 cycles! Edited December 29, 2008 by johncl Quote Link to comment Share on other sites More sharing options...
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.