mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Compile agbabi into agb
This commit is contained in:
parent
149d2ec76b
commit
601360ca67
|
@ -1,7 +1,13 @@
|
|||
use std::path;
|
||||
|
||||
fn main() {
|
||||
let asm = &["crt0.s", "interrupt_handler.s", "src/sound/mixer/mixer.s"];
|
||||
let asm = &[
|
||||
"crt0.s",
|
||||
"interrupt_handler.s",
|
||||
"src/sound/mixer/mixer.s",
|
||||
"src/agbabi/memset.s",
|
||||
"src/agbabi/memcpy.s",
|
||||
];
|
||||
|
||||
println!("cargo:rerun-if-changed=gba.ld");
|
||||
println!("cargo:rerun-if-changed=gba_mb.ld");
|
||||
|
|
115
agb/src/agbabi/memcpy.s
Normal file
115
agb/src/agbabi/memcpy.s
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
===============================================================================
|
||||
|
||||
ABI:
|
||||
__aeabi_memcpy, __aeabi_memcpy4, __aeabi_memcpy8
|
||||
Standard:
|
||||
memcpy
|
||||
Support:
|
||||
__agbabi_memcpy2
|
||||
|
||||
Copyright (C) 2021-2022 agbabi contributors
|
||||
For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
.arm
|
||||
.align 4
|
||||
|
||||
.section .iwram.__aeabi_memcpy, "ax", %progbits
|
||||
.global __agbabi_memcpy
|
||||
__agbabi_memcpy:
|
||||
.global __aeabi_memcpy
|
||||
__aeabi_memcpy:
|
||||
// Check pointer alignment
|
||||
eor r3, r1, r0
|
||||
// JoaoBapt carry & sign bit test
|
||||
movs r3, r3, lsl #31
|
||||
bmi .Lcopy1
|
||||
bcs .Lcopy2
|
||||
|
||||
.Lcopy4:
|
||||
// Copy half and byte head
|
||||
rsb r3, r0, #4
|
||||
movs r3, r3, lsl #31
|
||||
ldrmib r3, [r1], #1
|
||||
strmib r3, [r0], #1
|
||||
submi r2, r2, #1
|
||||
ldrcsh r3, [r1], #2
|
||||
strcsh r3, [r0], #2
|
||||
subcs r2, r2, #2
|
||||
// Fallthrough
|
||||
|
||||
.global __aeabi_memcpy8
|
||||
__aeabi_memcpy8:
|
||||
.global __aeabi_memcpy4
|
||||
__aeabi_memcpy4:
|
||||
// Copy 8 words
|
||||
movs r12, r2, lsr #5
|
||||
beq .Lskip32
|
||||
lsl r3, r12, #5
|
||||
sub r2, r2, r3
|
||||
push {r4-r10}
|
||||
.LcopyWords8:
|
||||
ldmia r1!, {r3-r10}
|
||||
stmia r0!, {r3-r10}
|
||||
subs r12, r12, #1
|
||||
bne .LcopyWords8
|
||||
pop {r4-r10}
|
||||
.Lskip32:
|
||||
|
||||
// Copy words
|
||||
movs r12, r2, lsr #2
|
||||
.LcopyWords:
|
||||
subs r12, r12, #1
|
||||
ldrhs r3, [r1], #4
|
||||
strhs r3, [r0], #4
|
||||
bhs .LcopyWords
|
||||
|
||||
// Copy half and byte tail
|
||||
movs r3, r2, lsl #31
|
||||
ldrcsh r3, [r1], #2
|
||||
strcsh r3, [r0], #2
|
||||
ldrmib r3, [r1]
|
||||
strmib r3, [r0]
|
||||
bx lr
|
||||
|
||||
.Lcopy2:
|
||||
// Copy byte head
|
||||
tst r0, #1
|
||||
ldrneb r3, [r1], #1
|
||||
strneb r3, [r0], #1
|
||||
subne r2, r2, #1
|
||||
// Fallthrough
|
||||
|
||||
.global __agbabi_memcpy2
|
||||
__agbabi_memcpy2:
|
||||
// Copy halves
|
||||
movs r12, r2, lsr #1
|
||||
.LcopyHalves:
|
||||
subs r12, r12, #1
|
||||
ldrhsh r3, [r1], #2
|
||||
strhsh r3, [r0], #2
|
||||
bhs .LcopyHalves
|
||||
|
||||
// Copy byte tail
|
||||
tst r2, #1
|
||||
ldrneb r3, [r1]
|
||||
strneb r3, [r0]
|
||||
bx lr
|
||||
|
||||
.Lcopy1:
|
||||
subs r2, r2, #1
|
||||
ldrhsb r3, [r1], #1
|
||||
strhsb r3, [r0], #1
|
||||
bhs .Lcopy1
|
||||
bx lr
|
||||
|
||||
.section .iwram.memcpy, "ax", %progbits
|
||||
.global memcpy
|
||||
memcpy:
|
||||
push {r0, lr}
|
||||
bl __aeabi_memcpy
|
||||
pop {r0, lr}
|
||||
bx lr
|
107
agb/src/agbabi/memset.s
Normal file
107
agb/src/agbabi/memset.s
Normal file
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
===============================================================================
|
||||
|
||||
ABI:
|
||||
__aeabi_memset, __aeabi_memset4, __aeabi_memset8,
|
||||
__aeabi_memclr, __aeabi_memclr4, __aeabi_memclr8
|
||||
Standard:
|
||||
memset
|
||||
Support:
|
||||
__agbabi_wordset4
|
||||
|
||||
Copyright (C) 2021-2022 agbabi contributors
|
||||
For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
.arm
|
||||
.balign 4
|
||||
|
||||
.section .iwram.__aeabi_memset, "ax", %progbits
|
||||
.global __agbabi_memset
|
||||
__agbabi_memset:
|
||||
.global __aeabi_memclr
|
||||
__aeabi_memclr:
|
||||
mov r2, #0
|
||||
b .LskipShifts
|
||||
|
||||
.global __aeabi_memset
|
||||
__aeabi_memset:
|
||||
mov r2, r2, lsl #24
|
||||
orr r2, r2, r2, lsr #8
|
||||
orr r2, r2, r2, lsr #16
|
||||
// Fallthrough
|
||||
|
||||
.LskipShifts:
|
||||
// JoaoBapt carry & sign bit test
|
||||
rsb r3, r0, #4
|
||||
movs r3, r3, lsl #31
|
||||
// Set half and byte head
|
||||
strmib r2, [r0], #1
|
||||
submi r1, r1, #1
|
||||
strcsh r2, [r0], #2
|
||||
subcs r1, r1, #2
|
||||
b __agbabi_wordset4
|
||||
|
||||
.global __aeabi_memclr8
|
||||
__aeabi_memclr8:
|
||||
.global __aeabi_memclr4
|
||||
__aeabi_memclr4:
|
||||
mov r2, #0
|
||||
b __agbabi_wordset4
|
||||
|
||||
.global __aeabi_memset8
|
||||
__aeabi_memset8:
|
||||
.global __aeabi_memset4
|
||||
__aeabi_memset4:
|
||||
mov r2, r2, lsl #24
|
||||
orr r2, r2, r2, lsr #8
|
||||
orr r2, r2, r2, lsr #16
|
||||
// Fallthrough
|
||||
|
||||
.global __agbabi_wordset4
|
||||
__agbabi_wordset4:
|
||||
// Set 8 words
|
||||
movs r12, r1, lsr #5
|
||||
beq .Lskip32
|
||||
lsl r3, r12, #5
|
||||
sub r1, r1, r3
|
||||
push {r4-r9}
|
||||
mov r3, r2
|
||||
mov r4, r2
|
||||
mov r5, r2
|
||||
mov r6, r2
|
||||
mov r7, r2
|
||||
mov r8, r2
|
||||
mov r9, r2
|
||||
.LsetWords8:
|
||||
stmia r0!, {r2-r9}
|
||||
subs r12, r12, #1
|
||||
bne .LsetWords8
|
||||
pop {r4-r9}
|
||||
.Lskip32:
|
||||
|
||||
// Set words
|
||||
movs r12, r1, lsr #2
|
||||
.LsetWords:
|
||||
subs r12, r12, #1
|
||||
strhs r2, [r0], #4
|
||||
bhs .LsetWords
|
||||
|
||||
// Set half and byte tail
|
||||
movs r3, r1, lsl #31
|
||||
strcsh r2, [r0], #2
|
||||
strmib r2, [r0]
|
||||
bx lr
|
||||
|
||||
.section .iwram.memset, "ax", %progbits
|
||||
.global memset
|
||||
memset:
|
||||
mov r3, r1
|
||||
mov r1, r2
|
||||
mov r2, r3
|
||||
push {r0, lr}
|
||||
bl __aeabi_memset
|
||||
pop {r0, lr}
|
||||
bx lr
|
Loading…
Reference in a new issue