views:

149

answers:

1
+1  Q: 

assembly return

a small portion of my code

swi  r6,r0,LCD_ CONT  
addi r10,r0,6  

firstdelay:  
addi r10,r10,-1  
bnei r10,firstdelay  
swi  r0,r0,LCD_ CONT  
addi r10,r0,30

seconddelay:  
addi r10,r10,-1  
bnei r10,seconddelay  
swi  r5,r0,LCD_DATA

i have to delay multiple times throughout the program but want to keep it small. id like to write something along the lines of:

swi  r6,r0,LCD_ CONT  
addi r10,r0,[delayamount]  
bri  Delay  
swi  r0,r0,LCD_ CONT  
addi r10,r0,[newdelayamount]  
bri  Delay

Delay:  
addi r10,r10,-1  
bnei r10,Delay  
[return to where I was previously in the code]

so my issue is: how do i get back to where i was in the code without having to create multiple delays and just run through the code straight. thanks everyone!

+1  A: 

Maybe this will help: Using Functions (note "the opcode rtsd is then used to return to the calling function").

ChrisW
rtsd will call me back to the calling function but how can i have it call back to another part of the current function? this assembly i am writing is already a subroutine being called from a C function so using rtsd r15, 8 will pull me back to the caling function
scott
I was suggesting that you make the delay code a separate function, which you'd call from your function using `brlid` (as described in the section titled "Invoking a Function"), so that when the delay code returns it would return to your function (which called it).
ChrisW
i may try that. thanks Chris!
scott