Merge pull request #237 from corwinkuiper/split-asm

Split asm
This commit is contained in:
Corwin 2022-06-17 00:24:44 +01:00 committed by GitHub
commit c5af151d76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 22692 additions and 71 deletions

View file

@ -1,35 +1,67 @@
use std::path;
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=src/sound/mixer/mixer.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");
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_file_path = format!("{}/{}", out_dir, &out_file_name);
let mut o_files = vec![];
let out = std::process::Command::new("arm-none-eabi-as")
.arg("-mthumb-interwork")
.arg("-mcpu=arm7tdmi")
.arg("-g")
.args(&["-o", out_file_path.as_str()])
.arg("crt0.s")
.output()
.expect("failed to compile crt0.s");
for &a in asm.iter() {
println!("cargo:rerun-if-changed={}", a);
let filename = path::Path::new(a);
let filename = filename.with_extension("o");
let filename = filename
.file_name()
.expect("should have filename")
.to_str()
.expect("Please make it valid utf-8");
assert!(
out.status.success(),
"{}",
String::from_utf8_lossy(&out.stderr)
);
let out_file_path = format!("{}/{}", out_dir, filename);
for warning_line in String::from_utf8_lossy(&out.stderr).split('\n') {
if !warning_line.is_empty() {
println!("cargo:warning={}", warning_line);
let out = std::process::Command::new("arm-none-eabi-as")
.arg("-mthumb-interwork")
.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);
}
}
o_files.push(out_file_path);
}
println!("cargo:rustc-link-search={}", out_dir);
let archive = format!("{out_dir}/agb.a");
let ar_out = std::process::Command::new("arm-none-eabi-ar")
.arg("-crs")
.arg(&archive)
.args(&o_files)
.output()
.expect("Failed to create static library");
assert!(
ar_out.status.success(),
"{}",
String::from_utf8_lossy(&ar_out.stderr)
);
println!("cargo:rustc-link-search={out_dir}");
}

View file

@ -1,7 +1,8 @@
.include "src/asm_include.s"
.arm
.global __start
.section .crt0
.align
__start:
b .Initialise
@ -73,6 +74,3 @@ b .Initialise_mb
1:
b 1b
.pool
.include "interrupt_handler.s"
.include "src/sound/mixer/mixer.s"

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > rom
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > rom

View file

@ -11,18 +11,17 @@ MEMORY {
__text_start = ORIGIN(ewram);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > ewram
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > ewram
} > rom
__text_end = .;
.rodata : {

22593
agb/out.s Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
.macro agb_arm_func functionName:req
.section .iwram, "ax", %progbits @ "ax" = allocatable and executable, %progbits = contains data
.section .iwram
.arm
.align 2
.global \functionName

View file

@ -1,3 +1,5 @@
.include "src/asm_include.s"
.section .iwram
.global agb_rs__buffer_size
.balign 4

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > rom
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > rom

View file

@ -11,18 +11,17 @@ MEMORY {
__text_start = ORIGIN(ewram);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > ewram
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > ewram
} > rom
__text_end = .;
.rodata : {

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > rom
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > rom

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > rom
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > rom

View file

@ -11,18 +11,17 @@ MEMORY {
__text_start = ORIGIN(ewram);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > ewram
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > ewram
} > rom
__text_end = .;
.rodata : {

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > rom
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > rom

View file

@ -11,18 +11,17 @@ MEMORY {
__text_start = ORIGIN(ewram);
INPUT (agb.a)
SECTIONS {
. = __text_start;
.crt0 : {
KEEP (crt0.o(.text));
. = ALIGN(4);
} > ewram
.text : {
KEEP(*(.crt0));
*(.crt0 .crt0*);
*(.text .text*);
. = ALIGN(4);
} > ewram
} > rom
__text_end = .;
.rodata : {