Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Optimizing tricks
2012-03-14 08:52
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
2012-03-14 09:11
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)
2012-03-14 09:16
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 :)
2012-03-14 09:29
Bitbreaker

Registered: Oct 2002
Posts: 508
@yago
Thanks, fixed! made the things about zeropage more clear.
2012-03-14 09:38
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
2012-03-14 11:16
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 -

2012-03-14 14:11
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 -
2012-03-14 20:37
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..
2012-03-14 21:45
Peiselulli

Registered: Oct 2006
Posts: 81
Perhaps too simple, but
	cmp #$80
	ror

for doing a arithmetic shift right.

2012-03-14 21:53
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: Perhaps too simple, but
	cmp #$80
	ror

for doing a arithmetic shift right.



Yay, my favorite! :)
2012-03-15 08:20
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Stone/Prosonix/Offence
Epyx/TSA
cba
Case/Padua
MCM/ONSLAUGHT
Andy/AEG
rikib80
Guests online: 103
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.161 sec.