Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backup v8 before I blow everything up
- Loading branch information
1 parent
4ad2fda
commit 1b328d0
Showing
16 changed files
with
145 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,8 @@ | ||
#ifndef COMMON_H | ||
#define COMMON_H | ||
|
||
.extern exit, printf, puts | ||
|
||
/* Store all callee saved registers, and LR in case we make further BL calls. | ||
* | ||
* Also save the input arguments r0-r3 on the stack, so we can access them later on, | ||
* despite those registers being overwritten. | ||
*/ | ||
#define ENTRY \ | ||
.text; \ | ||
.global asm_main; \ | ||
asm_main: \ | ||
stmdb sp!, { r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr }; \ | ||
; | ||
#include "common_arch.h" | ||
|
||
/* Branching to "fail" makes tests fail with exit status 1. | ||
* | ||
* If EXIT is reached, the program ends successfully. | ||
* | ||
* Meant to be called at the end of ENTRY. | ||
* | ||
* Restore LR and jump to it to return from asm_main. | ||
* | ||
* * r0: line of failure | ||
*/ | ||
#define EXIT \ | ||
mov r0, #0; \ | ||
mov r1, #0; \ | ||
b pass; \ | ||
fail: \ | ||
ldr r1, [sp]; \ | ||
str r0, [r1]; \ | ||
mov r0, #1; \ | ||
pass: \ | ||
add sp, #16; \ | ||
ldmia sp!, { r4, r5, r6, r7, r8, r9, r10, r11, lr }; \ | ||
bx lr; \ | ||
; | ||
|
||
#define FAIL_IF(condition) \ | ||
condition 1f; \ | ||
b 2f; \ | ||
1: \ | ||
ldr r0, =__LINE__; \ | ||
b fail; \ | ||
2: \ | ||
; | ||
.extern exit, printf, puts | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef COMMON_ARCH_H | ||
#define COMMON_ARCH_H | ||
|
||
/* Store all callee saved registers, and LR in case we make further BL calls. | ||
* | ||
* Also save the input arguments r0-r3 on the stack, so we can access them later on, | ||
* despite those registers being overwritten. | ||
*/ | ||
#define ENTRY \ | ||
.text; \ | ||
.global asm_main; \ | ||
asm_main: \ | ||
stmdb sp!, { r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, lr }; \ | ||
asm_main_end: \ | ||
; | ||
|
||
/* Meant to be called at the end of ENTRY.* | ||
* | ||
* Branching to "fail" makes tests fail with exit status 1. | ||
* | ||
* If EXIT is reached, the program ends successfully. | ||
* | ||
* Restore LR and bx jump to it to return from asm_main. | ||
*/ | ||
#define EXIT \ | ||
mov r0, #0; \ | ||
mov r1, #0; \ | ||
b pass; \ | ||
fail: \ | ||
ldr r1, [sp]; \ | ||
str r0, [r1]; \ | ||
mov r0, #1; \ | ||
pass: \ | ||
add sp, #16; \ | ||
ldmia sp!, { r4, r5, r6, r7, r8, r9, r10, r11, lr }; \ | ||
bx lr; \ | ||
; | ||
|
||
#define FAIL_IF(condition) \ | ||
condition 1f; \ | ||
b 2f; \ | ||
1: \ | ||
ldr r0, =__LINE__; \ | ||
b fail; \ | ||
2: \ | ||
; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* Minimal example using common.h. */ | ||
|
||
#include "common.h" | ||
|
||
ENTRY | ||
EXIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
* Controls the exit status of the program. | ||
*/ | ||
|
||
#include "common.h" | ||
|
||
.text | ||
.global asm_main | ||
asm_main: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# The opposite of -mthumb. | ||
CFLAGS_EXTRA = -marm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef COMMON_ARCH_H | ||
#define COMMON_ARCH_H | ||
|
||
#define ENTRY \ | ||
.text; \ | ||
.global asm_main; \ | ||
asm_main: \ | ||
sub sp, sp, #0xA0; \ | ||
stp x29, x30, [sp, #0x0]; \ | ||
stp x27, x28, [sp, #0x10]; \ | ||
stp x25, x26, [sp, #0x20]; \ | ||
stp x23, x24, [sp, #0x30]; \ | ||
stp x21, x22, [sp, #0x40]; \ | ||
stp x19, x20, [sp, #0x50]; \ | ||
stp x6, x7, [sp, #0x60]; \ | ||
stp x4, x5, [sp, #0x80]; \ | ||
stp x2, x3, [sp, #0x90]; \ | ||
stp x0, x1, [sp, #0xA0]; \ | ||
asm_main_end: \ | ||
; | ||
|
||
#define EXIT \ | ||
mov w0, #0; \ | ||
mov w1, #0; \ | ||
b pass; \ | ||
fail: \ | ||
ldr w1, [sp]; \ | ||
str w0, [x1]; \ | ||
mov w0, #1; \ | ||
pass: \ | ||
ldp x19, x20, [sp, #0x50]; \ | ||
ldp x21, x22, [sp, #0x40]; \ | ||
ldp x23, x24, [sp, #0x30]; \ | ||
ldp x25, x26, [sp, #0x20]; \ | ||
ldp x27, x28, [sp, #0x10]; \ | ||
ldp x29, x30, [sp]; \ | ||
add sp, sp, #0xA0; \ | ||
ret; \ | ||
; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../hello_common.S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.text | ||
.global asm_main | ||
asm_main: | ||
mov w0, #0 | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
ARCH = aarch64 | ||
DEFAULT_SYSROOT = /usr/aarch64-linux-gnu | ||
MARCH = armv8-a | ||
PREFIX = aarch64-linux-gnu |