Inexperience? I've dug through loads of 6502 code and it still surprises me what sort of inefficiencies people use. One bit of code I saw used repeated instances of:
Code:
LDX #cmd AND 255:LDY #cmd DIV 256:JSR oscli
...
.cmd:EQUS "FX 225,1":EQUB 13
instead of:
Code:
LDA #255:LDX #1:LDY #0:JSR osbyte
It even still gets me. For years I've used this sort of code to increment a BCD value:
Code:
LDA num:AND #15 :\ Do a BCD inc. with &09->&10
CMP #9:LDA #1 :\ &x0-&x8 - add 1
BCC AddBCD:LDA #6 :\ &x9 - add 6+1
.AddBCD
ADC num:STA num :\ num=num+1 or +7
I only realised a few months ago, after 30 years, that I could just do:
Code:
SED :\ set decimal mode
CLC :\ clear carry for add
ADC #1 :\ +1 gives x9 to y0
CLD :\ exit decimal mode
Edit: sorry, can't get the formatting to work. [Edited 4/1/13 by moderator to make it work, by unchecking the "Disable BBCode" box]