MACRO
$HandlerLabel HANDLER $HandleLabel
$HandlerLabel
sub sp,sp,#4 ;decrement sp(to store jump address)
stmfd sp!,{r0} ;PUSH the work register to stack(lr does not push because it return to original address)
ldr r0,=$HandleLabel;load the address of HandleXXX to r0
ldr r0,[r0] ;load the contents(service routine start address) of HandleXXX
str r0,[sp,#4] ;store the contents(ISR) of HandleXXX to stack
ldmfd sp!,{r0,pc} ;POP the work register and pc(jump to ISR)
MEND
$HandlerLabel 和 $HandleLabel是两个参数,第一个参数和第二个参数是不一样的,中间少了个r,而第一个参数在本宏中是一个标号,而第二个函数是一个入口地址。
拿HandlerSWI HANDLER HandleSWI说明:把它用宏给替换下来以后是:
$HandlerSWI
sub sp,sp,#4 ; decrement sp(to store jump address)
stmfd sp!,{r0} ; PUSH the work register to stack(lr does not push because it
return to original address)
ldr r0,=$HandleSWI ; load the address of HandleXXX to r0
ldr r0,[r0] ; load the contents(service routine start address) of HandleXXX
str r0,[sp,#4] ; store the contents(ISR) of HandleXXX to stack
ldmfd sp!,{r0,pc} ; POP the work register and pc(jump to ISR)