-
Posts
4 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Gallery
Events
Store
Community Map
Posts posted by c3po
-
-
19 hours ago, SvOlli said:
I was faced with the problem of doing "R minus A", remembering of something I learned at school called "2s complement", I came up with this:
EOR #$FF SEC ADC RI like it.
You can still do a normal "A minus R" then complement it
SEC SBC R EOR #$FF CLC ADC #01simplified to:
CLC SBC R EOR #$FFwhich is useful if the carry is known to be cleared already.
-
2
-
-
Well, for the sake of hacks, I think in any long program it's a useful commodity to have a table like this:
NumTab ; values 0-255 byte 0, 1, 2, 3, 4, 5, 6, 7 byte 8, 9, 10, 11, 12, 13, 14, 15 ... byte 248, 249, 250, 251, 252, 253, 254, 255
This allows some interesting "new instructions":AND NumTab,X ; A AND X ORA NumTab,X ; A OR X EOR NumTab,X ; A XOR X CMP NumTab,X ; CMP A with X CLC ADC NumTab,X ; A + X SEC SBC NumTab,X ; A - X LDY NumTab,X ; TXY LDX NumTab,Y ; TYX-
2
-
-
In (timely) response to the initial post...
lda work ; or ldy work clc ; iny adc #1 ; tya eor work and #$0f eor work sta workand if you want any subset of contiguous bits you can do like that:
lda work clc adc #4 ; value of the lsb of the increment group eor work and #%00011100 ; 3 bits (2...4) eor work sta workthis will cycle bits 2...4
-
1
-

6502 Killer hacks
in Atari 2600 Programming
Posted
If you need to do a modulo operation where the divisor is a power of two, you can use AND: M mod N = M AND (N-1).
; M mod 8 (8 is a power of 2...)
LDA M
AND #7 ; 8-1