Branch offset out of range.... wait a minute where????

Discussion in 'Discussion and Q&A Archive' started by Animemaster, May 10, 2009.

Thread Status:
Not open for further replies.
  1. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    I have been finishing off(or trying to) the knuckles code and was porting the climbing part of the code. But i got like 4 or 5 branch offsets out of range but...... its not in the code as far as i can see. My only guess is that i'm pushing so much branchs out of range that i got this. But i'm not sure, i could be looking for ever trying to figure out what the branchs are that are being pushed out place. I changed some things from S to W, and even to jsr, but to no avail. So.... here is the error



    Code:
    SNASM68K, version 2.1D, Dec 06 1995, 11:55:16, DOS4G PRO
    
    (c) 1993-95 Cross Products Ltd. All Rights Reserved
    
    s1comb.asm(20100) : Error 06052 : Branch offset (-33522) out of range at address 0
    
    s1comb.asm(20124) : Error 06052 : Branch offset (-33452) out of range at address 0
    
    s1comb.asm(20272) : Error 06052 : Branch offset (-33052) out of range at address 0
    
    s1comb.asm(20359) : Error 06052 : Branch offset (-32818) out of range at address 0
    
    
    
    4 errors encountered processing file 's1comb.asm'
    
    42417 source statements in 53591 lines processed in 0.4 seconds


    And here is the code:

    Code:
    ; ---------------------------------------------------------------------------
    
    Knuckles_Climbing_Wall:			&#59; ...
    
    		tst.b	($FFFFF7AD).w
    
    		bmi.w	loc_315BAE
    
    		move.w	8(a0),d0
    
    		cmp.w	$A(a0),d0
    
    		bne.w	loc_315BAE
    
    		btst	#3,$22(a0)
    
    		bne.w	loc_315BAE
    
    		move.w	#0,$14(a0)
    
    		move.w	#0,$10(a0)
    
    		move.w	#0,$12(a0)
    
    		move.l	#$FFFFD600,($FFFFF796).w
    
    		cmp.b	#$D,$3F(a0)
    
    		beq.s	loc_3159F0
    
    		move.l	#$FFFFD900,($FFFFF796).w
    
    
    
    loc_3159F0:				&#59; ...
    
    		move.b	$3F(a0),d5
    
    		move.b	#$A,$16(a0)
    
    		move.b	#$A,$17(a0)
    
    		moveq	#0,d1
    
    		btst	#0,($FFFFF602).w
    
    		beq.w	loc_315A76
    
    		move.w	$C(a0),d2
    
    		sub.w	#$B,d2
    
    		
    
    		cmp.w	#4,d1
    
    		bge.w	Knuckles_ClimbUp&#59; Climb onto the floor above you
    
    		tst.w	d1
    
    		bne.w	loc_315B30
    
    		move.b	$3F(a0),d5
    
    		move.w	$C(a0),d2
    
    		subq.w	#8,d2
    
    		move.w	8(a0),d3
    
    			&#59; Doesn't exist in S2
    
    		tst.w	d1
    
    		bpl.s	loc_315A46
    
    		sub.w	d1,$C(a0)
    
    		moveq	#1,d1
    
    		bra.w	loc_315B04
    
    ; ---------------------------------------------------------------------------
    
    
    
    loc_315A46:				&#59; ...
    
    		subq.w	#1,$C(a0)
    
    		tst.b	($FFFFFE19).w
    
    		beq.s	loc_315A54
    
    		subq.w	#1,$C(a0)
    
    
    
    loc_315A54:				&#59; ...
    
    		moveq	#1,d1
    
    		move.w	($FFFFEECC).w,d0
    
    		cmp.w	#-$100,d0
    
    		beq.w	loc_315B04
    
    		add.w	#$10,d0
    
    		cmp.w	$C(a0),d0
    
    		ble.w	loc_315B04
    
    		move.w	d0,$C(a0)
    
    		bra.w	loc_315B04
    
    ; ---------------------------------------------------------------------------
    
    
    
    loc_315A76:				&#59; ...
    
    		btst	#1,($FFFFF602).w
    
    		beq.w	loc_315B04
    
    		cmp.b	#$BD,$1A(a0)
    
    		bne.s	loc_315AA2
    
    		move.b	#$B7,$1A(a0)
    
    		addq.w	#3,$C(a0)
    
    		subq.w	#3,8(a0)
    
    		btst	#0,$22(a0)
    
    		beq.s	loc_315AA2
    
    		addq.w	#6,8(a0)
    
    
    
    loc_315AA2:				&#59; ...
    
    		move.w	$C(a0),d2
    
    		add.w	#$B,d2
    
    		
    
    		tst.w	d1
    
    		bne.w	loc_315BAE
    
    		move.b	$3E(a0),d5
    
    		move.w	$C(a0),d2
    
    		add.w	#9,d2
    
    		move.w	8(a0),d3
    
    		
    
    		tst.w	d1
    
    		bpl.s	loc_315AF4
    
    		add.w	d1,$C(a0)
    
    		move.b	($FFFFF768).w,$26(a0)
    
    		move.w	#0,$14(a0)
    
    		move.w	#0,$10(a0)
    
    		move.w	#0,$12(a0)
    
    		bsr.w	Knuckles_ResetOnFloor_Part2
    
    		move.b	#5,$1C(a0)
    
    		rts
    
    ; ---------------------------------------------------------------------------
    
    
    
    loc_315AF4:				&#59; ...
    
    		addq.w	#1,$C(a0)
    
    		tst.b	($FFFFFE19).w
    
    		beq.s	loc_315B02
    
    		addq.w	#1,$C(a0)
    
    
    
    loc_315B02:				&#59; ...
    
    		moveq	#-1,d1
    
    
    
    loc_315B04:				&#59; ...
    
    		tst.w	d1
    
    		beq.s	loc_315B30
    
    		subq.b	#1,$1F(a0)
    
    		bpl.s	loc_315B30
    
    		move.b	#3,$1F(a0)
    
    		add.b	$1A(a0),d1
    
    		cmp.b	#$B7,d1
    
    		bcc.s	loc_315B22
    
    		move.b	#$BC,d1
    
    
    
    loc_315B22:				&#59; ...
    
    		cmp.b	#$BC,d1
    
    		bls.s	loc_315B2C
    
    		move.b	#$B7,d1
    
    
    
    loc_315B2C:				&#59; ...
    
    		move.b	d1,$1A(a0)
    
    
    
    loc_315B30:				&#59; ...
    
    		move.b	#$20,$1E(a0)
    
    		move.b	#0,$1B(a0)
    
    		move.b	#$13,$16(a0)
    
    		move.b	#9,$17(a0)
    
    		move.w	($FFFFF602).w,d0
    
    		and.w	#$70,d0
    
    		beq.s	return_315B94
    
    		move.w	#$FC80,$12(a0)
    
    		move.w	#$400,$10(a0)
    
    		bchg	#0,$22(a0)
    
    		bne.s	loc_315B6A
    
    		neg.w	$10(a0)
    
    
    
    loc_315B6A:				&#59; ...
    
    		bset	#1,$22(a0)
    
    		move.b	#1,$3C(a0)
    
    		move.b	#$E,$16(a0)
    
    		move.b	#7,$17(a0)
    
    		move.b	#2,$1C(a0)
    
    		bset	#2,$22(a0)
    
    		move.b	#0,$21(a0)
    
    
    
    return_315B94:				&#59; ...
    
    		rts
    
    ; End of function Knuckles_GlideControl
    
    
    
    Knuckles_ClimbUp:			&#59; ...
    
    		move.b	#5,$21(a0)	&#59; Climb up to	the floor above	you
    
    		cmp.b	#$BD,$1A(a0)
    
    		beq.s	return_315BAC
    
    		move.b	#0,$1F(a0)
    
    		
    
    
    
    return_315BAC:				&#59; ...
    
    		rts
    
    ; ---------------------------------------------------------------------------
    
    
    
    loc_315BAE:				&#59; ...
    
    		move.b	#2,$21(a0)
    
    		move.w	#$2121,$1C(a0)
    
    		move.b	#$4A,$1A(a0)
    
    		move.b	#7,$1E(a0)
    
    		move.b	#1,$1B(a0)
    
    		move.b	#$13,$16(a0)
    
    		move.b	#9,$17(a0)
    
    		rts

    Man i've had so much problems with this code so many times, its frustrating! I just want to get this port over with.... so if any one can help me please!!!!
     
    Last edited by a moderator: May 10, 2009
  2. Thorn

    Thorn wroar Member

    Joined:
    Aug 11, 2007
    Messages:
    70
    ^ If you could provide a few line numbers, it might help more, since the errors don't give any more detail than that.


    Also -- and I'm probably stating the obvious here, but you never know -- make sure you're looking in s1comb.asm to see what line numbers the errors are on and then finding the same code in your main file, not just looking in s1.asm or sonic1.asm or whatever you're calling the file you do your work in. Other than that, all I can say is to use jmp and jsr like you say you're doing, since all of those offsets are past the distance a word can support. Without more detail I don't think much more can be said. ;)


    (now watch somebody prove that last statement wrong)
     
  3. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Well one i don't know what you mean by line numbers, elaborate please. And i know that the branchs with in the code, are in the range. As in they are branching to something not far soit only needs a beq.s, or neq.w ect. Thats why i think i'm pushing something else with in the sonic object code. Plus you say look in s1comb but how does that help me at all? its the same as sonic1.asm and i can't see what the lines are thats out of range. I mean thats what i'm trying to find out. And for detail? i don't know what more to say, this happens when i port the climbing code in, and when i remove the branches from knuckles begin_climb, one of the errors is removed. And note thats when they are all removed thats why i'm confused.
     
  4. Selbi

    Selbi The Euphonic Mess Member

    Joined:
    Jul 20, 2008
    Messages:
    2,429
    Location:
    Northern Germany
    Italic stuff are the line numbers. Look in your ASM and find these lines. Then, fix them. This should be the problem.
     
    Last edited by a moderator: May 10, 2009
  5. Thorn

    Thorn wroar Member

    Joined:
    Aug 11, 2007
    Messages:
    70
    Line numbers --> what line in the file is in question. What selbi said about that.


    Secondly, no, the two files are NOT the same all of the time. That's not to say they can't be -- I haven't touched Sonic 1 in a long time -- but it's possible that the two files are offset by a bit. View the problem there, then check the lines in your original file.


    The numbers given as high 32,000-odd and 33,000-odd suggest to me that they're just barely out of range, actually.
     
  6. Animemaster

    Animemaster Lets get to work! Member

    Joined:
    Mar 20, 2009
    Messages:
    1,229
    Location:
    UK
    Thanks thorn but selbi already elaborated on this. So one point to you and 2 for selbi.
     
Thread Status:
Not open for further replies.