mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 00:56:38 +11:00
split out assembly
This commit is contained in:
parent
46260c085a
commit
0be9da755c
6 changed files with 22637 additions and 30 deletions
58
agb/build.rs
58
agb/build.rs
|
@ -1,35 +1,51 @@
|
||||||
|
use std::path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rerun-if-changed=crt0.s");
|
let asm = &["crt0.s", "interrupt_handler.s", "src/sound/mixer/mixer.s"];
|
||||||
|
|
||||||
|
println!("cargo:rerun-if-changed=gba.ld");
|
||||||
println!("cargo:rerun-if-changed=gba_mb.ld");
|
println!("cargo:rerun-if-changed=gba_mb.ld");
|
||||||
println!("cargo:rerun-if-changed=src/sound/mixer/mixer.s");
|
|
||||||
println!("cargo:rerun-if-changed=src/asm_include.s");
|
println!("cargo:rerun-if-changed=src/asm_include.s");
|
||||||
println!("cargo:rerun-if-changed=interrupt_handler.s");
|
|
||||||
println!("cargo:rerun-if-changed=gfx/test_logo.png");
|
println!("cargo:rerun-if-changed=gfx/test_logo.png");
|
||||||
|
|
||||||
let out_file_name = "crt0.o";
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
|
||||||
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR environment variable must be specified");
|
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR environment variable must be specified");
|
||||||
let out_file_path = format!("{}/{}", out_dir, &out_file_name);
|
|
||||||
|
|
||||||
let out = std::process::Command::new("arm-none-eabi-as")
|
for &a in asm.iter() {
|
||||||
.arg("-mthumb-interwork")
|
println!("cargo:rerun-if-changed={}", a);
|
||||||
.arg("-mcpu=arm7tdmi")
|
let filename = path::Path::new(a);
|
||||||
.arg("-g")
|
let filename = filename.with_extension("o");
|
||||||
.args(&["-o", out_file_path.as_str()])
|
let filename = filename
|
||||||
.arg("crt0.s")
|
.file_name()
|
||||||
.output()
|
.expect("should have filename")
|
||||||
.expect("failed to compile crt0.s");
|
.to_str()
|
||||||
|
.expect("Please make it valid utf-8");
|
||||||
|
|
||||||
assert!(
|
let out_file_path = format!("{}/{}", out_dir, filename);
|
||||||
out.status.success(),
|
|
||||||
"{}",
|
|
||||||
String::from_utf8_lossy(&out.stderr)
|
|
||||||
);
|
|
||||||
|
|
||||||
for warning_line in String::from_utf8_lossy(&out.stderr).split('\n') {
|
let out = std::process::Command::new("arm-none-eabi-as")
|
||||||
if !warning_line.is_empty() {
|
.arg("-mthumb-interwork")
|
||||||
println!("cargo:warning={}", warning_line);
|
.arg("-mcpu=arm7tdmi")
|
||||||
|
.arg("-g")
|
||||||
|
.args(&["-o", out_file_path.as_str()])
|
||||||
|
.arg(a)
|
||||||
|
.output()
|
||||||
|
.unwrap_or_else(|_| panic!("failed to compile {}", a));
|
||||||
|
|
||||||
|
assert!(
|
||||||
|
out.status.success(),
|
||||||
|
"{}",
|
||||||
|
String::from_utf8_lossy(&out.stderr)
|
||||||
|
);
|
||||||
|
for warning_line in String::from_utf8_lossy(&out.stderr).split('\n') {
|
||||||
|
if !warning_line.is_empty() {
|
||||||
|
println!("cargo:warning={}", warning_line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
println!("cargo:rustc-link-arg={}", out_file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("cargo:rustc-link-search={}", out_dir);
|
println!("cargo:rustc-link-search={}", out_dir);
|
||||||
|
// println!("cargo:rustc-link-arg={}/crt0.o", out_dir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
.include "src/asm_include.s"
|
|
||||||
|
|
||||||
.arm
|
.arm
|
||||||
.global __start
|
.global __start
|
||||||
|
.section .crt0
|
||||||
|
.align
|
||||||
__start:
|
__start:
|
||||||
b .Initialise
|
b .Initialise
|
||||||
|
|
||||||
|
@ -73,6 +74,3 @@ b .Initialise_mb
|
||||||
1:
|
1:
|
||||||
b 1b
|
b 1b
|
||||||
.pool
|
.pool
|
||||||
|
|
||||||
.include "interrupt_handler.s"
|
|
||||||
.include "src/sound/mixer/mixer.s"
|
|
||||||
|
|
|
@ -15,12 +15,10 @@ __text_start = ORIGIN(rom);
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
. = __text_start;
|
. = __text_start;
|
||||||
|
|
||||||
.crt0 : {
|
|
||||||
KEEP (crt0.o(.text));
|
|
||||||
. = ALIGN(4);
|
|
||||||
} > rom
|
|
||||||
|
|
||||||
.text : {
|
.text : {
|
||||||
|
KEEP(*(.crt0));
|
||||||
|
*(.crt0 .crt0*);
|
||||||
*(.text .text*);
|
*(.text .text*);
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
} > rom
|
} > rom
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.macro agb_arm_func functionName:req
|
.macro agb_arm_func functionName:req
|
||||||
.section .iwram, "ax", %progbits @ "ax" = allocatable and executable, %progbits = contains data
|
.section .iwram
|
||||||
.arm
|
.arm
|
||||||
.align 2
|
.align 2
|
||||||
.global \functionName
|
.global \functionName
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
.include "src/asm_include.s"
|
||||||
|
|
||||||
.section .iwram
|
.section .iwram
|
||||||
.global agb_rs__buffer_size
|
.global agb_rs__buffer_size
|
||||||
.balign 4
|
.balign 4
|
||||||
|
|
Loading…
Add table
Reference in a new issue