Skip to content

Commit 13f90a9

Browse files
committed
Add ARM BX instruction for function returns
The BX (Branch and Exchange) instruction is needed for proper function returns in ARM code generation. Unlike BLX which saves the return address, BX simply branches to the address in the register. This fixes undefined reference errors during compilation.
1 parent 56c9378 commit 13f90a9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/arm.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,12 @@ int __blx(arm_cond_t cond, arm_reg rd)
329329
return arm_encode(cond, 18, 15, 15, rd + 3888);
330330
}
331331

332+
int __bx(arm_cond_t cond, arm_reg rm)
333+
{
334+
/* BX: Branch and Exchange */
335+
return (cond << 28) | 0x012FFF10 | rm;
336+
}
337+
332338
int __mul(arm_cond_t cond, arm_reg rd, arm_reg r1, arm_reg r2)
333339
{
334340
return arm_encode(cond, 0, rd, 0, (r1 << 8) + 144 + r2);

0 commit comments

Comments
 (0)