[yalo commit] r140 - trunk/cc wiki

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 6, 2009, 6:27:04 PM3/6/09
to yalo-...@googlegroups.com
Author: yujian.zhang
Date: Fri Mar 6 15:22:51 2009
New Revision: 140

Modified:
trunk/cc/test-cc.lisp
trunk/cc/x86-64-syntax.lisp
wiki/AssemblyX64D.wiki
wiki/AssemblyX64M.wiki
wiki/AssemblyX64N.wiki

Log:
Complete instruction div/mul/neg/not.

Modified: trunk/cc/test-cc.lisp
==============================================================================
--- trunk/cc/test-cc.lisp (original)
+++ trunk/cc/test-cc.lisp Fri Mar 6 15:22:51 2009
@@ -109,9 +109,13 @@
(dec di)
(dec ecx)
(dec r10)
+ (div ebx)
(inc di)
(inc ecx)
(inc r10)
+ (mul dword (rbx))
+ (neg rcx)
+ (not qword (rbx))
(sbb rbx rdx)

(db msg "Hello World! ")
@@ -119,36 +123,37 @@
"Arithmetic instructions are tested separately.")

(defparameter *arith-code*
- '(4 8 5 232 3 128 195 3 128 6 72 126 4 129 195 210 4 129 6 72 126 46
- 22 131 193 9 131 6 72 126 12 0 216 0 46 72 126 1 217 1 22 72 126 2
- 46 72 126 3 22 72 126 36 8 37 232 3 128 227 3 128 38 72 126 4 129
- 227 210 4 129 38 72 126 46 22 131 225 9 131 38 72 126 12 32 216 32
- 46 72 126 33 217 33 22 72 126 34 46 72 126 35 22 72 126 60 8 61
- 232 3 128 251 3 128 62 72 126 4 129 251 210 4 129 62 72 126 46 22
- 131 249 9 131 62 72 126 12 56 216 56 46 72 126 57 217 57 22 72 126
- 58 46 72 126 59 22 72 126 75 102 72 254 202 254 14 72 126 255 74 3
- 102 255 14 72 126 246 245 246 54 72 126 247 247 247 114 3 67 102
- 64 254 194 254 6 72 126 255 66 3 102 255 6 72 126 246 229 246 38
- 72 126 247 231 247 98 3 246 221 246 30 72 126 247 223 247 90 3 246
- 213 246 22 72 126 247 215 247 82 3 12 8 13 232 3 128 203 3 128 14
- 72 126 4 129 203 210 4 129 14 72 126 46 22 131 201 9 131 14 72 126
- 12 8 216 8 46 72 126 9 217 9 22 72 126 10 46 72 126 11 22 72 126
- 208 230 208 38 72 126 210 230 210 38 72 126 192 230 5 192 38 72
- 126 5 209 226 209 38 72 126 211 226 211 38 72 126 193 226 5 193 38
- 72 126 5 208 238 208 46 72 126 210 238 210 46 72 126 192 238 5 192
- 46 72 126 5 209 234 209 46 72 126 211 234 211 46 72 126 193 234 5
- 193 46 72 126 5 44 8 45 232 3 128 235 3 128 46 72 126 4 129 235
- 210 4 129 46 72 126 46 22 131 233 9 131 46 72 126 12 40 216 40 46
- 72 126 41 217 41 22 72 126 42 46 72 126 43 22 72 126 168 8 169 232
- 3 246 195 3 246 6 72 126 4 247 195 210 4 247 6 72 126 46 22 132
- 216 132 46 72 126 133 217 133 22 72 126 52 8 53 232 3 128 243 3
- 128 54 72 126 4 129 243 210 4 129 54 72 126 46 22 131 241 9 131 54
- 72 126 12 48 216 48 46 72 126 49 217 49 22 72 126 50 46 72 126 51
- 22 72 126 102 5 232 3 102 74 77 102 66 69 72 21 69 35 1 0 129 195
+ '(4 8 5 232 3 128 195 3 128 6 82 126 4 129 195 210 4 129 6 82 126 46
+ 22 131 193 9 131 6 82 126 12 0 216 0 46 82 126 1 217 1 22 82 126 2
+ 46 82 126 3 22 82 126 36 8 37 232 3 128 227 3 128 38 82 126 4 129
+ 227 210 4 129 38 82 126 46 22 131 225 9 131 38 82 126 12 32 216 32
+ 46 82 126 33 217 33 22 82 126 34 46 82 126 35 22 82 126 60 8 61
+ 232 3 128 251 3 128 62 82 126 4 129 251 210 4 129 62 82 126 46 22
+ 131 249 9 131 62 82 126 12 56 216 56 46 82 126 57 217 57 22 82 126
+ 58 46 82 126 59 22 82 126 75 102 72 254 202 254 14 82 126 255 74 3
+ 102 255 14 82 126 246 245 246 54 82 126 247 247 247 114 3 67 102
+ 64 254 194 254 6 82 126 255 66 3 102 255 6 82 126 246 229 246 38
+ 82 126 247 231 247 98 3 246 221 246 30 82 126 247 223 247 90 3 246
+ 213 246 22 82 126 247 215 247 82 3 12 8 13 232 3 128 203 3 128 14
+ 82 126 4 129 203 210 4 129 14 82 126 46 22 131 201 9 131 14 82 126
+ 12 8 216 8 46 82 126 9 217 9 22 82 126 10 46 82 126 11 22 82 126
+ 208 230 208 38 82 126 210 230 210 38 82 126 192 230 5 192 38 82
+ 126 5 209 226 209 38 82 126 211 226 211 38 82 126 193 226 5 193 38
+ 82 126 5 208 238 208 46 82 126 210 238 210 46 82 126 192 238 5 192
+ 46 82 126 5 209 234 209 46 82 126 211 234 211 46 82 126 193 234 5
+ 193 46 82 126 5 44 8 45 232 3 128 235 3 128 46 82 126 4 129 235
+ 210 4 129 46 82 126 46 22 131 233 9 131 46 82 126 12 40 216 40 46
+ 82 126 41 217 41 22 82 126 42 46 82 126 43 22 82 126 168 8 169 232
+ 3 246 195 3 246 6 82 126 4 247 195 210 4 247 6 82 126 46 22 132
+ 216 132 46 82 126 133 217 133 22 82 126 52 8 53 232 3 128 243 3
+ 128 54 82 126 4 129 243 210 4 129 54 82 126 46 22 131 241 9 131 54
+ 82 126 12 48 216 48 46 82 126 49 217 49 22 82 126 50 46 82 126 51
+ 22 82 126 102 5 232 3 102 74 77 102 66 69 72 21 69 35 1 0 129 195
232 3 0 0 72 5 3 2 1 16 72 5 10 0 0 0 72 129 195 11 1 0 0 73 129
199 86 52 18 0 65 131 194 3 64 128 198 6 65 128 193 8 73 1 218 72
- 3 51 102 255 207 255 201 73 255 202 102 255 199 255 193 73 255 194
- 72 25 211 72 101 108 108 111 32 87 111 114 108 100 33 32))
+ 3 51 102 255 207 255 201 73 255 202 247 243 102 255 199 255 193 73
+ 255 194 247 35 72 247 217 72 247 19 72 25 211 72 101 108 108 111
+ 32 87 111 114 108 100 33 32))

(defparameter *misc-asm*
'((bits 16)

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:51 2009
@@ -50,14 +50,19 @@
((,mnemonic r16 (r/m16 r16 m)) . (o16 ,(+ base #x03) /r))
((,mnemonic r32 (r/m32 r32 m)) . (o32 ,(+ base #x03)
/r))))))

-(defun arith-syntax-2 (mnemonic)
+(defun arith-syntax-2 (mnemonic 64bit-only?)
"Return syntax table for arithmetic operations: div/mul/neg/not."
(let ((opcode (ecase mnemonic
(div '/6) (mul '/4) (neg '/3) (not '/2))))
- `(((,mnemonic (r/m8 r8)) . (#xf6 ,opcode))
- ((,mnemonic byte m) . (#xf6 ,opcode))
- ((,mnemonic (r/m16 r16)) . (#xf7 ,opcode))
- ((,mnemonic word m) . (#xf7 ,opcode)))))
+ (if 64bit-only?
+ `(((,mnemonic (r/m64 r64)) . (#xf7 ,opcode))
+ ((,mnemonic qword m) . (#xf7 ,opcode)))
+ `(((,mnemonic (r/m8 r8)) . (#xf6 ,opcode))
+ ((,mnemonic byte m) . (#xf6 ,opcode))
+ ((,mnemonic (r/m16 r16)) . (o16 #xf7 ,opcode))
+ ((,mnemonic word m) . (o16 #xf7 ,opcode))
+ ((,mnemonic (r/m32 r32)) . (o32 #xf7 ,opcode))
+ ((,mnemonic dword m) . (o32 #xf7 ,opcode))))))

(defun shift-syntax (mnemonic)
"Return syntax table for shift operations: shl/shr."
@@ -107,7 +112,7 @@
((dec word m) . (o16 #xff /1))
((dec (r/m32 r32)) . (o32 #xff /1))
((dec dword m) . (o32 #xff /1))
- ,@(arith-syntax-2 'div)
+ ,@(arith-syntax-2 'div nil)
((hlt) . (#xf4))
((in al imm8) . (#xe4 ib))
((in ax imm8) . (#xe5 ib))
@@ -143,10 +148,10 @@
((movsb) . (#xa4))
((movsw) . (o16 #xa5))
((movsd) . (o32 #xa5))
- ,@(arith-syntax-2 'mul)
- ,@(arith-syntax-2 'neg)
+ ,@(arith-syntax-2 'mul nil)
+ ,@(arith-syntax-2 'neg nil)
((nop) . (#x90))
- ,@(arith-syntax-2 'not)
+ ,@(arith-syntax-2 'not nil)
,@(arith-syntax-1 'or nil)
((out imm8 r8) . (#xe6 ib)) ; (out imm8 al)
((out imm8 r16) . (#xe7 ib)) ; (out imm8 ax)
@@ -215,9 +220,13 @@
,@(arith-syntax-1 'cmp t)
((dec (r/m64 r64)) . (#xff /1))
((dec qword m) . (#xff /1))
+ ,@(arith-syntax-2 'div t)
((inc (r/m64 r64)) . (#xff /0))
((inc qword m) . (#xff /0))
((jrcxz (imm8 label imm16 imm32 imm64)) . (#xe3 rb))
+ ,@(arith-syntax-2 'mul t)
+ ,@(arith-syntax-2 'neg t)
+ ,@(arith-syntax-2 'not t)
,@(arith-syntax-1 'or t)
,@(arith-syntax-1 'sbb t)
,@(arith-syntax-1 'sub t)

Modified: wiki/AssemblyX64D.wiki
==============================================================================
--- wiki/AssemblyX64D.wiki (original)
+++ wiki/AssemblyX64D.wiki Fri Mar 6 15:22:51 2009
@@ -18,7 +18,9 @@

= div: Unsigned Divide =

-|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
-|| div r/m8 || F6 /6 || Valid || Valid || Unsigned
divide ax by r/m8, al <- quot, ah <- rem ||
-|| div r/m16 || F7 /6 || Valid || Valid || Unsigned
divide dx:ax by r/m16, ax <- quot, dx <- rem ||
+|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
+|| div r/m8 || F6 /6 || Valid || Valid || Unsigned
divide ax by r/m8, al <- quot, ah <- rem ||
+|| div r/m16 || o16 F7 /6 || Valid || Valid || Unsigned
divide dx:ax by r/m16, ax <- quot, dx <- rem ||
+|| div r/m32 || o32 F7 /6 || Valid || Valid || Unsigned
divide edx:eax by r/m32, eax <- quot, edx <- rem ||
+|| div r/m64 || F7 /6 || Valid || ~~N.E.~~ || Unsigned
divide rdx:rax by r/m64, rax <- quot, rdx <- rem ||


Modified: wiki/AssemblyX64M.wiki
==============================================================================
--- wiki/AssemblyX64M.wiki (original)
+++ wiki/AssemblyX64M.wiki Fri Mar 6 15:22:51 2009
@@ -32,7 +32,9 @@

= mul: Unsigned Multiply =

-|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
-|| mul r/m8 || F6 /4 || Valid || Valid || Unsigned
multiply (ax <- al * r/m8) ||
-|| mul r/m16 || F7 /4 || Valid || Valid || Unsigned
multiply (dx:ax <- ax * r/m16 ||
+|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
+|| mul r/m8 || F6 /4 || Valid || Valid || Unsigned
multiply (ax <- al * r/m8) ||
+|| mul r/m16 || o16 F7 /4 || Valid || Valid || Unsigned
multiply (dx:ax <- ax * r/m16 ||
+|| mul r/m32 || o32 F7 /4 || Valid || Valid || Unsigned
multiply (edx:eax <- ax * r/m32 ||
+|| mul r/m64 || F7 /4 || Valid || ~~N.E.~~ || Unsigned
multiply (rdx:rax <- rax * r/m64 ||


Modified: wiki/AssemblyX64N.wiki
==============================================================================
--- wiki/AssemblyX64N.wiki (original)
+++ wiki/AssemblyX64N.wiki Fri Mar 6 15:22:51 2009
@@ -6,9 +6,11 @@

= neg: Two's Complement Negation =

-|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
-|| neg r/m8 || F6 /3 || Valid || Valid || Two's
complement negate r/m8 ||
-|| neg r/m16 || F7 /3 || Valid || Valid || Two's
complement negate r/m16 ||
+|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
+|| neg r/m8 || F6 /3 || Valid || Valid || Two's
complement negate r/m8 ||
+|| neg r/m16 || o16 F7 /3 || Valid || Valid || Two's
complement negate r/m16 ||
+|| neg r/m32 || o32 F7 /3 || Valid || Valid || Two's
complement negate r/m32 ||
+|| neg r/m64 || F7 /3 || Valid || ~~N.E.~~ || Two's
complement negate r/m64 ||

Replaces the value of destination operand with its two's complement
(-dest).

@@ -23,9 +25,11 @@

= not: One's Complement Negation =

-|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
-|| not r/m8 || F6 /2 || Valid || Valid || Reverse each
bit of r/m8 ||
-|| not r/m16 || F7 /2 || Valid || Valid || Reverse each
bit of r/m16 ||
+|| Instruction || Opcode || 64-Bit Mode || 16/32-Bit Mode ||
Description ||
+|| not r/m8 || F6 /2 || Valid || Valid || Reverse
each bit of r/m8 ||
+|| not r/m16 || o16 F7 /2 || Valid || Valid || Reverse
each bit of r/m16 ||
+|| not r/m32 || o32 F7 /2 || Valid || Valid || Reverse
each bit of r/m32 ||
+|| not r/m64 || F7 /2 || Valid || ~~N.E.~~ || Reverse
each bit of r/m64 ||

Replaces the value of destination operand with its one's complement
(bitwise NOT).

Reply all
Reply to author
Forward
0 new messages