|
45 | 45 | (error n "expects register; given ~v" a1)) |
46 | 46 | a1)) |
47 | 47 |
|
48 | | -(define (check:src-dest width) |
| 48 | +(define check:src-dest |
49 | 49 | (λ (a1 a2 n) |
50 | 50 | (unless (or (register? a1) (offset? a1)) |
51 | 51 | (error n "expects register or offset; given ~v" a1)) |
52 | 52 | (unless (or (register? a2) (offset? a2) (exact-integer? a2) (Const? a2)) |
53 | 53 | (error n "expects register, offset, exact integer, or defined constant; given ~v" a2)) |
54 | 54 | (when (and (offset? a1) (offset? a2)) |
55 | 55 | (error n "cannot use two memory locations; given ~v, ~v" a1 a2)) |
56 | | - (when (and (exact-integer? a2) (> (integer-length a2) width)) |
57 | | - (error n "literal must not exceed ~v-bits; given ~v (~v bits); go through a register instead" width a2 (integer-length a2))) |
| 56 | + (when (and (exact-integer? a2) (> (integer-length a2) 32)) |
| 57 | + (error n "literal must not exceed 32-bits; given ~v (~v bits); go through a register instead" a2 (integer-length a2))) |
58 | 58 | (when (and (offset? a1) (exact-integer? a2)) |
59 | 59 | (error n "cannot use a memory locations and literal; given ~v, ~v; go through a register instead" a1 a2)) |
60 | 60 | (values a1 a2))) |
61 | 61 |
|
| 62 | +(define check:mov |
| 63 | + (λ (a1 a2 n) |
| 64 | + (unless (or (register? a1) (offset? a1)) |
| 65 | + (error n "expects register or offset; given ~v" a1)) |
| 66 | + (unless (or (register? a2) (offset? a2) (exact-integer? a2) (Const? a2)) |
| 67 | + (error n "expects register, offset, exact integer, or defined constant; given ~v" a2)) |
| 68 | + (when (and (offset? a1) (offset? a2)) |
| 69 | + (error n "cannot use two memory locations; given ~v, ~v" a1 a2)) |
| 70 | + (when (and (exact-integer? a2) (> (integer-length a2) 64)) |
| 71 | + (error n "literal must not exceed 64-bits; given ~v (~v bits)" a2 (integer-length a2))) |
| 72 | + (when (and (offset? a1) (exact-integer? a2)) |
| 73 | + (error n "cannot use a memory locations and literal; given ~v, ~v; go through a register instead" a1 a2)) |
| 74 | + (values a1 a2))) |
62 | 75 |
|
63 | 76 | (define check:shift |
64 | 77 | (λ (a1 a2 n) |
|
133 | 146 | (instruct Label (x) check:label-symbol) |
134 | 147 | (instruct Call (x) check:target) |
135 | 148 | (instruct Ret () check:none) |
136 | | -(instruct Mov (dst src) (check:src-dest 64)) |
| 149 | +(instruct Mov (dst src) check:mov) |
137 | 150 | (instruct Add (dst src) check:arith) |
138 | 151 | (instruct Sub (dst src) check:arith) |
139 | | -(instruct Cmp (a1 a2) (check:src-dest 32)) |
| 152 | +(instruct Cmp (a1 a2) check:src-dest) |
140 | 153 | (instruct Jmp (x) check:target) |
141 | 154 | (instruct Je (x) check:target) |
142 | 155 | (instruct Jne (x) check:target) |
143 | 156 | (instruct Jl (x) check:target) |
144 | 157 | (instruct Jle (x) check:target) |
145 | 158 | (instruct Jg (x) check:target) |
146 | 159 | (instruct Jge (x) check:target) |
147 | | -(instruct And (dst src) (check:src-dest 32)) |
148 | | -(instruct Or (dst src) (check:src-dest 32)) |
149 | | -(instruct Xor (dst src) (check:src-dest 32)) |
| 160 | +(instruct And (dst src) check:src-dest) |
| 161 | +(instruct Or (dst src) check:src-dest) |
| 162 | +(instruct Xor (dst src) check:src-dest) |
150 | 163 | (instruct Sal (dst i) check:shift) |
151 | 164 | (instruct Sar (dst i) check:shift) |
152 | 165 | (instruct Push (a1) check:push) |
|
0 commit comments