2017-04-02 10:29:09 +00:00
|
|
|
;;; -*-scheme-*-
|
|
|
|
|
|
|
|
;;; Mes --- Maxwell Equations of Software
|
|
|
|
;;; Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
|
|
|
;;;
|
|
|
|
;;; This file is part of Mes.
|
|
|
|
;;;
|
|
|
|
;;; Mes is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; Mes is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
2017-05-21 20:25:02 +00:00
|
|
|
;;; as-i386.mes defines i386 assembly
|
2017-04-02 10:29:09 +00:00
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(cond-expand
|
|
|
|
(guile-2)
|
|
|
|
(guile)
|
|
|
|
(mes
|
2017-06-11 11:11:40 +00:00
|
|
|
(mes-use-module (mes elf-util))))
|
2017-04-02 10:29:09 +00:00
|
|
|
|
|
|
|
(define (i386:function-preamble)
|
|
|
|
'(#x55 ; push %ebp
|
|
|
|
#x89 #xe5)) ; mov %esp,%ebp
|
|
|
|
|
|
|
|
;; (define (i386:function-locals)
|
|
|
|
;; '(#x83 #xec #x20)) ; sub $0x10,%esp -- 8 local vars
|
|
|
|
|
|
|
|
(define (i386:function-locals)
|
|
|
|
'(#x83 #xec #x40)) ; sub $0x10,%esp -- 16 local vars
|
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:push-label label)
|
|
|
|
`(#x68 ,label #f #f #F)) ; push $0x<o>
|
2017-04-02 10:29:09 +00:00
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:push-label-mem label)
|
|
|
|
`(#xa1 ,label #f #f #f ; mov 0x804a000,%eax
|
2017-04-02 10:29:09 +00:00
|
|
|
#x50)) ; push %eax
|
|
|
|
|
|
|
|
(define (i386:push-local n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: push-local: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#xff #x75 ,(- 0 (* 4 n)))) ; pushl 0x<n>(%ebp)
|
|
|
|
|
|
|
|
(define (i386:push-local-address n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: push-local-address: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x8d #x45 ,(- 0 (* 4 n)) ; lea 0x<n>(%ebp),%eax
|
|
|
|
#x50)) ; push %eax
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
(define (i386:push-byte-local-de-ref n)
|
|
|
|
(or n (error "invalid value: push-byte-local-de-ref: " n))
|
|
|
|
`(#x8b #x45 ,(- 0 (* 4 n)) ; mov -0x<n>(%ebp),%eax
|
|
|
|
#x0f #xb6 #x00 ; movzbl (%eax),%eax
|
|
|
|
#x50)) ; push %eax
|
|
|
|
|
|
|
|
(define (i386:push-byte-local-de-de-ref n)
|
|
|
|
(or n (error "invalid value: push-byte-local-de-de-ref: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x8b #x45 ,(- 0 (* 4 n)) ; mov -0x<n>(%ebp),%eax
|
2017-04-17 00:15:11 +00:00
|
|
|
#x8b #x00 ; mov (%eax),%eax
|
2017-04-02 10:29:09 +00:00
|
|
|
#x0f #xb6 #x00 ; movzbl (%eax),%eax
|
2017-04-17 00:15:11 +00:00
|
|
|
#x50))
|
|
|
|
|
|
|
|
(define (i386:push-local-de-ref n)
|
|
|
|
(or n (error "invalid value: push-byte-local-de-ref: " n))
|
|
|
|
`(#x8b #x45 ,(- 0 (* 4 n)) ; mov -0x<n>(%ebp),%eax
|
|
|
|
#x8b #x00 ; mov (%eax),%eax
|
2017-04-02 10:29:09 +00:00
|
|
|
#x50)) ; push %eax
|
|
|
|
|
|
|
|
(define (i386:pop-accu)
|
|
|
|
'(#x58)) ; pop %eax
|
|
|
|
|
|
|
|
(define (i386:push-accu)
|
|
|
|
'(#x50)) ; push %eax
|
|
|
|
|
|
|
|
(define (i386:pop-base)
|
2017-03-22 06:13:34 +00:00
|
|
|
'(#x5a)) ; pop %edx
|
2017-04-02 10:29:09 +00:00
|
|
|
|
|
|
|
(define (i386:push-base)
|
2017-03-22 06:13:34 +00:00
|
|
|
'(#x52)) ; push %edx
|
2017-04-02 10:29:09 +00:00
|
|
|
|
|
|
|
(define (i386:ret)
|
|
|
|
'(#xc9 ; leave
|
|
|
|
#xc3)) ; ret
|
|
|
|
|
|
|
|
(define (i386:accu->base)
|
|
|
|
'(#x89 #xc2)) ; mov %eax,%edx
|
|
|
|
|
|
|
|
(define (i386:accu->base-address)
|
|
|
|
'(#x89 #x02)) ; mov %eax,%(edx)
|
|
|
|
|
|
|
|
(define (i386:byte-accu->base-address)
|
|
|
|
'(#x88 #x02)) ; mov %al,%(edx)
|
|
|
|
|
|
|
|
(define (i386:accu->base-address+n n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: accu->base-address+n: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x89 #x42 ,n)) ; mov %eax,$0x<n>%(edx)
|
|
|
|
|
|
|
|
(define (i386:accu->local n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: accu->local: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x89 #x45 ,(- 0 (* 4 n)))) ; mov %eax,-<0xn>(%ebp)
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
;; (define (i386:accu->local-address n)
|
|
|
|
;; (or n (error "invalid value: accu->local: " n))
|
|
|
|
;; `(#x89 #x45 ,(- 0 (* 4 n)))) ; mov %eax,-<0xn>(%ebp)
|
|
|
|
|
2017-04-02 10:29:09 +00:00
|
|
|
(define (i386:base->local n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: base->local: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x89 #x55 ,(- 0 (* 4 n)))) ; mov %edx,-<0xn>(%ebp)
|
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:accu->label label)
|
|
|
|
`(#xa3 ,label #f #f #f))
|
2017-04-02 10:29:09 +00:00
|
|
|
|
|
|
|
(define (i386:accu-zero?)
|
|
|
|
'(#x85 #xc0)) ; cmpl %eax,%eax
|
|
|
|
|
|
|
|
(define (i386:accu-non-zero?)
|
|
|
|
(append '(#x85 #xc0) ; cmpl %eax,%eax
|
|
|
|
(i386:xor-zf)))
|
|
|
|
|
|
|
|
(define (i386:accu-shl n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: accu:shl n: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#xc1 #xe0 ,n)) ; shl $0x8,%eax
|
|
|
|
|
2017-03-24 21:32:02 +00:00
|
|
|
(define (i386:accu<<base)
|
|
|
|
'(#x31 #xc9 ; xor %ecx,%ecx
|
|
|
|
#x89 #xd1 ; mov %edx,%ecx
|
|
|
|
#xd3 #xe0)) ; shl %cl,%eax
|
|
|
|
|
2017-03-25 17:48:40 +00:00
|
|
|
(define (i386:accu>>base)
|
|
|
|
'(#x31 #xc9 ; xor %ecx,%ecx
|
|
|
|
#x89 #xd1 ; mov %edx,%ecx
|
|
|
|
#xd3 #xe8)) ; shr %cl,%eax
|
|
|
|
|
2017-03-24 22:15:01 +00:00
|
|
|
(define (i386:accu-or-base)
|
|
|
|
'(#x09 #xd0)) ; or %edx,%eax
|
|
|
|
|
2017-05-06 12:57:39 +00:00
|
|
|
(define (i386:accu-and-base)
|
|
|
|
'(#x21 #xd0)) ; and %edx,%eax
|
|
|
|
|
|
|
|
(define (i386:accu-xor-base)
|
|
|
|
'(#x31 #xd0)) ; and %edx,%eax
|
|
|
|
|
2017-04-02 10:29:09 +00:00
|
|
|
(define (i386:accu+accu)
|
|
|
|
'(#x01 #xc0)) ; add %eax,%eax
|
|
|
|
|
|
|
|
(define (i386:accu+base)
|
|
|
|
`(#x01 #xd0)) ; add %edx,%eax
|
|
|
|
|
|
|
|
(define (i386:accu+value v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or v (error "invalid value: accu+value: " v))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x05 ,@(int->bv32 v))) ; add %eax,%eax
|
|
|
|
|
|
|
|
(define (i386:accu-base)
|
|
|
|
`(#x29 #xd0)) ; sub %edx,%eax
|
|
|
|
|
mescc: Mini-mes (gcc-compiled) runs read-0.mes.
* module/language/c99/compiler.mes (expr->accu): Add mul.
(test->jump->info): Add le, ge.
(ast->info): Support int and char* initialization at top level.
* module/mes/as-i386.mes (i386:accu*base, i386:Xjump-cz,
i386:Xjump-ncz): New function.
* module/mes/as-i386.scm: Export them.
* doc/examples/t.c (test): Test them.
* module/mes/libc.mes (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
(libc): Export them.
* module/mes/mini-0.mes: Load full reader.
* mlibc.c (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
* mes.c (list length error lookup_ getchar ungetchar peekchar
peek_byte read_byte unread_byte greater_p less_p): Move functions
needed to run read-0.mes into core.
* doc/examples/mini-mes.c: Likewise.
* lib.c (length, error): Comment-out.
* math.c (greater_p, less_p): Comment-out.
* posix.c: (getchar, ungetchar, peekchar, peek_byte, read_byte,
unread_byte): Comment-out.
* reader.c (lookup_): Comment-out.
2017-03-22 05:39:24 +00:00
|
|
|
(define (i386:accu*base)
|
|
|
|
`(#xf7 #xe2)) ; mul %edx
|
|
|
|
|
2017-04-02 10:29:09 +00:00
|
|
|
(define (i386:accu/base)
|
|
|
|
'(#x86 #xd3 ; mov %edx,%ebx
|
|
|
|
#x31 #xd2 ; xor %edx,%edx
|
|
|
|
#xf7 #xf3)) ; div %ebx
|
|
|
|
|
|
|
|
(define (i386:accu%base)
|
|
|
|
'(#x86 #xd3 ; mov %edx,%ebx
|
|
|
|
#x31 #xd2 ; xor %edx,%edx
|
|
|
|
#xf7 #xf3 ; div %ebx
|
|
|
|
#x89 #xd0)) ; mov %edx,%eax
|
|
|
|
|
|
|
|
(define (i386:base->accu)
|
|
|
|
'(#x89 #xd0)) ; mov %edx,%eax
|
|
|
|
|
|
|
|
(define (i386:local->accu n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: local->accu: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x8b #x45 ,(- 0 (* 4 n)))) ; mov -<0xn>(%ebp),%eax
|
|
|
|
|
|
|
|
(define (i386:local-address->accu n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: ladd: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x8d #x45 ,(- 0 (* 4 n)))) ; lea 0x<n>(%ebp),%eax
|
|
|
|
|
|
|
|
(define (i386:local-ptr->accu n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: local-ptr->accu: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x89 #xe8 ; mov %ebp,%eax
|
|
|
|
#x83 #xc0 ,(- 0 (* 4 n)))) ; add $0x<n>,%eax
|
|
|
|
|
|
|
|
(define (i386:byte-local->accu n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: byte-local->accu: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x0f #xb6 #x45 ,(- 0 (* 4 n)))) ; movzbl 0x<n>(%ebp),%eax
|
|
|
|
|
2017-04-12 19:27:59 +00:00
|
|
|
(define (i386:byte-local->base n)
|
|
|
|
(or n (error "invalid value: byte-local->base: " n))
|
2017-04-17 00:15:11 +00:00
|
|
|
`(#x0f #xb6 #x55 ,(- 0 (* 4 n)))) ; movzbl 0x<n>(%ebp),%edx
|
2017-04-12 19:27:59 +00:00
|
|
|
|
2017-04-02 10:29:09 +00:00
|
|
|
(define (i386:local->base n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: local->base: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x8b #x55 ,(- 0 (* 4 n)))) ; mov -<0xn>(%ebp),%edx
|
|
|
|
|
|
|
|
(define (i386:local-address->base n) ;; DE-REF
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: local-address->base: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x8d #x55 ,(- 0 (* 4 n)))) ; lea 0x<n>(%ebp),%edx
|
|
|
|
|
|
|
|
(define (i386:local-ptr->base n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: local-ptr->base: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x89 #xea ; mov %ebp,%edx
|
|
|
|
#x83 #xc2 ,(- 0 (* 4 n)))) ; add $0x<n>,%edx
|
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:label->accu label)
|
|
|
|
`(#xb8 ,label #f #f #f)) ; mov $<>,%eax
|
|
|
|
|
|
|
|
(define (i386:label->base label)
|
|
|
|
`(#xba ,label #f #f #f)) ; mov $<n>,%edx
|
|
|
|
|
|
|
|
(define (i386:label-mem->accu label)
|
|
|
|
`(#xa1 ,label #f #f #f)) ; mov 0x<n>,%eax
|
2017-04-02 10:29:09 +00:00
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:label-mem->base label)
|
|
|
|
`(#x8b #x15 ,label #f #f #f)) ; mov 0x<n>,%edx
|
2017-04-02 10:29:09 +00:00
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:label-mem-add label v)
|
|
|
|
`(#x83 #x05 ,label #f #f #f ,v)) ; addl $<v>,0x<n>
|
2017-04-02 10:29:09 +00:00
|
|
|
|
|
|
|
(define (i386:byte-base-mem->accu)
|
|
|
|
'(#x01 #xd0 ; add %edx,%eax
|
|
|
|
#x0f #xb6 #x00)) ; movzbl (%eax),%eax
|
|
|
|
|
|
|
|
(define (i386:byte-mem->accu)
|
|
|
|
'(#x0f #xb6 #x00)) ; movzbl (%eax),%eax
|
|
|
|
|
|
|
|
(define (i386:byte-mem->base)
|
|
|
|
'(#x0f #xb6 #x10)) ; movzbl (%eax),%edx
|
|
|
|
|
|
|
|
(define (i386:base-mem->accu)
|
|
|
|
'(#x01 #xd0 ; add %edx,%eax
|
|
|
|
#x8b #x00)) ; mov (%eax),%eax
|
|
|
|
|
|
|
|
(define (i386:mem->accu)
|
|
|
|
'(#x8b #x00)) ; mov (%eax),%eax
|
|
|
|
|
|
|
|
(define (i386:mem+n->accu n)
|
|
|
|
`(#x8b #x40 ,n)) ; mov 0x<n>(%eax),%eax
|
|
|
|
|
|
|
|
(define (i386:base-mem+n->accu n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: base-mem+n->accu: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x01 #xd0 ; add %edx,%eax
|
|
|
|
#x8b #x40 ,n)) ; mov <n>(%eax),%eax
|
|
|
|
|
|
|
|
(define (i386:value->accu v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or v (error "invalid value: i386:value->accu: " v))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#xb8 ,@(int->bv32 v))) ; mov $<v>,%eax
|
|
|
|
|
|
|
|
(define (i386:value->accu-address v)
|
|
|
|
`(#xc7 #x00 ,@(int->bv32 v))) ; movl $0x<v>,(%eax)
|
|
|
|
|
|
|
|
(define (i386:value->accu-address+n n v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or v (error "invalid value: i386:value->accu-address+n: " v))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#xc7 #x40 ,n ,@(int->bv32 v))) ; movl $<v>,0x<n>(%eax)
|
|
|
|
|
|
|
|
(define (i386:base->accu-address)
|
|
|
|
'(#x89 #x10)) ; mov %edx,(%eax)
|
|
|
|
|
|
|
|
(define (i386:base-address->accu-address)
|
|
|
|
'(#x8b #x0a ; mov (%edx),%ecx
|
|
|
|
#x89 #x08)) ; mov %ecx,(%eax)
|
|
|
|
|
|
|
|
(define (i386:accu+n n)
|
|
|
|
`(#x83 #xc0 ,n)) ; add $0x00,%eax
|
|
|
|
|
|
|
|
(define (i386:base+n n)
|
|
|
|
`(#x83 #xc2 ,n)) ; add $0x00,%edx
|
|
|
|
|
|
|
|
(define (i386:byte-base->accu-address)
|
|
|
|
'(#x88 #x10)) ; mov %dl,(%eax)
|
|
|
|
|
|
|
|
(define (i386:byte-base->accu-address+n n)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: byte-base->accu-address+n: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x88 #x50 ,n)) ; mov %dl,0x<n>(%eax)
|
|
|
|
|
|
|
|
(define (i386:value->base v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or v (error "invalid value: i386:value->base: " v))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#xba ,@(int->bv32 v))) ; mov $<v>,%edx
|
|
|
|
|
|
|
|
(define (i386:local-add n v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: i386:local-add: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x83 #x45 ,(- 0 (* 4 n)) ,v)) ; addl $<v>,0x<n>(%ebp)
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
(define (i386:accu-mem-add v)
|
|
|
|
`(#x83 #x00 ,v)) ; addl $<v>,(%eax)
|
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:value->label label v)
|
|
|
|
(or v (error "invalid value: value->label: " v))
|
|
|
|
`(#xc7 #x05 ,label #f #f #f ; movl $<v>,(<n>)
|
2017-04-02 10:29:09 +00:00
|
|
|
,@(int->bv32 v)))
|
|
|
|
|
|
|
|
(define (i386:value->local n v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: value->local: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#xc7 #x45 ,(- 0 (* 4 n)) ; movl $<v>,0x<n>(%ebp)
|
|
|
|
,@(int->bv32 v)))
|
|
|
|
|
|
|
|
(define (i386:local-test n v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or n (error "invalid value: local-test: " n))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x83 #x7d ,(- 0 (* 4 n)) ,v)) ; cmpl $<v>,0x<n>(%ebp)
|
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:call-label label n)
|
|
|
|
`(#xe8 ,label #f #f #f ; call relative $00
|
2017-04-02 10:29:09 +00:00
|
|
|
#x83 #xc4 ,(* n 4))) ; add $00,%esp
|
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:call-accu n)
|
2017-04-02 10:29:09 +00:00
|
|
|
`(,@(i386:push-accu)
|
|
|
|
,@(i386:pop-accu)
|
|
|
|
#xff #xd0 ; call *%eax
|
|
|
|
#x83 #xc4 ,(* n 4))) ; add $00,%esp
|
|
|
|
|
|
|
|
(define (i386:accu-not)
|
|
|
|
`(#x0f #x94 #xc0 ; sete %al
|
|
|
|
#x0f #xb6 #xc0)) ; movzbl %al,%eax
|
|
|
|
|
|
|
|
(define (i386:xor-accu v)
|
2017-04-12 19:27:59 +00:00
|
|
|
(or v (error "invalid value: i386:xor-accu: n: " v))
|
2017-04-02 10:29:09 +00:00
|
|
|
`(#x35 ,@(int->bv32 v))) ;xor $0xff,%eax
|
|
|
|
|
|
|
|
(define (i386:xor-zf)
|
|
|
|
'(#x9f ; lahf
|
|
|
|
#x80 #xf4 #x40 ; xor $0x40,%ah
|
|
|
|
#x9e)) ; sahf
|
|
|
|
|
|
|
|
(define (i386:accu-cmp-value v)
|
|
|
|
`(#x83 #xf8 ,v)) ; cmp $<v>,%eax
|
|
|
|
|
|
|
|
(define (i386:accu-test)
|
|
|
|
'(#x85 #xc0)) ; test %eax,%eax
|
|
|
|
|
2017-06-11 11:11:40 +00:00
|
|
|
(define (i386:jump-label label)
|
|
|
|
`(#xe9 ,label #f #f #f)) ; jmp . + <n>
|
|
|
|
|
2017-06-12 19:00:50 +00:00
|
|
|
(define (i386:jump-label-z label)
|
|
|
|
`(#x0f #x84 ,label #f #f #f)) ; jz . + <n>
|
|
|
|
|
|
|
|
(define (i386:jump-label-byte-z label)
|
|
|
|
`(#x84 #xc0 ; test %al,%al
|
|
|
|
#x74 ,label)) ; jne <n>
|
|
|
|
|
|
|
|
;; signed
|
|
|
|
(define (i386:jump-label-g label)
|
|
|
|
`(#x0f #x8f ,label #f #f #f)) ; jg/jnle <n>
|
|
|
|
|
|
|
|
;; signed
|
|
|
|
(define (i386:jump-label-ge label)
|
|
|
|
`(#x0f #x8d ,label #f #f #f)) ; jge/jnl <n>
|
|
|
|
|
|
|
|
(define (i386:jump-label-nz label)
|
|
|
|
`(#x0f #x85 ,label #f #f #f)) ; jnz . + <n>
|
|
|
|
|
|
|
|
(define (i386:jump-label-z label)
|
|
|
|
`(#x0f #x84 ,label #f #f #f)) ; jz . + <n>
|
|
|
|
|
2017-04-02 10:29:09 +00:00
|
|
|
(define (i386:byte-test-base)
|
|
|
|
`(#x38 #xc2)) ; cmp %al,%dl
|
|
|
|
|
|
|
|
(define (i386:test-base)
|
|
|
|
`(#x39 #xd0)) ; cmp %edx,%eax
|
|
|
|
|
|
|
|
(define (i386:byte-sub-base)
|
|
|
|
`(#x28 #xd0)) ; sub %dl,%al
|
|
|
|
|
|
|
|
(define (i386:byte-base-sub)
|
|
|
|
`(#x28 #xd0)) ; sub %al,%dl
|
|
|
|
|
|
|
|
(define (i386:sub-base)
|
|
|
|
`(#x29 #xd0)) ; sub %edx,%eax
|
|
|
|
|
|
|
|
(define (i386:base-sub)
|
|
|
|
`(#x29 #xc2)) ; sub %eax,%edx
|
|
|
|
|
2017-05-06 15:30:14 +00:00
|
|
|
(define (i386:nz->accu)
|
|
|
|
'(#x0f #x95 #xc0 ; setne %al
|
|
|
|
#x0f #xb6 #xc0)) ; movzbl %al,%eax
|
|
|
|
|
|
|
|
(define (i386:z->accu)
|
|
|
|
'(#x0f #x94 #xc0 ; sete %al
|
|
|
|
#x0f #xb6 #xc0)) ; movzbl %al,%eax
|
|
|
|
|
|
|
|
(define (i386:accu<->stack)
|
|
|
|
'(#x87 #x04 #x24)) ; xchg %eax,(%esp)
|
|
|
|
|