From 496fd1068004459e82c3e18de342008cd4176a26 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Mon, 12 Sep 2022 09:47:28 +0200 Subject: [PATCH] ARM: Fix unsigned modulo. * lib/arm-mes/arm.M1 (mov____%esp,%r3): New macro. * module/mescc/armv4/as.scm (armv4:r0%r1): Use it to avoid overwriting %r0 before caling __mesabi_uldiv. --- lib/arm-mes/arm.M1 | 3 ++- module/mescc/armv4/as.scm | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/arm-mes/arm.M1 b/lib/arm-mes/arm.M1 index 9bf19126..384f8776 100644 --- a/lib/arm-mes/arm.M1 +++ b/lib/arm-mes/arm.M1 @@ -1,5 +1,5 @@ ### GNU Mes --- Maxwell Equations of Software -### Copyright © 2017,2018,2020 Jan (janneke) Nieuwenhuizen +### Copyright © 2017,2018,2020,2022 Jan (janneke) Nieuwenhuizen ### Copyright © 2019,2020 Danny Milosavljevic ### ### This file is part of GNU Mes. @@ -91,6 +91,7 @@ DEFINE mov____%r0,(%r1) 000081e5 DEFINE mov____%r1,%r0 0100a0e1 DEFINE mov____%r1,%r2 0120a0e1 DEFINE mov____%esp,%r0 0d00a0e1 +DEFINE mov____%esp,%r3 0d30a0e1 # e59f9004 ldr r9, [pc, #4] ; # e5890000 str r0, [r9] diff --git a/module/mescc/armv4/as.scm b/module/mescc/armv4/as.scm index e30338d3..3787c9be 100644 --- a/module/mescc/armv4/as.scm +++ b/module/mescc/armv4/as.scm @@ -383,9 +383,9 @@ `(,(string-append "push___%" r0)) (armv4:call-label #f "__mesabi_imod" 2)) ;; __mesabi_uldiv(a, b, remainderp) - (append `(("push___%r0") ; slot for remainder - ("mov____%esp,%r0") - ("push___%r0") ; pointer to remainder + (append `(("push___%r3") ; slot for remainder + ("mov____%esp,%r3") + ("push___%r3") ; pointer to remainder (,(string-append "push___%" r1)) (,(string-append "push___%" r0))) (armv4:call-label #f "__mesabi_uldiv" 3)