| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
Optimizing tricks
Hi folks,
I put together a few optimizing tricks for 6502, including a section about illegal opcodes. Anything else i could mention there? Especially the illegal opcode section could need some more examples and opcodes discussed i guess? Any mistakes?
http://www.codebase64.org/doku.php?id=base:advanced_optimizing
Bitbreaker |
|
| |
yago
Registered: May 2002 Posts: 333 |
Very nice and big :-)
I dont understand the part in Zeropage about X/Y.. (why TXA, you can STX everywhere)
Clobbering Registers has offset wrong (should be +1, not +2)
|
| |
andym00
Registered: Jun 2009 Posts: 45 |
A little thing I started using a lot recently for 16bit negates..
lax #$00
sbx #lo
sbc #hi
Comes in very handy at times if it's what you need.. Although that need is probably very small :) |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
@yago
Thanks, fixed! made the things about zeropage more clear. |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
@andym00
Hmm, that can also be used to negate two 8-bit values at a time, though sbx value is immediate, what would mean extra overhead of setting the value by code manipulation:
stx .val1+1
lax #$00
.val1 sbx #$00
sec
sbc .val2
|
| |
LHS
Registered: Dec 2002 Posts: 66 |
Good work!
one tip for the DCP opcode:
x1
.byte $7
x2
.byte $1a
-
;an effect
dec x2
lda x2
cmp x1
bne -
can be written as
-
;an effect
lda x1
dcp x2
bne -
|
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
Added the new examples, thanks for that!
the dcp could then also be used like:
-
...some code
lda #end
dcp counter
bne -
instead of
-
...some code
dec counter
lda counter
cmp #end (of course silly if this would be #$00)
bne -
|
| |
Testa Account closed
Registered: Oct 2004 Posts: 197 |
thanks for sharing at codebase... i learned a few new tricks!, always interesting how creative you can be with legal and illigal opcodes..
|
| |
Peiselulli
Registered: Oct 2006 Posts: 81 |
Perhaps too simple, but
cmp #$80
ror
for doing a arithmetic shift right.
|
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: Perhaps too simple, but
cmp #$80
ror
for doing a arithmetic shift right.
Yay, my favorite! :) |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
i added the arithemtic shift right to the maths section some time ago ;-) can also be combined with the illegal opcode anc instead of cmp to force carry to be always clear afterwards. |
... 15 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 - Next |