mescc: Lshift support non-fixed shift value.
* module/mes/as-i386.mes (i386:accu<<base): New function. * module/mes/as-i386.scm: Export it. * module/language/c99/compiler.mes (expr->accu): Use it. * scaffold/t.c (math_test): Test it.
This commit is contained in:
parent
ce55c198c0
commit
ca633abdda
|
@ -761,15 +761,27 @@
|
|||
(list (lambda (f g ta t d)
|
||||
(i386:accu-base)))))))
|
||||
|
||||
((lshift ,a (p-expr (fixed ,value)))
|
||||
((bitwise-or ,a ,b)
|
||||
(let* ((empty (clone info #:text '()))
|
||||
(accu ((expr->accu empty) a))
|
||||
(value (cstring->number value)))
|
||||
(base ((expr->base empty) b)))
|
||||
(clone info #:text
|
||||
(append text
|
||||
(.text accu)
|
||||
(.text base)
|
||||
(list (lambda (f g ta t d)
|
||||
(i386:accu-shl value)))))))
|
||||
(i386:accu-or-base)))))))
|
||||
|
||||
((lshift ,a ,b)
|
||||
(let* ((empty (clone info #:text '()))
|
||||
(accu ((expr->accu empty) a))
|
||||
(base ((expr->base empty) b)))
|
||||
(clone info #:text
|
||||
(append text
|
||||
(.text accu)
|
||||
(.text base)
|
||||
(list (lambda (f g ta t d)
|
||||
(i386:accu<<base)))))))
|
||||
|
||||
((div ,a ,b)
|
||||
(let* ((empty (clone info #:text '()))
|
||||
|
|
|
@ -126,6 +126,11 @@
|
|||
(or n accu:shl n)
|
||||
`(#xc1 #xe0 ,n)) ; shl $0x8,%eax
|
||||
|
||||
(define (i386:accu<<base)
|
||||
'(#x31 #xc9 ; xor %ecx,%ecx
|
||||
#x89 #xd1 ; mov %edx,%ecx
|
||||
#xd3 #xe0)) ; shl %cl,%eax
|
||||
|
||||
(define (i386:accu+accu)
|
||||
'(#x01 #xc0)) ; add %eax,%eax
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
i386:accu*base
|
||||
i386:accu-base
|
||||
i386:accu-shl
|
||||
i386:accu<<base
|
||||
i386:base-sub
|
||||
i386:base->accu
|
||||
i386:base->accu-address
|
||||
|
|
|
@ -212,6 +212,13 @@ math_test ()
|
|||
puts ("t: 3*4=");
|
||||
i = 3 * 4;
|
||||
if (i!=12) return 1;
|
||||
|
||||
puts ("t: 1 << 3\n");
|
||||
if (1 << 3 != 8) return 1 << 3;
|
||||
|
||||
puts ("t: 3 << 4\n");
|
||||
if (3 << 4 != 48) return 3 << 4;
|
||||
|
||||
return read_test ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue