mescc: Support &, ^.
* module/mes/as-i386.mes (i386:accu-and-base, i386:accu-xor-base): New functions. * module/mes/as-i386.scm: Export them. * module/language/c99/compiler.mes (expr->accu): Support bitwise-and, bitwise-xor.
This commit is contained in:
parent
6272356959
commit
be6e30a8fa
|
@ -689,6 +689,8 @@
|
|||
((add ,a ,b) ((binop->accu info) a b (i386:accu+base)))
|
||||
((sub ,a ,b) ((binop->accu info) a b (i386:accu-base)))
|
||||
((bitwise-or ,a ,b) ((binop->accu info) a b (i386:accu-or-base)))
|
||||
((bitwise-and ,a ,b) ((binop->accu info) a b (i386:accu-and-base)))
|
||||
((bitwise-xor ,a ,b) ((binop->accu info) a b (i386:accu-xor-base)))
|
||||
((lshift ,a ,b) ((binop->accu info) a b (i386:accu<<base)))
|
||||
((rshift ,a ,b) ((binop->accu info) a b (i386:accu>>base)))
|
||||
((div ,a ,b) ((binop->accu info) a b (i386:accu/base)))
|
||||
|
@ -718,6 +720,30 @@
|
|||
((le ,a ,b) ((binop->accu info) b a (i386:base-sub)))
|
||||
((lt ,a ,b) ((binop->accu info) b a (i386:base-sub)))
|
||||
|
||||
((or ,a ,b)
|
||||
(let* ((empty (clone info #:text '()))
|
||||
(b-length (length (append (i386:Xjump-nz 0)
|
||||
(i386:accu-test))))
|
||||
(info ((expr->accu info) a))
|
||||
(info (append-text info (wrap-as (i386:accu-test))))
|
||||
(info (append-text info (wrap-as (append (i386:Xjump-nz (- b-length 1))
|
||||
(i386:accu-test)))))
|
||||
(info ((expr->accu info) b))
|
||||
(info (append-text info (wrap-as (i386:accu-test)))))
|
||||
info))
|
||||
|
||||
((and ,a ,b)
|
||||
(let* ((empty (clone info #:text '()))
|
||||
(b-length (length (append (i386:Xjump-z 0)
|
||||
(i386:accu-test))))
|
||||
(info ((expr->accu info) a))
|
||||
(info (append-text info (wrap-as (i386:accu-test))))
|
||||
(info (append-text info (wrap-as (append (i386:Xjump-z (- b-length 1))
|
||||
(i386:accu-test)))))
|
||||
(info ((expr->accu info) b))
|
||||
(info (append-text info (wrap-as (i386:accu-test)))))
|
||||
info))
|
||||
|
||||
((cast ,cast ,o)
|
||||
((expr->accu info) o))
|
||||
|
||||
|
|
|
@ -155,6 +155,12 @@
|
|||
(define (i386:accu-or-base)
|
||||
'(#x09 #xd0)) ; or %edx,%eax
|
||||
|
||||
(define (i386:accu-and-base)
|
||||
'(#x21 #xd0)) ; and %edx,%eax
|
||||
|
||||
(define (i386:accu-xor-base)
|
||||
'(#x31 #xd0)) ; and %edx,%eax
|
||||
|
||||
(define (i386:accu+accu)
|
||||
'(#x01 #xc0)) ; add %eax,%eax
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@
|
|||
i386:accu*base
|
||||
i386:accu-base
|
||||
i386:accu-shl
|
||||
i386:accu-and-base
|
||||
i386:accu-or-base
|
||||
i386:accu-xor-base
|
||||
i386:accu<<base
|
||||
i386:accu>>base
|
||||
i386:base-sub
|
||||
|
|
|
@ -332,6 +332,15 @@ math_test ()
|
|||
puts ("t: -1 + 2\n");
|
||||
if (-1 + 2 != 1) return 1;
|
||||
|
||||
puts ("t: 1 & 3\n");
|
||||
if ((1 & 3) != 1) return 1;
|
||||
|
||||
puts ("t: 1 | 3\n");
|
||||
if ((1 | 2) != 3) return 1;
|
||||
|
||||
puts ("t: ^ 1 \n");
|
||||
if ((1 ^ 3) != 2) return 1;
|
||||
|
||||
return array_test (env);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue