Im a new user to the ARM7 and its asm instruction set. The current division libraries return zero if a divide by zero is detected. Im trying to modify one of these division libraries to record the called function’s address to a register to return back to another C function to detect where this /0 occurred
The original library asm looks something like this
=========
U_DIV:
STMFD sp!, {dvs, lr}
MOVS dvs, r1
BEQ div_by_zero
div_by_zero:
MOV r0, #0 ;
LDMFD sp!, {dvs, pc}
==========
What I want to do is get the stack pointer - 4 saved into A1 which should be the value of the function the divide by zero occurred in. When the branch to my C function occurs, A1 then gets passed to it.
Ive tried quite a few different things with my limited knowledge of this instruction set, but nothing seems to work.
=========
U_DIV:
<save stack address - 4 to A2>
STMFD sp!, {dvs, lr}
MOVS dvs, r1
BEQ div_by_zero
div_by_zero:
MOV A1, A2
BL _DIVZERO
MOV r0, #0 ;
LDMFD sp!, {dvs, pc}
==========
This seems like it should be something pretty easy to do, but I cant figure it out. Any suggestions?