From 823da6108b486c4582cb03e882518cae4f7b72f1 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sat, 7 May 2022 15:18:07 +0200 Subject: [PATCH] WIP ARM: Use mes-style crt1.M1. --- lib/arm-mes/arm.M1 | 1 + lib/linux/arm-mes-m2/crt1.M1 | 44 +++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/arm-mes/arm.M1 b/lib/arm-mes/arm.M1 index 384f8776..f2c078d4 100644 --- a/lib/arm-mes/arm.M1 +++ b/lib/arm-mes/arm.M1 @@ -31,6 +31,7 @@ DEFINE add____$i8,%r0 0090e2 # adds r0, r0, #xx; ADDSI = immediate op1 '09' op # 1090e2 # adds r1, r0, #xx; ADDSI = immediate op1 '09' op2 'e2' DEFINE add____$i8,%r1 1091e2 # adds r1, r1, #xx DEFINE add____$i8,%r13 d09de2 # adds r13, r13, #xx +DEFINE add____$i8,%ebp e28cc0 # adds ip, ip, #xx DEFINE sub____$i8,%r0 0050e2 # subs r0, r0, #xx DEFINE sub____$i8,%r1 1051e2 # subs r1, r1, #xx DEFINE add____%r0,%r0 000090e0 # adds r0, r0, r0 diff --git a/lib/linux/arm-mes-m2/crt1.M1 b/lib/linux/arm-mes-m2/crt1.M1 index 4c71e9e8..d18dbd92 100644 --- a/lib/linux/arm-mes-m2/crt1.M1 +++ b/lib/linux/arm-mes-m2/crt1.M1 @@ -1,6 +1,7 @@ ### GNU Mes --- Maxwell Equations of Software ### Copyright (C) 2016 Jeremiah Orians -### Copyright © 2022 Jan (janneke) Nieuwenhuizen +### Copyright © 2017,2018,2022 Jan (janneke) Nieuwenhuizen +### Copyright © 2020 Danny Milosavljevic ### ### This file is part of GNU Mes. ### @@ -17,6 +18,47 @@ ### You should have received a copy of the GNU General Public License ### along with GNU Mes. If not, see . +:UNUSED_start + ;; ??? from M2 + '0' SP BP NO_SHIFT MOVE_ALWAYS ; Setup Base Pointer + + push___%lr + push___%ebp + mov____%esp,%ebp + allocate_stack_4180 + !0 mov____$i8,%r0 + mov____%r0,0x32 &GLOBAL___stdin + !1 mov____$i8,%r0 + mov____%r0,0x32 &GLOBAL___stdout + !2 mov____$i8,%r0 + mov____%r0,0x32 &GLOBAL___stderr + !8 ldr____%r0,(%fp,+#$i8) + mov____%fp,%r1 + !12 add____%r1,$i8 + add____%r2,%r1,%r0,lsl#2 + !4 add____%r2,$i8 + mov____%r2,0x32 &GLOBAL_environ + +; M2-Planet calling convention pushes forward + push___%r0 ; argc + push___%r1 ; argv + push___%r2 ; environ + + !4 add____$i8,%ebp ;M2-Planet calling convention + ^~FUNCTION_main bl + !0x0 add____$i8,%esp + !0x0 cmp____$i8,%r0 + SYS_exit mov____$i8,%r7 + swi____$0 +:__start_loop + wfi + !0x1 mov____$i8,%r0 + !0x0 cmp____$i8,%r0 + ^~__start_loop b + mov____%ebp,%esp + pop____%ebp + ret + :_start '0' SP BP NO_SHIFT MOVE_ALWAYS ; Setup Base Pointer