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() { 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 mut o_files = vec![];
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);
}
} }
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 .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"

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom); __text_start = ORIGIN(rom);
INPUT (agb.a)
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

View file

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

View file

@ -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

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom); __text_start = ORIGIN(rom);
INPUT (agb.a)
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

View file

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

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom); __text_start = ORIGIN(rom);
INPUT (agb.a)
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

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom); __text_start = ORIGIN(rom);
INPUT (agb.a)
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

View file

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

View file

@ -12,15 +12,15 @@ MEMORY {
__text_start = ORIGIN(rom); __text_start = ORIGIN(rom);
INPUT (agb.a)
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

View file

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