The Questionable Level Design Contest ends in…
Views: 913,915,957
18 users online: AppleBoy54321, chickaDEE Magazine, Green Jerry, HLXY, isaix, le4che,  MarioFanGamer, miguel, MiracleWater, mmBeefStew,  Nameless, NINTENLUIGI, palaceswitcher0, spooonsss, StackDino, TruffledToad, Vic Rattlehead, Yukiika - Guests: 85 - Bots: 69 Users: 51,188 (2,246 active)
Latest: Yukiika
Tip: Use Kipernal's Blockreator if you want to code custom blocks but you have little to no experience with ASM.
Not logged in.
Branch out of bounds
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Branch out of bounds
Pages: « 1 » Link
I got these errors when trying to insert an UberASM code that I wrote :

  Text.asm:34: error: (E5037): Relative branch out of bounds. (Distance is 154). [BEQ skip]
  Text.asm:38: error: (E5037): Relative branch out of bounds. (Distance is 148). [BEQ skip]
  Text.asm:46: error: (E5037): Relative branch out of bounds. (Distance is 129). [BNE skip]

So it seems that the destination of the branch that I'm trying to make is too far away. What should I do to fix this, while still having the conditional branch?
There's a few ways you can solve this:
- Repurpose some of the code that's between those instructions and the skip label so there's less space between them. For example, moving some of the code to a subroutine.
- Invert those branches: for example, "BEQ skip" will become
	BNE +
	JMP skip

- Add an "intermediate" label, let's say "skip2", that just jumps to "skip", and letting the branches go there instead. This works assuming you manage to place it in between the branches and the skip label, and it shouldn't break the flow of the code (for example, put it after a RTS,RTL,BRA or JMP).
If the branch destination ends up to short, you have to combine it with a JMP which can jump anywhere in the same bank. So instead of writing code as "if X then skip", you write "if !X then code else skip".

Rest in peace, Near.
Thanks guys!! No errors now.

YY-CHR > Photoshop
Pages: « 1 » Link
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Branch out of bounds

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2021 - SMW Central
Legal Information - Privacy Policy - Link To Us


Follow Us On

  • YouTube
  • Twitch
  • Twitter


  • Super Mario Bros. X Community
  • Mario Fan Games Galaxy
  • sm64romhacks