Modified:
trunk/cc/lap.lisp
trunk/cc/test-cc.lisp
trunk/cc/x86-64-syntax.lisp
wiki/AssemblyX64J.wiki
wiki/AssemblyX64Overview.wiki
Log:
Support instruction jcxz/jecxz/jrcxz.
Modified: trunk/cc/lap.lisp
==============================================================================
--- trunk/cc/lap.lisp (original)
+++ trunk/cc/lap.lisp Fri Mar 6 15:22:26 2009
@@ -249,12 +249,13 @@
remaining)))
(defun size-prefix (op bits)
- "Handles operand/address-size override prefix o16 & o32. Returns nil
- if no prefix is needed, otherwise corresponding prefix #x66 or #x67."
+ "Handles operand/address-size override prefix o16/o32 and
+ a16/a32. Returns nil if no prefix is needed, otherwise corresponding
+ prefix #x66 or #x67."
(let* ((s (str op))
(st (symb (subseq s 0 1)))
(sbit (read-from-string (subseq s 1 3))))
- (if (or (= sbit bits) (and (member bits '(32 64)) (member sbit '(32
64))))
+ (if (or (= sbit bits) (and (eq op 'o32) (member bits '(32 64))))
nil
(list (ecase st
(o #x66)
Modified: trunk/cc/test-cc.lisp
==============================================================================
--- trunk/cc/test-cc.lisp (original)
+++ trunk/cc/test-cc.lisp Fri Mar 6 15:22:26 2009
@@ -169,6 +169,7 @@
(int 3)
(int #x10)
.loop
+ (jcxz .loop)
(je .loop)
(jmp short .loop)
(lgdt (msg))
@@ -225,6 +226,8 @@
(cmpxchg8b (rbx))
(cmpxchg16b (rbx))
(jb near msg)
+ (jecxz msg)
+ (jrcxz msg)
(syscall)
(sysret)
(xadd cl dl)
@@ -255,18 +258,18 @@
"Miscellaneous instructions.")
(defparameter *misc-code*
- '(232 179 0 248 252 250 244 228 3 229 4 236 237 204 205 16 116 254
- 235 252 15 1 22 182 124 15 1 30 182 124 15 0 210 15 0 22 182 124
- 172 173 226 230 180 9 187 13 0 137 200 137 30 182 124 139 14 123
- 28 199 6 182 124 123 0 142 195 140 200 144 230 3 231 4 238 239 81
- 14 22 30 6 90 23 31 7 243 164 243 165 243 102 165 195 249 253 251
- 170 171 15 203 72 15 200 73 15 202 102 15 71 195 15 66 194 73 15
- 68 210 15 176 209 102 15 177 209 15 177 215 76 15 177 209 15 199
- 11 72 15 199 11 15 130 40 0 0 0 15 5 15 7 15 192 209 102 15 193
- 209 15 193 215 76 15 193 209 102 147 102 145 147 145 72 147 72 145
- 134 200 102 135 217 135 218 77 135 250 182 124 72 101 108 108 111
- 32 87 111 114 108 100 33 32 0 0 0 85 170 64 226 1 0 67 104 120 0 0
- 0 230 130 217 250 11 0))
+ '(232 186 0 248 252 250 244 228 3 229 4 236 237 204 205 16 227 254
+ 116 252 235 250 15 1 22 189 124 15 1 30 189 124 15 0 210 15 0 22
+ 189 124 172 173 226 228 180 9 187 13 0 137 200 137 30 189 124 139
+ 14 123 28 199 6 189 124 123 0 142 195 140 200 144 230 3 231 4 238
+ 239 81 14 22 30 6 90 23 31 7 243 164 243 165 243 102 165 195 249
+ 253 251 170 171 15 203 72 15 200 73 15 202 102 15 71 195 15 66 194
+ 73 15 68 210 15 176 209 102 15 177 209 15 177 215 76 15 177 209 15
+ 199 11 72 15 199 11 15 130 45 0 0 0 103 227 42 227 40 15 5 15 7 15
+ 192 209 102 15 193 209 15 193 215 76 15 193 209 102 147 102 145
+ 147 145 72 147 72 145 134 200 102 135 217 135 218 77 135 250 189
+ 124 72 101 108 108 111 32 87 111 114 108 100 33 32 0 0 0 85 170 64
+ 226 1 0 67 104 120 0 0 0 230 130 217 250 11 0))
(defparameter *address-asm*
'((org #x7c00)
Modified: trunk/cc/x86-64-syntax.lisp
==============================================================================
--- trunk/cc/x86-64-syntax.lisp (original)
+++ trunk/cc/x86-64-syntax.lisp Fri Mar 6 15:22:26 2009
@@ -121,9 +121,10 @@
((inc dword m) . (o32 #xff /0))
((int 3) . (#xcc))
((int imm8) . (#xcd ib))
- ((jcc (imm8 label imm16)) . ((+ #x70 cc) rb))
- ((jcc near (imm32 label imm8 imm16)) . (#x0f (+ #x80 cc) rd))
- ((jmp short (imm8 label imm16)) . (#xeb rb))
+ ((jcc (imm8 label imm16 imm32 imm64)) . ((+ #x70 cc) rb))
+ ((jcc near (imm32 label imm8 imm16 imm64)) . (#x0f (+ #x80 cc) rd))
+ ((jecxz (imm8 label imm16 imm32 imm64)) . (a32 #xe3 rb))
+ ((jmp short (imm8 label imm16 imm32 imm64)) . (#xeb rb))
((lldt (r/m16 r16 m)) . (#x0f #x00 /2))
((lodsb) . (#xac))
((lodsw) . (#xad))
@@ -191,6 +192,7 @@
((dec r32) . (o32 (+ #x48 r)))
((inc r16) . (o16 (+ #x40 r)))
((inc r32) . (o32 (+ #x40 r)))
+ ((jcxz (imm8 label imm16 imm32 imm64)) . (a16 #xe3 rb))
((lgdt m) . (#x0f #x01 /2))
((lidt m) . (#x0f #x01 /3))
((pop ss) . (#x17))
@@ -215,6 +217,7 @@
((dec qword m) . (#xff /1))
((inc (r/m64 r64)) . (#xff /0))
((inc qword m) . (#xff /0))
+ ((jrcxz (imm8 label imm16 imm32 imm64)) . (#xe3 rb))
,@(arith-syntax-1 'or t)
,@(arith-syntax-1 'sbb t)
,@(arith-syntax-1 'sub t)
Modified: wiki/AssemblyX64J.wiki
==============================================================================
--- wiki/AssemblyX64J.wiki (original)
+++ wiki/AssemblyX64J.wiki Fri Mar 6 15:22:26 2009
@@ -9,6 +9,9 @@
|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
|| jcc imm || (+ 70 cc) rb || Valid || Valid ||
Short conditional jump ||
|| jcc near imm || 0F (+ 80 cc) rd || Valid || Valid ||
Near conditional jump ||
+|| jcxz imm || a16 E3 rb || ~~N.E.~~ || Valid ||
Jump short if cx=0 ||
+|| jecxz imm || a32 E3 rb || Valid || Valid ||
Jump short if ecx=0 ||
+|| jrcxz imm || E3 rb || Valid || ~~N.E.~~ ||
Jump short if rcx=0 ||
Please refer [AssemblyX64Overview#Conditional_Codes conditional codes] for
details.
Modified: wiki/AssemblyX64Overview.wiki
==============================================================================
--- wiki/AssemblyX64Overview.wiki (original)
+++ wiki/AssemblyX64Overview.wiki Fri Mar 6 15:22:26 2009
@@ -70,7 +70,7 @@
* *rb, rw, rd, ro*: one of the operands is an immediate value, and the
_difference_ between this value and the end address of the instruction is
to be encoded as byte (rb), little-endian word (rw), little-endian
doubleword (rd), and little-endian quadword (ro) respectively.
* *ib, iw, id, io*: one of the operands is an immediate value, and it is
to be encoded as byte (rb), little-endian word (rw), little-endian
doubleword (rd), and little-endian quadword (ro) respectively.
* *o16, o32*: operand-size override prefix. o16 generates no code in
16-bit mode, but indicates a 66h prefix in 32/64-bit mode; similarly, o32
generates no code in 32/64-bit mode, but indicates a 66h prefix in 16-bit
mode.
- * *a16, a32*: address-size override prefix. a16 generates no code in
16-bit mode, but indicates a 67h prefix in 32/64-bit mode; similarly, a32
generates no code in 32/64-bit mode, but indicates a 67h prefix in 16-bit
mode.
+ * *a16, a32*: address-size override prefix. a16 generates no code in
16-bit mode, but indicates a 67h prefix in 32/64-bit mode; similarly, a32
generates no code in 32-bit mode, but indicates a 67h prefix in 16/64-bit
mode.
Note that REX prefix are not used in opcode notations. The prefix is
automatically generated by analyzing the operands.