[FE7] ASM-- Changing BL Location? (Talk Conversation) [Answered!]

I’m new to this, and have read through the Ultimate Tutorial ASM guide and searched this site seemingly without finding the answer to my problem, so bear with me a little if this is basic and I just did not understand.

I’m playing around with A-support-dependent “Talk” conversations. The one between Hector and Lyn in 29x/31x is triggered based on an ASM function; seen here in FEBuilder’s disassembler.

I copied these bytes:

00 B5 02 20 2D 21 AC F7 03 FD 00 06 00 16 02 BC 08 47
pasted them in free space (0xD00010), and changed the first “02” to “01” to test creating a conversation between Eliwood and Lyn. I got the events all set up etc, pointed to the right location for the function. It didn’t work (Eliwood froze upon riding up to Lyn), and when I checked the new function in FEBuilder’s disassembler I saw:

Everything is the same except the offset after the BL on the fourth line. Doing the math, this offset is about the same distance from the new function location as the offset in the original from the original location, so I assume it’s defined relatively. However, I just don’t know how to make it so that the new function is looking at the right offset. I’m not sure what bytes correspond to that, or if I’d have to make something entirely new for it to work.

Does anyone have insight? Thank you.

BL has a range of +/- 4 MB, which is far less than the distance between the beginning of the rom and free space. You’ve run into the issue of longcalling, which you can read about more here and here.
Here’s how i would do it:

push {r14}
mov r0,#0x1
mov r1,#0x2D
ldr r2,=#0x8026C08
mov r14,r2
.short 0xF800
lsl r0,#0x18
asr r0,#0x18
pop {r1}
bx r1

.ltorg

(This is for a .asm file, I don’t know how you would assemble in FEBuilder.)

BL jumps to relative address.
Therefore, even if you simply copy it will not work.

As Teq says, please use absolute addressed jump.

Get an assembler such as DevkitPro.

When calling from FEBuilderGBA, set it to Path 2.

Once this setting is made,
You can use ASM.

Choose Top Menu “Open” menu → “Insert ASM”,
or.
On the disassembler screen, select “Import from file”.

If you want to add a routine to 0xD00010.
First, after displaying 0xD00010, select Import Form File in the lower right.

Default is in the mode to install hook, so change it.
This time, it is the second option because we want to write data to 0xD00010.
select (2. Embed at give address).

I will briefly explain each mode.

1.No,it does not interfere with ROM
It only compile (assemble).
The result is saved in a dmp file.
In this mode, it does not write to ROM.

2. Embed at give address (This time I choose this.)
Writes the compiled (assembled) result to the specified address.

3. Place it in the free area and embed the jump code
Create a hook routine in the specified location, and create a jump code to the asm routine written in the free area.
It want to add processing to the routine but use it when there is no capacity to add.
Hook code creates 8 bytes to 10 bytes on the spot and moves it to your asm routine.

Add the technically asm file to the. s file.
Teq has forgotten to write .thumb, so please add it to the beginning.

—a.s–

.thumb @Please add this.
push {r14}
mov r0,#0x1
mov r1,#0x2D
ldr r2,=#0x8026C08
mov r14,r2
.short 0xF800
lsl r0,#0x18
asr r0,#0x18
pop {r1}
bx r1

Please write with the Open button.

When writing is successful, if you look at 0xD0010, the specified asm routine is written.

After that, actually read this routine and test the operation.
If it does not work properly, please use no$gba-debugger etc.

Thank you two SO much! That worked perfectly! I can already tell this site is going to be great for whatever I pursue in the future.

1 Like