1 // assembly-output: emit-asm
2 // compile-flags: --target msp430-none-elf
3 // needs-llvm-components: msp430
5 #![feature(no_core, lang_items, rustc_attrs, asm_sym, asm_experimental_arch, asm_const)]
6 #![crate_type = "rlib"]
8 #![allow(non_camel_case_types)]
10 #[rustc_builtin_macro]
14 #[rustc_builtin_macro]
24 type ptr = *const i16;
33 ($func:ident $ty:ident $class:ident) => {
35 pub unsafe fn $func(x: $ty) -> $ty {
37 asm!("mov {}, {}", lateout($class) y, in($class) x);
44 ($func:ident $ty:ident $class:ident) => {
46 pub unsafe fn $func(x: $ty) -> $ty {
48 asm!("mov.b {}, {}", lateout($class) y, in($class) x);
54 macro_rules! check_reg {
55 ($func:ident $ty:ident $reg:tt) => {
57 pub unsafe fn $func(x: $ty) -> $ty {
59 asm!(concat!("mov ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
65 macro_rules! check_regb {
66 ($func:ident $ty:ident $reg:tt) => {
68 pub unsafe fn $func(x: $ty) -> $ty {
70 asm!(concat!("mov.b ", $reg, ", ", $reg), lateout($reg) y, in($reg) x);
78 static extern_static: i8;
81 // CHECK-LABEL: sym_fn
83 // CHECK: call extern_func
86 pub unsafe fn sym_fn() {
87 asm!("call {}", sym extern_func);
90 // CHECK-LABEL: sym_static
92 // CHECK: mov.b extern_static, r{{[0-9]+}}
95 pub unsafe fn sym_static() -> i8 {
97 asm!("mov.b {1}, {0}", lateout(reg) y, sym extern_static);
101 // CHECK-LABEL: add_const:
103 // CHECK: add.b #5, r{{[0-9]+}}
106 pub unsafe fn add_const() -> i8 {
108 asm!("add.b #{number}, {}", out(reg) y, number = const 5);
112 // CHECK-LABEL: mov_postincrement:
114 // CHECK: mov @r5+, r{{[0-9]+}}
117 pub unsafe fn mov_postincrement(mut x: *const i16) -> (i16, *const i16) {
119 asm!("mov @r5+, {0}", out(reg) y, inlateout("r5") x);
123 // CHECK-LABEL: reg_i8:
125 // CHECK: mov r{{[0-9]+}}, r{{[0-9]+}}
127 check!(reg_i8 i8 reg);
129 // CHECK-LABEL: reg_i16:
131 // CHECK: mov r{{[0-9]+}}, r{{[0-9]+}}
133 check!(reg_i16 i16 reg);
135 // CHECK-LABEL: reg_i8b:
137 // CHECK: mov.b r{{[0-9]+}}, r{{[0-9]+}}
139 checkb!(reg_i8b i8 reg);
141 // CHECK-LABEL: r5_i8:
145 check_reg!(r5_i8 i8 "r5");
147 // CHECK-LABEL: r5_i16:
151 check_reg!(r5_i16 i16 "r5");
153 // CHECK-LABEL: r5_i8b:
155 // CHECK: mov.b r5, r5
157 check_regb!(r5_i8b i8 "r5");