rust-embedded / cortex-m-rt

Minimal startup / runtime for Cortex-M microcontrollers

Home Page:https://rust-embedded.github.io/cortex-m-rt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to prevent generation of 'extra' code for ISR

LeonSkoog opened this issue · comments

Hello,
I'm trying to write simple RTOS and I'm struggling with extra asm code generated by compiler.
I was able to remove trampoline by using #[no_mangle] attribute but I can't figure out how to remove/prevent generation of push {r7, lr} and pop {r7, pc} instructions.

Here is my PendSV code:

#[allow(non_snake_case)]
#[no_mangle]
pub fn PendSV() {
    unsafe{
        asm!("nop")
    }
}

Here is generated code:

push    {r7, lr}
mov     r7, sp
nop                                                                                                                                      
pop     {r7, pc}

I'm looking for some sort of attribute or compiler option so I could have just nop generated as part of PendSV function. Is it possible?

@Disasm - That's exactly what I was looking for!
Thanks! :)