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 > Branch too far in 64TASS
2008-08-13 17:17
Higgie

Registered: Apr 2002
Posts: 127
Branch too far in 64TASS

hiho!

what does 'Branch too far' mean?

the readme of 64tass says: 'can't relative branch that far'

i understand that sentence but what is the limit then?
and how to deal with the limitation?

sorry for coming up with stupid stuff already known to most of the decent coders here.... ;)

thanx in advance!
2008-08-13 17:20
Scout

Registered: Dec 2002
Posts: 1570
If you jump using branches (beq, bne, bcc...) you can only jump 128 bytes back and forth.
You can solve this using a combination of branches and jmps.

You can also this in the 64tass manual:
Quote:

To avoid branch too long errors the assembler also supports long branches, it can automatically convert conditional relative branches to it's opposite and a JMP. This have to be enabled on the command line using the "--long-branch" option.
	bcc veryfar	;compiled as "bcc veryfar" or
			;	bcs sk
			;	jmp veryfar
			;sk

2008-08-13 17:39
Higgie

Registered: Apr 2002
Posts: 127
wow! thanx, scout!

i see, there are a lot of small things to keep in mind when coding assembler.

it's too easy to forget about such things if you have done java for some years. ;)

so if i understand this properly i can switch on that commandline option and my branches will get converted. sounds easy! :)
2008-08-13 17:43
Scout

Registered: Dec 2002
Posts: 1570
Quote:

so if i understand this properly i can switch on that commandline option and my branches will get converted. sounds easy! :)


Yup! :-)
Keep in mind it's not the most elegant way especially when you're optimizing (speed)code.
Besides that, you're losing control over the compiled code. That could be a pain when debugging.
2008-08-13 17:55
Radiant

Registered: Sep 2004
Posts: 639
What Scout says. Under normal circumstances (demo or game coding) you wouldn't want the compiler to automatically generate long branches for you.
2008-08-13 18:24
Higgie

Registered: Apr 2002
Posts: 127
well, i don't see it being 'normal circumstances' when i'm coding assembler. ;)

'premature optimization is the root of all evil' (Donald E. Knuth) ... i know!

but as long as the assembler gives me a warning i think it's ok. so i can come back to that branch later to rework my code, if necessary. atm i'm quite happy that i don't have to deal with all those little obstacles myself. your help and the little help from 64tass are well appreciated. :)

i will keep in mind that there could occur some implicit behaviour depending on the assembler options i use.
2008-08-13 19:17
JackAsser

Registered: Jun 2002
Posts: 2014
@higgie: just do it manually. :D I mean, if the compiler complains, simply invert your branch and add a jmp. It's really not that hard.

F.e.

beq farAwayThatComplains

Invert it and make it branch past the jmp:

bne *+3
jmp farAwayThatComplains ; won't complain anymore

Simple as that!


2008-08-13 21:03
Cruzer

Registered: Dec 2001
Posts: 1048
Agree with Scout et al, this long branch feature sounds risky. Any coder will learn how to make long branches as one of the first things. At least it should be a pseudo command, e.g. "lbcc".
2008-08-13 22:14
Frantic

Registered: Mar 2003
Posts: 1648
If I was writing an assembler, I would also go for "lbcc" and pseudo-ops like that, to keep the distinction clear.
2008-08-13 23:48
Higgie

Registered: Apr 2002
Posts: 127
@jackasser: you see me convinced. :)
@cruzer: yeah! such a pseudo command would definitly be superior over any configuration based behaviour.
2008-08-14 05:35
Scout

Registered: Dec 2002
Posts: 1570
I guess you can make, using Cruzers example, a macro for it in 64tass:

lbeq .macro
bne *+3
jmp \1
.endm

Something like that.
 
... 3 posts hidden. Click here to view all posts....
 
Previous - 1 | 2 - 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
t0m3000/hf^boom!^ibx
Brataccas/HF
Peacemaker/CENSOR/Hi..
Andy/AEG
kbs/Pht/Lxt
rexbeng
Chesser/Blazon
Courage
CA$H/TRiAD
lA-sTYLe/Quantum
marley
Technotron/I-I F
Fungus/Nostalgia
WVL/Xenon
Matt
ged/Samar
Guests online: 136
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 Censor Design  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

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