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 > Code indenting
2017-09-11 07:40
oziphantom

Registered: Oct 2014
Posts: 478
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 09:29
Trash

Registered: Jan 2002
Posts: 122
I would do this and skip indenting for the different cases:
bmi C ; Why case C
beq B ; Why case B
;------------
; Case A, <explanation>
;------------
A
A
A
bne C ; Why case C
A
A
jmp D ; Why case D
;------------
; Case B, <explanation>
;------------
B
B
B
B
beq D ; Why case D
;------------
; Case C, <explanation>
;------------
C
C
C
C
;------------
; Case D, <explanation>
;------------
D
D
D
2017-09-11 11:34
Cruzer

Registered: Dec 2001
Posts: 1048
Looks retarded to me. I would just add some newlines to split the code into logical blocks. 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.
2017-09-11 12:06
Dano

Registered: Jul 2004
Posts: 226
What Cruzer said.
2017-09-11 12:18
chatGPZ

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

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

Registered: Apr 2002
Posts: 5007
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 16:28
Perplex

Registered: Feb 2009
Posts: 254
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 00:17
Skate

Registered: Jul 2003
Posts: 490
C64 has no tab key for a reason. :)
2017-09-12 00:51
chatGPZ

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

Registered: Oct 2014
Posts: 478
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 ?
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
sebalozlepsi
Zoid
Krill/Plush
AMB/Level 64
Kojote/Speckdrumm
Hero/ILLUSION
iAN CooG/HVSC
DeMOSic/HF^MS^BCC^LSD
Guests online: 293
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 Wonderland XIV  (9.6)
10 Bromance  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 S!R  (9.9)
3 Mr Zero Page  (9.8)
4 Antitrack  (9.8)
5 OTD  (9.8)

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