]> git.lizzy.rs Git - rust.git/blob - src/doc/unstable-book/src/language-features/abi-msp430-interrupt.md
Rollup merge of #106904 - khuey:preserve_debuginfo_for_rlibs, r=davidtwco
[rust.git] / src / doc / unstable-book / src / language-features / abi-msp430-interrupt.md
1 # `abi_msp430_interrupt`
2
3 The tracking issue for this feature is: [#38487]
4
5 [#38487]: https://github.com/rust-lang/rust/issues/38487
6
7 ------------------------
8
9 In the MSP430 architecture, interrupt handlers have a special calling
10 convention. You can use the `"msp430-interrupt"` ABI to make the compiler apply
11 the right calling convention to the interrupt handlers you define.
12
13 <!-- NOTE(ignore) this example is specific to the msp430 target -->
14
15 ``` rust,ignore
16 #![feature(abi_msp430_interrupt)]
17 #![no_std]
18
19 // Place the interrupt handler at the appropriate memory address
20 // (Alternatively, you can use `#[used]` and remove `pub` and `#[no_mangle]`)
21 #[link_section = "__interrupt_vector_10"]
22 #[no_mangle]
23 pub static TIM0_VECTOR: extern "msp430-interrupt" fn() = tim0;
24
25 // The interrupt handler
26 extern "msp430-interrupt" fn tim0() {
27     // ..
28 }
29 ```
30
31 ``` text
32 $ msp430-elf-objdump -CD ./target/msp430/release/app
33 Disassembly of section __interrupt_vector_10:
34
35 0000fff2 <TIM0_VECTOR>:
36     fff2:       00 c0           interrupt service routine at 0xc000
37
38 Disassembly of section .text:
39
40 0000c000 <int::tim0>:
41     c000:       00 13           reti
42 ```