environment
(let ((mnemonic (cadr form))
(opcode (caddr form))
- (digit (cadddr form))
- (signed-prefix (car (cddddr form)))
- (unsigned-prefix (cadr (cddddr form))))
- (define (signed suffix)
- (symbol signed-prefix '- suffix))
- (define (unsigned suffix)
- (symbol unsigned-prefix '- suffix))
+ (digit (cadddr form)))
`(define-instruction ,mnemonic
((B (? target r/m-ea) (R (? source)))
(PREFIX (ModR/M source target))
(BITS (8 ,(+ opcode 2)))
(ModR/M target source))
- ((B (R 0) (& (? value ,(signed 'BYTE)))) ;AL
+ ((B (R 0) (& (? value sign-extended-byte))) ;AL
(BITS (8 ,(+ opcode 4))
(8 value SIGNED)))
- ((B (R 0) (&U (? value ,(unsigned 'BYTE)))) ;AL
+ ((B (R 0) (&U (? value zero-extended-byte))) ;AL
(BITS (8 ,(+ opcode 4))
- (8 value UNSIGNED)))
+ (8 value SIGNED)))
- ((B (? target r/m-ea) (& (? value ,(signed 'BYTE))))
+ ((B (? target r/m-ea) (& (? value sign-extended-byte)))
(PREFIX (ModR/M target))
(BITS (8 #x80))
(ModR/M ,digit target)
(BITS (8 value SIGNED)))
- ((B (? target r/m-ea) (&U (? value ,(unsigned 'BYTE))))
+ ((B (? target r/m-ea) (&U (? value zero-extended-byte)))
(PREFIX (ModR/M target))
(BITS (8 #x80))
(ModR/M ,digit target)
- (BITS (8 value UNSIGNED)))
+ (BITS (8 value SIGNED)))
- ((W (R 0) (& (? value ,(signed 'WORD))))
+ ((W (R 0) (& (? value sign-extended-word)))
(PREFIX (OPERAND 'W))
(BITS (8 ,(+ opcode 5))
(16 value SIGNED)))
- ((W (R 0) (&U (? value ,(unsigned 'WORD))))
+ ((W (R 0) (&U (? value zero-extended-word)))
(PREFIX (OPERAND 'W))
(BITS (8 ,(+ opcode 5))
- (16 value UNSIGNED)))
+ (16 value SIGNED)))
- (((? size operand-size) (R 0) (& (? value ,(signed 'LONG))))
+ (((? size operand-size) (R 0) (& (? value sign-extended-long)))
(PREFIX (OPERAND size))
(BITS (8 ,(+ opcode 5))
(32 value SIGNED)))
- (((? size operand-size) (R 0) (&U (? value ,(unsigned 'LONG))))
+ (((? size operand-size) (R 0) (&U (? value zero-extended-long)))
(PREFIX (OPERAND size))
(BITS (8 ,(+ opcode 5))
- (32 value UNSIGNED)))
+ (32 value SIGNED)))
\f
(((? size operand-size) (? target r/m-ea) (R (? source)))
(PREFIX (OPERAND size) (ModR/M source target))
(((? size operand-size)
(? target r/m-ea)
- (& (? value ,(signed 'BYTE))))
+ (& (? value sign-extended-byte)))
(PREFIX (OPERAND size) (ModR/M target))
(BITS (8 #x83))
(ModR/M ,digit target)
(((? size operand-size)
(? target r/m-ea)
- (&U (? value ,(unsigned 'BYTE))))
+ (&U (? value zero-extended-byte)))
(PREFIX (OPERAND size) (ModR/M target))
(BITS (8 #x83))
(ModR/M ,digit target)
- (BITS (8 value UNSIGNED)))
+ (BITS (8 value SIGNED)))
- ((W (? target r/m-ea) (& (? value ,(signed 'WORD))))
+ ((W (? target r/m-ea) (& (? value sign-extended-word)))
(PREFIX (OPERAND 'W) (ModR/M target))
(BITS (8 #x81))
(ModR/M ,digit target)
(BITS (16 value SIGNED)))
- ((W (? target r/m-ea) (&U (? value ,(unsigned 'WORD))))
+ ((W (? target r/m-ea) (&U (? value zero-extended-word)))
(PREFIX (OPERAND 'W) (ModR/M target))
(BITS (8 #x81))
(ModR/M ,digit target)
- (BITS (16 value UNSIGNED)))
+ (BITS (16 value SIGNED)))
(((? size operand-size)
(? target r/m-ea)
- (& (? value ,(signed 'LONG))))
+ (& (? value sign-extended-long)))
(PREFIX (OPERAND size) (ModR/M target))
(BITS (8 #x81))
(ModR/M ,digit target)
(((? size operand-size)
(? target r/m-ea)
- (&U (? value ,(unsigned 'LONG))))
+ (&U (? value zero-extended-long)))
(PREFIX (OPERAND size) (ModR/M target))
(BITS (8 #x81))
(ModR/M ,digit target)
- (BITS (32 value UNSIGNED)))))))))
-
- (define-arithmetic-instruction ADC #x10 2 SIGN-EXTENDED ZERO-EXTENDED)
- (define-arithmetic-instruction ADD #x00 0 SIGN-EXTENDED ZERO-EXTENDED)
- (define-arithmetic-instruction AND #x20 4 SIGNED UNSIGNED)
- (define-arithmetic-instruction CMP #x38 7 SIGN-EXTENDED ZERO-EXTENDED)
- (define-arithmetic-instruction OR #x08 1 SIGNED UNSIGNED)
- (define-arithmetic-instruction SBB #x18 3 SIGN-EXTENDED ZERO-EXTENDED)
- (define-arithmetic-instruction SUB #x28 5 SIGN-EXTENDED ZERO-EXTENDED)
- (define-arithmetic-instruction XOR #x30 6 SIGNED UNSIGNED))
+ (BITS (32 value SIGNED)))))))))
+
+ (define-arithmetic-instruction ADC #x10 2)
+ (define-arithmetic-instruction ADD #x00 0)
+ (define-arithmetic-instruction AND #x20 4)
+ (define-arithmetic-instruction CMP #x38 7)
+ (define-arithmetic-instruction OR #x08 1)
+ (define-arithmetic-instruction SBB #x18 3)
+ (define-arithmetic-instruction SUB #x28 5)
+ (define-arithmetic-instruction XOR #x30 6))
\f
(define-instruction BSF
(((? size operand-size) (R (? target)) (? source r/m-ea))
`(define-instruction ,mnemonic
(((? size operand-size) (? target r/m-ea)
- (& (? posn unsigned-byte)))
+ (&U (? posn unsigned-byte)))
(PREFIX (OPERAND size) (ModR/M target))
(BITS (8 #x0f)
(8 #xba))
(ModR/M ,digit target)
- (BITS (8 posn)))
+ (BITS (8 posn UNSIGNED)))
(((? target r/m-ea) (R (? posn)))
(PREFIX (ModR/M posn target))
(define-mul/div MUL 4))
(define-instruction ENTER
- (((& (? frame-size unsigned-word)) (& (? lexical-level unsigned-byte)))
+ (((&U (? frame-size unsigned-word)) (&U (? lexical-level unsigned-byte)))
(BITS (8 #xc8)
- (16 frame-size)
- (8 lexical-level))))
+ (16 frame-size UNSIGNED)
+ (8 lexical-level UNSIGNED))))
(define-trivial-instruction HLT #xf4)
\f
(BITS (32 multiplier SIGNED))))
\f
(define-instruction IN
- ((B (R 0) (& (? port unsigned-byte)))
+ ((B (R 0) (&U (? port unsigned-byte)))
(BITS (8 #xe4)
- (8 port)))
+ (8 port UNSIGNED)))
((B (R 0) (R 2))
(BITS (8 #xec)))
- ((W (R 0) (& (? port unsigned-byte)))
+ ((W (R 0) (&U (? port unsigned-byte)))
(PREFIX (OPERAND 'W))
(BITS (8 #xe5)
- (8 port)))
+ (8 port UNSIGNED)))
((W (R 0) (R 2))
(PREFIX (OPERAND 'W))
(BITS (8 #xed)))
- ((L (R 0) (& (? port unsigned-byte)))
+ ((L (R 0) (&U (? port unsigned-byte)))
(BITS (8 #xe5)
- (8 port)))
+ (8 port UNSIGNED)))
((L (R 0) (R 2))
(BITS (8 #xed))))
((3)
(BITS (8 #xcc)))
- (((& (? vector unsigned-byte)))
+ (((&U (? vector unsigned-byte)))
(BITS (8 #xcd)
- (8 vector))))
+ (8 vector UNSIGNED))))
(define-trivial-instruction INVD #x0f #x08) ; 486 only
(define-trivial-instruction IRET #xcf)
(8 ,near-opcode)
(32 `(- ,dest (+ *PC* 4)) SIGNED)))
- ((B (@PCO (? displ)))
+ ((B (@PCO (? displ signed-byte)))
(BITS (8 ,short-opcode)
(8 displ SIGNED)))
- ((L (@PCO (? displ)))
+ ((L (@PCO (? displ signed-long)))
(BITS (8 #x0f)
(8 ,near-opcode)
(32 displ SIGNED)))))))))
(BITS (8 #xe9)
(32 `(- ,dest (+ *PC* 4)) SIGNED)))
- ((B (@PCO (? displ)))
+ ((B (@PCO (? displ signed-byte)))
(BITS (8 #xeb)
(8 displ SIGNED)))
- ((L (@PCO (? displ)))
+ ((L (@PCO (? displ signed-long)))
(BITS (8 #xe9)
(32 displ SIGNED))))
\f
(define-trivial-instruction NOP #x90)
(define-instruction OUT
- ((B (& (? port unsigned-byte)) (R 0))
+ ((B (&U (? port unsigned-byte)) (R 0))
(BITS (8 #xe6)
- (8 port)))
+ (8 port UNSIGNED)))
((B (R 2) (R 0))
(BITS (8 #xee)))
- (((? size operand-size) (& (? port unsigned-byte)) (R 0))
+ (((? size operand-size) (&U (? port unsigned-byte)) (R 0))
(PREFIX (OPERAND size))
(BITS (8 #xe7)
- (8 port)))
+ (8 port UNSIGNED)))
(((PREFIX (OPERAND size)) (R 2) (R 0))
(BITS (8 #xef))))
((Q (&U (? value zero-extended-byte))) ;No operand prefix.
(BITS (8 #x6a)
- (8 value UNSIGNED)))
+ (8 value SIGNED)))
((Q (& (? value sign-extended-long))) ;No operand prefix.
(BITS (8 #x68)
((Q (&U (? value zero-extended-long))) ;No operand prefix.
(BITS (8 #x68)
- (32 value UNSIGNED)))
+ (32 value SIGNED)))
((W (? source m-ea))
(PREFIX (OPERAND 'W) (ModR/M source))
(BITS (8 #x0f)
(8 ,opcode))
(ModR/M target source)
- (BITS (8 count)))
+ (BITS (8 count UNSIGNED)))
(((? size operand-size) (? target r/m-ea)
(R (? source))
(((&U (? frame-size unsigned-word)))
(BITS (8 #xc2)
- (16 frame-size)))
+ (16 frame-size UNSIGNED)))
((F (&U (? frame-size unsigned-word)))
(BITS (8 #xca)
- (16 frame-size))))
+ (16 frame-size UNSIGNED))))
(define-trivial-instruction SAHF #x9e)
(BITS (8 #xa9)
(16 value SIGNED)))
- (((? size operand-size) (R 0) (& (? value signed-long)))
- (PREFIX (OPERAND size))
+ ((L (R 0) (& (? value signed-long)))
+ (PREFIX (OPERAND 'L))
+ (BITS (8 #xa9)
+ (32 value SIGNED)))
+
+ ((Q (R 0) (& (? value sign-extended-long)))
+ (PREFIX (OPERAND 'Q))
(BITS (8 #xa9)
(32 value SIGNED)))
(BITS (8 #xa9)
(16 value UNSIGNED)))
- (((? size operand-size) (R 0) (&U (? value unsigned-long)))
- (PREFIX (OPERAND size))
+ ((L (R 0) (&U (? value unsigned-long)))
+ (PREFIX (OPERAND 'L))
(BITS (8 #xa9)
(32 value UNSIGNED)))
+ ((Q (R 0) (&U (? value zero-extended-long)))
+ (PREFIX (OPERAND 'Q))
+ (BITS (8 #xa9)
+ (32 value SIGNED)))
+\f
((B (? operand r/m-ea) (& (? value signed-byte)))
(PREFIX (ModR/M operand))
(BITS (8 #xf6))
(ModR/M 0 operand)
(BITS (16 value SIGNED)))
- (((? size operand-size) (? operand r/m-ea) (& (? value signed-long)))
- (PREFIX (OPERAND size) (ModR/M operand))
+ ((L (? operand r/m-ea) (& (? value signed-long)))
+ (PREFIX (OPERAND 'L) (ModR/M operand))
+ (BITS (8 #xf7))
+ (ModR/M 0 operand)
+ (BITS (32 value SIGNED)))
+
+ ((Q (? operand r/m-ea) (& (? value sign-extended-long)))
+ (PREFIX (OPERAND 'Q) (ModR/M operand))
(BITS (8 #xf7))
(ModR/M 0 operand)
(BITS (32 value SIGNED)))
(ModR/M 0 operand)
(BITS (16 value UNSIGNED)))
- (((? size operand-size) (? operand r/m-ea) (&U (? value unsigned-long)))
- (PREFIX (OPERAND size) (ModR/M operand))
+ ((L (? operand r/m-ea) (&U (? value unsigned-long)))
+ (PREFIX (OPERAND 'L) (ModR/M operand))
(BITS (8 #xf7))
(ModR/M 0 operand)
(BITS (32 value UNSIGNED)))
+ ((Q (? operand r/m-ea) (&U (? value zero-extended-long)))
+ (PREFIX (OPERAND 'Q) (ModR/M operand))
+ (BITS (8 #xf7))
+ (ModR/M 0 operand)
+ (BITS (32 value SIGNED)))
+
((B (? r/m r/m-ea) (R (? reg)))
(PREFIX (ModR/M reg r/m))
(BITS (8 #x84))