From fa4147a284e4d7b50175e0252bbd4ecf431cb7fd Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Tue, 6 Oct 2020 19:41:14 +0200 Subject: [PATCH] mescc: Use signed division for x86, x86_64 when appropriate. This fixes 36-compare-arithmetic.c * module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Do not reset signed?. * module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise. * lib/tests/scaffold/36-compare-arithmetic.c (main): Use unique exit value per failure. --- lib/tests/scaffold/36-compare-arithmetic.c | 16 ++++++++-------- module/mescc/i386/as.scm | 6 ++---- module/mescc/x86_64/as.scm | 6 ++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/tests/scaffold/36-compare-arithmetic.c b/lib/tests/scaffold/36-compare-arithmetic.c index a138aef9..a8ed0573 100644 --- a/lib/tests/scaffold/36-compare-arithmetic.c +++ b/lib/tests/scaffold/36-compare-arithmetic.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2020 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -30,31 +30,31 @@ main () oputs ("t: 2 - 1\n"); if (0) - return 1; + return 2; oputs ("t: 1 << 3\n"); if (1 << 3 != 8) - return 1; + return 3; oputs ("t: 8 >> 3\n"); if (8 >> 3 != 1) - return 1; + return 4; oputs ("t: 8 / 4\n"); if (8 / 4 != 2) - return 1; + return 5; oputs ("t: 8 / -4\n"); if (8 / -4 != -2) - return 1; + return 6; oputs ("t: -8 / -4\n"); if (-8 / -4 != 2) - return 1; + return 7; oputs ("t: -8 / 4\n"); if (-8 / 4 != -2) - return 1; + return 8; return 0; } diff --git a/module/mescc/i386/as.scm b/module/mescc/i386/as.scm index 387e3b7a..0b786e5b 100644 --- a/module/mescc/i386/as.scm +++ b/module/mescc/i386/as.scm @@ -355,8 +355,7 @@ `((,(string-append "and____%" r1 ",%" r0))))) (define (i386:r0/r1 info signed?) - (let ((signed? #f) ; nobody knows, -- all advice are belong to us? - (allocated (.allocated info)) + (let ((allocated (.allocated info)) (r0 (get-r0 info)) (r1 (get-r1 info))) (if (not (member "edx" allocated)) @@ -381,8 +380,7 @@ ("pop____%eax"))))) (define (i386:r0%r1 info signed?) - (let ((signed? #f) ; nobody knows, -- all advice are belong to us? - (allocated (.allocated info)) + (let ((allocated (.allocated info)) (r0 (get-r0 info)) (r1 (get-r1 info))) (if (not (member "edx" allocated)) diff --git a/module/mescc/x86_64/as.scm b/module/mescc/x86_64/as.scm index fe98452d..7e438c6c 100644 --- a/module/mescc/x86_64/as.scm +++ b/module/mescc/x86_64/as.scm @@ -435,8 +435,7 @@ `((,(string-append "and____%" r1 ",%" r0))))) (define (x86_64:r0/r1 info signed?) - (let ((signed? #f) ; nobody knows, -- all advice are belong to us? - (allocated (.allocated info)) + (let ((allocated (.allocated info)) (r0 (get-r0 info)) (r1 (get-r1 info))) (if (not (member "rdx" allocated)) @@ -461,8 +460,7 @@ ("pop____%rax"))))) (define (x86_64:r0%r1 info signed?) - (let ((signed? #f) ; nobody knows, -- all advice are belong to us? - (allocated (.allocated info)) + (let ((allocated (.allocated info)) (r0 (get-r0 info)) (r1 (get-r1 info))) (if (not (member "rdx" allocated))