diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 0648bbc8..51d24870 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -1079,10 +1079,17 @@ (jump-text body-length))))))) (lambda (o) (pmatch o - ((le ,a ,b) ((jump i386:Xjump-ncz) o)) - ((lt ,a ,b) ((jump i386:Xjump-nc) o)) - ((ge ,a ,b) ((jump i386:Xjump-ncz) o)) - ((gt ,a ,b) ((jump i386:Xjump-nc) o)) + ;; unsigned + ;; ((le ,a ,b) ((jump i386:Xjump-ncz) o)) ; ja + ;; ((lt ,a ,b) ((jump i386:Xjump-nc) o)) ; jae + ;; ((ge ,a ,b) ((jump i386:Xjump-ncz) o)) + ;; ((gt ,a ,b) ((jump i386:Xjump-nc) o)) + + ((le ,a ,b) ((jump i386:Xjump-g) o)) + ((lt ,a ,b) ((jump i386:Xjump-ge) o)) + ((ge ,a ,b) ((jump i386:Xjump-g) o)) + ((gt ,a ,b) ((jump i386:Xjump-ge) o)) + ((ne ,a ,b) ((jump i386:Xjump-nz) o)) ((eq ,a ,b) ((jump i386:Xjump-nz) o)) ((not _) ((jump i386:Xjump-z) o)) diff --git a/module/mes/as-i386.mes b/module/mes/as-i386.mes index 9b1a63df..287066cd 100644 --- a/module/mes/as-i386.mes +++ b/module/mes/as-i386.mes @@ -342,10 +342,6 @@ barf) `(#x72 ,(if (>= n 0) n (- n 2)))) ; jc -(define (i386:Xjump-c n) - (or n urg:Xjump-c) - `(#x0f #x82 ,@(int->bv32 n))) ; jc - (define (i386:jump-cz n) (when (or (> n #x80) (< n #x-80)) (format (current-error-port) "JUMP n=~a\n" n) @@ -364,18 +360,46 @@ barf) `(#x73 ,(if (>= n 0) n (- n 2)))) ; jnc +;; unsigned (define (i386:Xjump-nc n) (or n urg:Xjump-nc) `(#x0f #x83 ,@(int->bv32 n))) ; jnc -(define (i386:Xjump-cz n) - (or n urg:Xjump-cz) - `(#x0f #x86 ,@(int->bv32 n))) ; jbe - +;; unsigned (define (i386:Xjump-ncz n) (or n urg:Xjump-ncz) `(#x0f #x87 ,@(int->bv32 n))) ; ja +;; unsigned +;; (define (i386:Xjump-c n) +;; (or n urg:Xjump-c) +;; `(#x0f #x82 ,@(int->bv32 n))) ; jc + +;; unsigned +;; (define (i386:Xjump-cz n) +;; (or n urg:Xjump-cz) +;; `(#x0f #x86 ,@(int->bv32 n))) ; jbe + +;; signed +(define (i386:Xjump-g n) + (or n urg:Xjump-g) + `(#x0f #x8f ,@(int->bv32 n))) ; jg/jnle + +;; signed +(define (i386:Xjump-ge n) + (or n urg:Xjump-ge) + `(#x0f #x8d ,@(int->bv32 n))) ; jge/jnl + +;; ;; signed +;; (define (i386:Xjump-l n) +;; (or n urg:Xjump-l) +;; `(#x0f #x8c ,@(int->bv32 n))) ; jl/jnge + +;; ;; signed +;; (define (i386:Xjump-le n) +;; (or n urg:Xjump-le) +;; `(#x0f #x8e ,@(int->bv32 n))) ; jle/jgn + (define (i386:jump-z n) (when (or (> n #x80) (< n #x-80)) (format (current-error-port) "JUMP-z n=~a\n" n) diff --git a/module/mes/as-i386.scm b/module/mes/as-i386.scm index fe0a008f..9c5fd439 100644 --- a/module/mes/as-i386.scm +++ b/module/mes/as-i386.scm @@ -120,14 +120,20 @@ ;; long jump i386:Xjump - i386:Xjump - i386:Xjump-c - i386:Xjump-cz + ;;i386:Xjump-c + ;;i386:Xjump-cz i386:Xjump-nc i386:Xjump-ncz + i386:Xjump-nz i386:Xjump-z + i386:Xjump-g + i386:Xjump-ge + + ;; i386:Xjump-l + ;; i386:Xjump-le + i386:XXjump i386:accu+n diff --git a/scaffold/mini-mes.c b/scaffold/mini-mes.c index b2fc0b2a..0d8fdb94 100644 --- a/scaffold/mini-mes.c +++ b/scaffold/mini-mes.c @@ -1368,11 +1368,6 @@ less_p (SCM x) ///((name . "<") (arity . n)) while (x != cell_nil) { assert (TYPE (car (x)) == TNUMBER); -#if __MESC__ - //FIXME __GNUC__ - if (n == INT_MIN); - else -#endif if (VALUE (car (x)) <= n) return cell_f; n = VALUE (car (x)); x = cdr (x); diff --git a/scaffold/t.c b/scaffold/t.c index 1fd12f5c..cffa2ce7 100644 --- a/scaffold/t.c +++ b/scaffold/t.c @@ -177,6 +177,30 @@ read_test () int math_test () { + puts ("t: 0 < 0\n"); + if (0 < 0) return 1; + + puts ("t: 2 < 1\n"); + if (2 < 1) return 1; + + puts ("t: -1 < -2\n"); + if (-1 < -2) return 1; + + puts ("t: 0 < -1\n"); + if (0 < -1) return 1; + + puts ("t: 0 > 0\n"); + if (0 > 0) return 1; + + puts ("t: 1 > 2\n"); + if (1 > 2) return 1; + + puts ("t: -2 > -1\n"); + if (-2 > -1) return 1; + + puts ("t: -1 > 0\n"); + if (-1 > 0) return 1; + int i; puts ("t: 4/2="); i = 4 / 2; diff --git a/tests/scm.test b/tests/scm.test index e8b86827..2f444255 100755 --- a/tests/scm.test +++ b/tests/scm.test @@ -122,9 +122,8 @@ exit $? (pass-if-equal "iota 0" '() (iota 0)) -(if %mesc (display "***FIXME: MESCC skip iota -1") - (pass-if-equal "iota -1" - '() (iota -1))) +(pass-if-equal "iota -1" + '() (iota -1)) (pass-if "reverse" (sequal? (reverse '(1 2 3)) '(3 2 1)))