2018-10-16 06:56:02 -05:00
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
use core::fmt::Write;
|
|
|
|
use cortex_m::asm;
|
2019-07-28 12:05:31 -05:00
|
|
|
use cortex_m_rt::entry;
|
|
|
|
use cortex_m_semihosting as semihosting;
|
|
|
|
|
2020-01-21 04:12:17 -06:00
|
|
|
use panic_halt as _;
|
2018-10-16 06:56:02 -05:00
|
|
|
|
2020-01-21 04:12:17 -06:00
|
|
|
#[entry]
|
2018-10-16 06:56:02 -05:00
|
|
|
fn main() -> ! {
|
|
|
|
let x = 42;
|
|
|
|
|
|
|
|
loop {
|
|
|
|
asm::nop();
|
|
|
|
|
|
|
|
// write something through semihosting interface
|
|
|
|
let mut hstdout = semihosting::hio::hstdout().unwrap();
|
2019-07-28 12:05:31 -05:00
|
|
|
let _ = write!(hstdout, "x = {}\n", x);
|
2018-10-16 06:56:02 -05:00
|
|
|
|
|
|
|
// exit from qemu
|
|
|
|
semihosting::debug::exit(semihosting::debug::EXIT_SUCCESS);
|
|
|
|
}
|
2018-10-16 07:08:13 -05:00
|
|
|
}
|