mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
Support armv4t-none-eabi target as well.
This commit is contained in:
parent
a7e038aa18
commit
22e9cbccc0
|
@ -12,6 +12,7 @@
|
|||
)]
|
||||
#![feature(alloc_error_handler)]
|
||||
#![feature(allocator_api)]
|
||||
#![feature(asm_const)]
|
||||
#![warn(clippy::all)]
|
||||
#![deny(clippy::must_use_candidate)]
|
||||
#![deny(clippy::trivially_copy_pass_by_ref)]
|
||||
|
|
|
@ -4,10 +4,19 @@ use core::arch::asm;
|
|||
|
||||
#[allow(non_snake_case)]
|
||||
|
||||
const fn swi_map(thumb_id: u32) -> u32 {
|
||||
if cfg!(target_feature="thumb-mode") {
|
||||
thumb_id
|
||||
} else {
|
||||
thumb_id << 16
|
||||
}
|
||||
}
|
||||
|
||||
pub fn halt() {
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x02",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x02) },
|
||||
lateout("r0") _,
|
||||
lateout("r1") _,
|
||||
lateout("r2") _,
|
||||
|
@ -19,7 +28,8 @@ pub fn halt() {
|
|||
pub fn stop() {
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x03",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x03) },
|
||||
lateout("r0") _,
|
||||
lateout("r1") _,
|
||||
lateout("r2") _,
|
||||
|
@ -31,7 +41,8 @@ pub fn stop() {
|
|||
pub fn wait_for_interrupt() {
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x04",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x04) },
|
||||
lateout("r0") _,
|
||||
lateout("r1") _,
|
||||
lateout("r2") _,
|
||||
|
@ -45,7 +56,8 @@ pub fn wait_for_interrupt() {
|
|||
pub fn wait_for_vblank() {
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x05",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x05) },
|
||||
lateout("r0") _,
|
||||
lateout("r1") _,
|
||||
lateout("r2") _,
|
||||
|
@ -61,7 +73,8 @@ pub fn div(numerator: i32, denominator: i32) -> (i32, i32, i32) {
|
|||
let abs_divide: i32;
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x06",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x06) },
|
||||
in("r0") numerator,
|
||||
in("r1") denominator,
|
||||
lateout("r0") divide,
|
||||
|
@ -77,7 +90,8 @@ pub fn sqrt(n: i32) -> i32 {
|
|||
let result: i32;
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x08",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x08) },
|
||||
in("r0") n,
|
||||
lateout("r0") result,
|
||||
lateout("r1") _,
|
||||
|
@ -93,7 +107,8 @@ pub fn arc_tan(n: i16) -> i16 {
|
|||
let result: i16;
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x09",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x09) },
|
||||
in("r0") n,
|
||||
lateout("r0") result,
|
||||
lateout("r1") _,
|
||||
|
@ -109,7 +124,8 @@ pub fn arc_tan2(x: i16, y: i32) -> i16 {
|
|||
let result: i16;
|
||||
unsafe {
|
||||
asm!(
|
||||
"swi 0x09",
|
||||
"swi {SWI}",
|
||||
SWI = const { swi_map(0x09) },
|
||||
in("r0") x,
|
||||
in("r1") y,
|
||||
lateout("r0") result,
|
||||
|
|
Loading…
Reference in a new issue