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


Forums > C64 Coding > Code indenting
2017-09-11 09:40
oziphantom

Registered: Oct 2014
Posts: 161
Code indenting

I've always been a strict
label code comment
kinda guy but of late I've been experimenting with code readability and speed boosts. Indenting does seem to improve things
updateMovement
	ldx Ents.movementPtr
-	lda YXDeltas,x
	cmp #$AA
	bne +
	ldx Ents.movementPtrBase
	stx Ents.movementPtr
	jmp -
+	clc
	adc Ents.y
	sta Ents.y
	inx	
	lda YXDeltas,x
	beq _endAdd
	bmi _sub
	clc
	adc Ents.x
	sta Ents.x
	bcc _endAdd
	inc Ents.xMSB
	jmp _endAdd
_sub
	clc
	adc Ents.x
	sta Ents.x
	lda Ents.xMSB
	adc #$ff
	sta Ents.xMSB
_endAdd
	inx
	stx Ents.movementPtr
	rts
vs
updateMovement
	ldx Ents.movementPtr
-	lda YXDeltas,x
	cmp #$AA
	bne +
	    ldx Ents.movementPtrBase
	    stx Ents.movementPtr
	jmp -
+	clc
	adc Ents.y
	sta Ents.y
	inx	
	lda YXDeltas,x
	beq _endAdd
	    bmi _sub
                clc
                adc Ents.x
                sta Ents.x
                bcc _endAdd
                    inc Ents.xMSB
                    jmp _endAdd
       _sub
            clc
            adc Ents.x
            sta Ents.x
            lda Ents.xMSB
            adc #$ff
            sta Ents.xMSB
_endAdd
	inx
	stx Ents.movementPtr
	rts
this kind of falls apart when you get the to the leap frog code. I.e something like
bmi C
beq B
A
A
A
bne C
A
A
jmp D
B
B
B
B
beq D
C
C
C
C
D
D
D
So I was wondering if anybody else had tumbled down this rabbit hole or had other things to do to help?
 
... 13 posts hidden. Click here to view all posts....
 
2017-09-11 14:06
dano

Registered: Jul 2004
Posts: 112
What Cruzer said.
2017-09-11 14:18
Groepaz

Registered: Dec 2001
Posts: 8275
not a single label named "shit". unreadable.
2017-09-11 14:46
Mr. SID

Registered: Jan 2003
Posts: 337
You lost me at the + and - labels... :)
2017-09-11 15:16
Oswald

Registered: Apr 2002
Posts: 4126
I still hate all that branching going on, why not just 16 bit math?

bmi case:

+3 cycle bmi -2 cycle at adc # = +1 cycle slower than adc abs,x

bpl case:

not taken branch:2
not taken bcc: 2
inc 5
jmp 4

13 cycles = +1 cycle slower than lda adc sta (Each 4)


only 1 case its faster.

instead of #$aa it could be a dec counter bmi.
2017-09-11 18:28
Perplex

Registered: Feb 2009
Posts: 197
Quoting Cruzer
The only time it makes sense to indent asm code is if it's in curly brackets, e.g. because of an if-statement or for-loop.


This.
2017-09-12 02:17
Skate

Registered: Jul 2003
Posts: 469
C64 has no tab key for a reason. :)
2017-09-12 02:51
Groepaz

Registered: Dec 2001
Posts: 8275
and TASS already auto-idents the way god intended!
2017-09-12 09:32
oziphantom

Registered: Oct 2014
Posts: 161
Quoting Perplex
Quoting Cruzer
The only time it makes sense to indent asm code is if it's in curly brackets, e.g. because of an if-statement or for-loop.


This.


Python, Ruby et al ?
2017-09-12 09:44
oziphantom

Registered: Oct 2014
Posts: 161
Quoting Skate
C64 has no tab key for a reason. :)


And the C128 does for a reason ;) The Kernal even has Tab Stops build in.
2017-09-15 21:37
Skate

Registered: Jul 2003
Posts: 469
Quote: Quoting Skate
C64 has no tab key for a reason. :)


And the C128 does for a reason ;) The Kernal even has Tab Stops build in.


We are free to use indenting for our C128 projects then, good to know.

I have a C128 but it will take a few more decades until i need that much memory and speed. ;)
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
CreaMD/React
Acidchild/Padua
pcollins/Excess
Squad333
Guests online: 43
Top Demos
1 Uncensored  (9.7)
2 Edge of Disgrace  (9.7)
3 Coma Light 13  (9.6)
4 The Shores of Reflec..  (9.6)
5 Lunatico  (9.6)
6 Comaland 100%  (9.5)
7 Incoherent Nightmare  (9.5)
8 Wonderland XII  (9.5)
9 Comaland  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 Pandemoniac Part 2 o..  (9.6)
2 FMX Music Demo  (9.6)
3 Daah, Those Acid Pil..  (9.5)
4 Dawnfall V1.1  (9.5)
5 Synthesis  (9.5)
6 Dawnfall  (9.4)
7 Treu Love [reu]  (9.4)
8 Field Sort  (9.4)
9 KAOS 64  (9.3)
10 One-Der  (9.2)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.3)
4 Crest  (9.3)
5 The Judges  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Mitch  (9.8)
3 Mr Zero Page  (9.8)
4 Snacky  (9.8)
5 MWS  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2017
Page generated in: 1.595 sec.