This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Nested Subroutines?

Hello,

I was wondering how to use routines in a subroutine (called nested subroutines?).

For example, let's say I have

    MOV r0, #0

start
    BL firstLoop


stop B stop


firstLoop
    ADD r0, r0, #1
    CMP r0, #0
    BEQ isZero
    BNE notZero
    BX LR ;This doesn't return me back to start

isZero
    ;Code
    B firstLoop

notZero
    ;Code
    B firstLoop

How do I go about doing something like this? I wan't to use something like a for loop in my firstLoop subroutine but by doing so, it apparently updates the LR so if I use BX LR once the for loop is done, it doesn't return me back to the very start.
From what I've seen I need something like a push subroutine?

Thank you very much

0