Changeset 97
- Timestamp:
- Sep 21, 2010, 1:51:59 PM (10 years ago)
- Location:
- Deliverables/D4.1
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D4.1/ASM.mli
r92 r97 28 28 type instruction = 29 29 (* arithmetic operations *) 30 31 | ADDC of acc * [ reg | direct | indirect | data ]32 | SUBB of acc * [ reg | direct | indirect | data ]33 | INC of [ acc | reg | direct | indirect | dptr ]34 | DEC of [ acc | reg | direct | indirect ]35 | MUL of acc * b36 | DIV of acc * b37 | DA of acc30 [ `ADD of acc * [ reg | direct | indirect | data ] 31 | `ADDC of acc * [ reg | direct | indirect | data ] 32 | `SUBB of acc * [ reg | direct | indirect | data ] 33 | `INC of [ acc | reg | direct | indirect | dptr ] 34 | `DEC of [ acc | reg | direct | indirect ] 35 | `MUL of acc * b 36 | `DIV of acc * b 37 | `DA of acc 38 38 39 39 (* logical operations *) 40 | ANL of40 | `ANL of 41 41 (acc * [ reg | direct | indirect | data ], 42 42 direct * [ acc | data ], 43 43 carry * [ bit | nbit]) union3 44 | ORL of44 | `ORL of 45 45 (acc * [ reg | data | direct | indirect ], 46 46 direct * [ acc | data ], 47 47 carry * [ bit | nbit]) union3 48 | XRL of48 | `XRL of 49 49 (acc * [ data | reg | direct | indirect ], 50 50 direct * [ acc | data ]) union2 51 | CLR of [ acc | carry | bit ]52 | CPL of [ acc | carry | bit ]53 | RL of acc54 | RLC of acc55 | RR of acc56 | RRC of acc57 | SWAP of acc51 | `CLR of [ acc | carry | bit ] 52 | `CPL of [ acc | carry | bit ] 53 | `RL of acc 54 | `RLC of acc 55 | `RR of acc 56 | `RRC of acc 57 | `SWAP of acc 58 58 59 59 (* data transfer *) 60 | MOV of60 | `MOV of 61 61 (acc * [ reg | direct | indirect | data ], 62 62 [ reg | indirect ] * [ acc | direct | data ], … … 66 66 bit * carry 67 67 ) union6 68 | MOVC of acc * [ acc_dptr | acc_pc ]69 | MOVX of (acc * [ ext_indirect | ext_indirect_dptr ],68 | `MOVC of acc * [ acc_dptr | acc_pc ] 69 | `MOVX of (acc * [ ext_indirect | ext_indirect_dptr ], 70 70 [ ext_indirect | ext_indirect_dptr ] * acc) union2 71 | SETB of [ carry | bit ]72 | PUSH of direct73 | POP of direct74 | XCH of acc * [ reg | direct | indirect ]75 | XCHD of acc * indirect71 | `SETB of [ carry | bit ] 72 | `PUSH of direct 73 | `POP of direct 74 | `XCH of acc * [ reg | direct | indirect ] 75 | `XCHD of acc * indirect 76 76 77 77 (* program branching *) 78 | JC of rel 79 | JNC of rel 80 | JB of bit * rel 81 | JNB of bit * rel 82 | JBC of bit * rel 83 | ACALL of addr11 84 | LCALL of addr16 85 | RET 86 | RETI 87 | AJMP of addr11 88 | LJMP of addr16 89 | SJMP of rel 90 | JMP of indirect_dptr 91 | JZ of rel 92 | JNZ of rel 93 | CJNE of (acc * [ direct | data ], [ reg | indirect ] * data) union2 * rel 94 | DJNZ of [ reg | direct ] * rel 95 | NOP 78 | `JC of rel 79 | `JNC of rel 80 | `JB of bit * rel 81 | `JNB of bit * rel 82 | `JBC of bit * rel 83 | `ACALL of addr11 84 | `LCALL of addr16 85 | `RET 86 | `RETI 87 | `AJMP of addr11 88 | `LJMP of addr16 89 | `SJMP of rel 90 | `JMP of indirect_dptr 91 | `JZ of rel 92 | `JNZ of rel 93 | `CJNE of (acc * [ direct | data ], [ reg | indirect ] * data) union2 * rel 94 | `DJNZ of [ reg | direct ] * rel 95 | `NOP ] 96 97 type labelled_instruction = 98 [ instruction 99 | `Label of string 100 | `Cost of string ] -
Deliverables/D4.1/ASMInterpret.ml
r95 r97 84 84 85 85 let get_cy_flag status = 86 let [cy;_;_;_;_;_;_;_] = to_bitsstatus.psw in cy86 let (cy,_,_,_),(_,_,_,_) = bits_of_byte status.psw in cy 87 87 let get_ac_flag status = 88 let [_;ac;_;_;_;_;_;_] = to_bitsstatus.psw in ac88 let (_,ac,_,_),(_,_,_,_) = bits_of_byte status.psw in ac 89 89 let get_fo_flag status = 90 let [_;_;fo;_;_;_;_;_] = to_bitsstatus.psw in fo90 let (_,_,fo,_),(_,_,_,_) = bits_of_byte status.psw in fo 91 91 let get_rs1_flag status = 92 let [_;_;_;rs1;_;_;_;_] = to_bitsstatus.psw in rs192 let (_,_,_,rs1),(_,_,_,_) = bits_of_byte status.psw in rs1 93 93 let get_rs0_flag status = 94 let [_;_;_;_;rs0;_;_;_] = to_bitsstatus.psw in rs094 let (_,_,_,_),(rs0,_,_,_) = bits_of_byte status.psw in rs0 95 95 let get_ov_flag status = 96 let [_;_;_;_;_;ov;_;_] = to_bitsstatus.psw in ov96 let (_,_,_,_),(_,ov,_,_) = bits_of_byte status.psw in ov 97 97 let get_ud_flag status = 98 let [_;_;_;_;_;_;ud;_] = to_bitsstatus.psw in ud98 let (_,_,_,_),(_,_,ud,_) = bits_of_byte status.psw in ud 99 99 let get_p_flag status = 100 let [_;_;_;_;_;_;_;p] = to_bitsstatus.psw in p100 let (_,_,_,_),(_,_,_,p) = bits_of_byte status.psw in p 101 101 102 102 (* timings taken from SIEMENS *) … … 115 115 (a10,a9,a8,true),(false,false,false,true) -> 116 116 let pc,b1 = next pc in 117 ACALL (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2117 `ACALL (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2 118 118 | (false,false,true,false),(true,r1,r2,r3) -> 119 ADD (`A,`REG (r1,r2,r3)), pc, 1119 `ADD (`A,`REG (r1,r2,r3)), pc, 1 120 120 | (false,false,true,false),(false,true,false,true) -> 121 121 let pc,b1 = next pc in 122 ADD (`A,`DIRECT b1), pc, 1122 `ADD (`A,`DIRECT b1), pc, 1 123 123 | (false,false,true,false),(false,true,true,i1) -> 124 ADD (`A,`INDIRECT i1), pc, 1124 `ADD (`A,`INDIRECT i1), pc, 1 125 125 | (false,false,true,false),(false,true,false,false) -> 126 126 let pc,b1 = next pc in 127 ADD (`A,`DATA b1), pc, 1127 `ADD (`A,`DATA b1), pc, 1 128 128 | (false,false,true,true),(true,r1,r2,r3) -> 129 ADDC (`A,`REG (r1,r2,r3)), pc, 1129 `ADDC (`A,`REG (r1,r2,r3)), pc, 1 130 130 | (false,false,true,true),(false,true,false,true) -> 131 131 let pc,b1 = next pc in 132 ADDC (`A,`DIRECT b1), pc, 1132 `ADDC (`A,`DIRECT b1), pc, 1 133 133 | (false,false,true,true),(false,true,true,i1) -> 134 ADDC (`A,`INDIRECT i1), pc, 1134 `ADDC (`A,`INDIRECT i1), pc, 1 135 135 | (false,false,true,true),(false,true,false,false) -> 136 136 let pc,b1 = next pc in 137 ADDC (`A,`DATA b1), pc, 1137 `ADDC (`A,`DATA b1), pc, 1 138 138 | (a10,a9,a8,false),(false,false,false,true) -> 139 139 let pc,b1 = next pc in 140 AJMP (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2140 `AJMP (`ADDR11 (mk_word11 a10 a9 a8 b1)), pc, 2 141 141 | (false,true,false,true),(true,r1,r2,r3) -> 142 ANL (`U1 (`A, `REG (r1,r2,r3))), pc, 1142 `ANL (`U1 (`A, `REG (r1,r2,r3))), pc, 1 143 143 | (false,true,false,true),(false,true,false,true) -> 144 144 let pc,b1 = next pc in 145 ANL (`U1 (`A, `DIRECT b1)), pc, 1145 `ANL (`U1 (`A, `DIRECT b1)), pc, 1 146 146 | (false,true,false,true),(false,true,true,i1) -> 147 ANL (`U1 (`A, `INDIRECT i1)), pc, 1147 `ANL (`U1 (`A, `INDIRECT i1)), pc, 1 148 148 | (false,true,false,true),(false,true,false,false) -> 149 149 let pc,b1 = next pc in 150 ANL (`U1 (`A, `DATA b1)), pc, 1150 `ANL (`U1 (`A, `DATA b1)), pc, 1 151 151 | (false,true,false,true),(false,false,true,false) -> 152 152 let pc,b1 = next pc in 153 ANL (`U2 (`DIRECT b1,`A)), pc, 1153 `ANL (`U2 (`DIRECT b1,`A)), pc, 1 154 154 | (false,true,false,true),(false,false,true,true) -> 155 155 let pc,b1 = next pc in 156 156 let pc,b2 = next pc in 157 ANL (`U2 (`DIRECT b1,`DATA b2)), pc, 2157 `ANL (`U2 (`DIRECT b1,`DATA b2)), pc, 2 158 158 | (true,false,false,false),(false,false,true,false) -> 159 159 let pc,b1 = next pc in 160 ANL (`U3 (`C,`BIT b1)), pc, 2160 `ANL (`U3 (`C,`BIT b1)), pc, 2 161 161 | (true,false,true,true),(false,false,false,false) -> 162 162 let pc,b1 = next pc in 163 ANL (`U3 (`C,`NBIT b1)), pc, 2163 `ANL (`U3 (`C,`NBIT b1)), pc, 2 164 164 | (true,false,true,true),(false,true,false,true) -> 165 165 let pc,b1 = next pc in 166 166 let pc,b2 = next pc in 167 CJNE (`U1 (`A, `DIRECT b1), `REL b2), pc, 2167 `CJNE (`U1 (`A, `DIRECT b1), `REL b2), pc, 2 168 168 | (true,false,true,true),(false,true,false,false) -> 169 169 let pc,b1 = next pc in 170 170 let pc,b2 = next pc in 171 CJNE (`U1 (`A, `DATA b1), `REL b2), pc, 2171 `CJNE (`U1 (`A, `DATA b1), `REL b2), pc, 2 172 172 | (true,false,true,true),(true,r1,r2,r3) -> 173 173 let pc,b1 = next pc in 174 174 let pc,b2 = next pc in 175 CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2), pc, 2175 `CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2), pc, 2 176 176 | (true,false,true,true),(false,true,true,i1) -> 177 177 let pc,b1 = next pc in 178 178 let pc,b2 = next pc in 179 CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2), pc, 2179 `CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2), pc, 2 180 180 | (true,true,true,false),(false,true,false,false) -> 181 CLR `A, pc, 1181 `CLR `A, pc, 1 182 182 | (true,true,false,false),(false,false,true,true) -> 183 CLR `C, pc, 1183 `CLR `C, pc, 1 184 184 | (true,true,false,false),(false,false,true,false) -> 185 185 let pc,b1 = next pc in 186 CLR (`BIT b1), pc, 1186 `CLR (`BIT b1), pc, 1 187 187 | (true,true,true,true),(false,true,false,false) -> 188 CPL `A, pc, 1188 `CPL `A, pc, 1 189 189 | (true,false,true,true),(false,false,true,true) -> 190 CPL `C, pc, 1190 `CPL `C, pc, 1 191 191 | (true,false,true,true),(false,false,true,false) -> 192 192 let pc,b1 = next pc in 193 CPL (`BIT b1), pc, 1193 `CPL (`BIT b1), pc, 1 194 194 | (true,true,false,true),(false,true,false,false) -> 195 DA `A, pc, 1195 `DA `A, pc, 1 196 196 | (false,false,false,true),(false,true,false,false) -> 197 DEC `A, pc, 1197 `DEC `A, pc, 1 198 198 | (false,false,false,true),(true,r1,r2,r3) -> 199 DEC (`REG(r1,r2,r3)), pc, 1199 `DEC (`REG(r1,r2,r3)), pc, 1 200 200 | (false,false,false,true),(false,true,false,true) -> 201 201 let pc,b1 = next pc in 202 DEC (`DIRECT b1), pc, 1202 `DEC (`DIRECT b1), pc, 1 203 203 | (false,false,false,true),(false,true,true,i1) -> 204 DEC (`INDIRECT i1), pc, 1204 `DEC (`INDIRECT i1), pc, 1 205 205 | (true,false,false,false),(false,true,false,false) -> 206 DIV (`A, `B), pc, 4206 `DIV (`A, `B), pc, 4 207 207 | (true,true,false,true),(true,r1,r2,r3) -> 208 208 let pc,b1 = next pc in 209 DJNZ (`REG(r1,r2,r3), `REL b1), pc, 2209 `DJNZ (`REG(r1,r2,r3), `REL b1), pc, 2 210 210 | (true,true,false,true),(false,true,false,true) -> 211 211 let pc,b1 = next pc in 212 212 let pc,b2 = next pc in 213 DJNZ (`DIRECT b1, `REL b2), pc, 2213 `DJNZ (`DIRECT b1, `REL b2), pc, 2 214 214 | (false,false,false,false),(false,true,false,false) -> 215 INC `A, pc, 1215 `INC `A, pc, 1 216 216 | (false,false,false,false),(true,r1,r2,r3) -> 217 INC (`REG(r1,r2,r3)), pc, 1217 `INC (`REG(r1,r2,r3)), pc, 1 218 218 | (false,false,false,false),(false,true,false,true) -> 219 219 let pc,b1 = next pc in 220 INC (`DIRECT b1), pc, 1220 `INC (`DIRECT b1), pc, 1 221 221 | (false,false,false,false),(false,true,true,i1) -> 222 INC (`INDIRECT i1), pc, 1222 `INC (`INDIRECT i1), pc, 1 223 223 | (true,false,true,false),(false,false,true,true) -> 224 INC `DPTR, pc, 2224 `INC `DPTR, pc, 2 225 225 | (false,false,true,false),(false,false,false,false) -> 226 226 let pc,b1 = next pc in 227 227 let pc,b2 = next pc in 228 JB (`BIT b1, `REL b2), pc, 2228 `JB (`BIT b1, `REL b2), pc, 2 229 229 | (false,false,false,true),(false,false,false,false) -> 230 230 let pc,b1 = next pc in 231 231 let pc,b2 = next pc in 232 JBC (`BIT b1, `REL b2), pc, 2232 `JBC (`BIT b1, `REL b2), pc, 2 233 233 | (false,true,false,false),(false,false,false,false) -> 234 234 let pc,b1 = next pc in 235 JC (`REL b1), pc, 2235 `JC (`REL b1), pc, 2 236 236 | (false,true,true,true),(false,false,true,true) -> 237 JMP `IND_DPTR, pc, 2237 `JMP `IND_DPTR, pc, 2 238 238 | (false,false,true,true),(false,false,false,false) -> 239 239 let pc,b1 = next pc in 240 240 let pc,b2 = next pc in 241 JNB (`BIT b1, `REL b2), pc, 2241 `JNB (`BIT b1, `REL b2), pc, 2 242 242 | (false,true,false,true),(false,false,false,false) -> 243 243 let pc,b1 = next pc in 244 JNC (`REL b1), pc, 2244 `JNC (`REL b1), pc, 2 245 245 | (false,true,true,true),(false,false,false,false) -> 246 246 let pc,b1 = next pc in 247 JNZ (`REL b1), pc, 2247 `JNZ (`REL b1), pc, 2 248 248 | (false,true,true,false),(false,false,false,false) -> 249 249 let pc,b1 = next pc in 250 JZ (`REL b1), pc, 2250 `JZ (`REL b1), pc, 2 251 251 | (false,false,false,true),(false,false,true,false) -> 252 252 let pc,b1 = next pc in 253 253 let pc,b2 = next pc in 254 LCALL (`ADDR16 (mk_word b1 b2)), pc, 2254 `LCALL (`ADDR16 (mk_word b1 b2)), pc, 2 255 255 | (false,false,false,false),(false,false,true,false) -> 256 256 let pc,b1 = next pc in 257 257 let pc,b2 = next pc in 258 LJMP (`ADDR16 (mk_word b1 b2)), pc, 2258 `LJMP (`ADDR16 (mk_word b1 b2)), pc, 2 259 259 | (true,true,true,false),(true,r1,r2,r3) -> 260 MOV (`U1 (`A, `REG(r1,r2,r3))), pc, 1260 `MOV (`U1 (`A, `REG(r1,r2,r3))), pc, 1 261 261 | (true,true,true,false),(false,true,false,true) -> 262 262 let pc,b1 = next pc in 263 MOV (`U1 (`A, `DIRECT b1)), pc, 1263 `MOV (`U1 (`A, `DIRECT b1)), pc, 1 264 264 | (true,true,true,false),(false,true,true,i1) -> 265 MOV (`U1 (`A, `INDIRECT i1)), pc, 1265 `MOV (`U1 (`A, `INDIRECT i1)), pc, 1 266 266 | (false,true,true,true),(false,true,false,false) -> 267 267 let pc,b1 = next pc in 268 MOV (`U1 (`A, `DATA b1)), pc, 1268 `MOV (`U1 (`A, `DATA b1)), pc, 1 269 269 | (true,true,true,true),(true,r1,r2,r3) -> 270 MOV (`U2 (`REG(r1,r2,r3), `A)), pc, 1270 `MOV (`U2 (`REG(r1,r2,r3), `A)), pc, 1 271 271 | (true,false,true,false),(true,r1,r2,r3) -> 272 272 let pc,b1 = next pc in 273 MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))), pc, 2273 `MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))), pc, 2 274 274 | (false,true,true,true),(true,r1,r2,r3) -> 275 275 let pc,b1 = next pc in 276 MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))), pc, 1276 `MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))), pc, 1 277 277 | (true,true,true,true),(false,true,false,true) -> 278 278 let pc,b1 = next pc in 279 MOV (`U3 (`DIRECT b1, `A)), pc, 1279 `MOV (`U3 (`DIRECT b1, `A)), pc, 1 280 280 | (true,false,false,false),(true,r1,r2,r3) -> 281 281 let pc,b1 = next pc in 282 MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))), pc, 2282 `MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))), pc, 2 283 283 | (true,false,false,false),(false,true,false,true) -> 284 284 let pc,b1 = next pc in 285 285 let pc,b2 = next pc in 286 MOV (`U3 (`DIRECT b1, `DIRECT b2)), pc, 2286 `MOV (`U3 (`DIRECT b1, `DIRECT b2)), pc, 2 287 287 | (true,false,false,false),(false,true,true,i1) -> 288 288 let pc,b1 = next pc in 289 MOV (`U3 (`DIRECT b1, `INDIRECT i1)), pc, 2289 `MOV (`U3 (`DIRECT b1, `INDIRECT i1)), pc, 2 290 290 | (false,true,true,true),(false,true,false,true) -> 291 291 let pc,b1 = next pc in 292 292 let pc,b2 = next pc in 293 MOV (`U3 (`DIRECT b1, `DATA b2)), pc, 2293 `MOV (`U3 (`DIRECT b1, `DATA b2)), pc, 2 294 294 | (true,true,true,true),(false,true,true,i1) -> 295 MOV (`U2 (`INDIRECT i1, `A)), pc, 1295 `MOV (`U2 (`INDIRECT i1, `A)), pc, 1 296 296 | (true,false,true,false),(false,true,true,i1) -> 297 297 let pc,b1 = next pc in 298 MOV (`U2 (`INDIRECT i1, `DIRECT b1)), pc, 2298 `MOV (`U2 (`INDIRECT i1, `DIRECT b1)), pc, 2 299 299 | (false,true,true,true),(false,true,true,i1) -> 300 300 let pc,b1 = next pc in 301 MOV (`U2 (`INDIRECT i1, `DATA b1)), pc, 1301 `MOV (`U2 (`INDIRECT i1, `DATA b1)), pc, 1 302 302 | (true,false,true,false),(false,false,true,false) -> 303 303 let pc,b1 = next pc in 304 MOV (`U5 (`C, `BIT b1)), pc, 1304 `MOV (`U5 (`C, `BIT b1)), pc, 1 305 305 | (true,false,false,true),(false,false,true,false) -> 306 306 let pc,b1 = next pc in 307 MOV (`U6 (`BIT b1, `C)), pc, 2307 `MOV (`U6 (`BIT b1, `C)), pc, 2 308 308 | (true,false,false,true),(false,false,false,false) -> 309 309 let pc,b1 = next pc in 310 310 let pc,b2 = next pc in 311 MOV (`U4 (`DPTR, `DATA16(mk_word b1 b2))), pc, 2311 `MOV (`U4 (`DPTR, `DATA16(mk_word b1 b2))), pc, 2 312 312 | (true,false,false,true),(false,false,true,true) -> 313 MOVC (`A, `A_DPTR), pc, 2313 `MOVC (`A, `A_DPTR), pc, 2 314 314 | (true,false,false,false),(false,false,true,true) -> 315 MOVC (`A, `A_PC), pc, 2315 `MOVC (`A, `A_PC), pc, 2 316 316 | (true,true,true,false),(false,false,true,i1) -> 317 MOVX (`U1 (`A, `EXT_INDIRECT i1)), pc, 2317 `MOVX (`U1 (`A, `EXT_INDIRECT i1)), pc, 2 318 318 | (true,true,true,false),(false,false,false,false) -> 319 MOVX (`U1 (`A, `EXT_IND_DPTR)), pc, 2319 `MOVX (`U1 (`A, `EXT_IND_DPTR)), pc, 2 320 320 | (true,true,true,true),(false,false,true,i1) -> 321 MOVX (`U2 (`EXT_INDIRECT i1, `A)), pc, 2321 `MOVX (`U2 (`EXT_INDIRECT i1, `A)), pc, 2 322 322 | (true,true,true,true),(false,false,false,false) -> 323 MOVX (`U2 (`EXT_IND_DPTR, `A)), pc, 2323 `MOVX (`U2 (`EXT_IND_DPTR, `A)), pc, 2 324 324 | (true,false,true,false),(false,true,false,false) -> 325 MUL(`A, `B), pc, 4325 `MUL(`A, `B), pc, 4 326 326 | (false,false,false,false),(false,false,false,false) -> 327 NOP, pc, 1327 `NOP, pc, 1 328 328 | (false,true,false,false),(true,r1,r2,r3) -> 329 ORL (`U1(`A, `REG(r1,r2,r3))), pc, 1329 `ORL (`U1(`A, `REG(r1,r2,r3))), pc, 1 330 330 | (false,true,false,false),(false,true,false,true) -> 331 331 let pc,b1 = next pc in 332 ORL (`U1(`A, `DIRECT b1)), pc, 1332 `ORL (`U1(`A, `DIRECT b1)), pc, 1 333 333 | (false,true,false,false),(false,true,true,i1) -> 334 ORL (`U1(`A, `INDIRECT i1)), pc, 1334 `ORL (`U1(`A, `INDIRECT i1)), pc, 1 335 335 | (false,true,false,false),(false,true,false,false) -> 336 336 let pc,b1 = next pc in 337 ORL (`U1(`A, `DATA b1)), pc, 1337 `ORL (`U1(`A, `DATA b1)), pc, 1 338 338 | (false,true,false,false),(false,false,true,false) -> 339 339 let pc,b1 = next pc in 340 ORL (`U2(`DIRECT b1, `A)), pc, 1340 `ORL (`U2(`DIRECT b1, `A)), pc, 1 341 341 | (false,true,false,false),(false,false,true,true) -> 342 342 let pc,b1 = next pc in 343 343 let pc,b2 = next pc in 344 ORL (`U2 (`DIRECT b1, `DATA b2)), pc, 2344 `ORL (`U2 (`DIRECT b1, `DATA b2)), pc, 2 345 345 | (false,true,true,true),(false,false,true,false) -> 346 346 let pc,b1 = next pc in 347 ORL (`U3 (`C, `BIT b1)), pc, 2347 `ORL (`U3 (`C, `BIT b1)), pc, 2 348 348 | (true,false,true,false),(false,false,false,false) -> 349 349 let pc,b1 = next pc in 350 ORL (`U3 (`C, `NBIT b1)), pc, 2350 `ORL (`U3 (`C, `NBIT b1)), pc, 2 351 351 | (true,true,false,true),(false,false,false,false) -> 352 352 let pc,b1 = next pc in 353 POP (`DIRECT b1), pc, 2353 `POP (`DIRECT b1), pc, 2 354 354 | (true,true,false,false),(false,false,false,false) -> 355 355 let pc,b1 = next pc in 356 PUSH (`DIRECT b1), pc, 2356 `PUSH (`DIRECT b1), pc, 2 357 357 | (false,false,true,false),(false,false,true,false) -> 358 RET, pc, 2358 `RET, pc, 2 359 359 | (false,false,true,true),(false,false,true,false) -> 360 RETI, pc, 2360 `RETI, pc, 2 361 361 | (false,false,true,false),(false,false,true,true) -> 362 RL `A, pc, 1362 `RL `A, pc, 1 363 363 | (false,false,true,true),(false,false,true,true) -> 364 RLC `A, pc, 1364 `RLC `A, pc, 1 365 365 | (false,false,false,false),(false,false,true,true) -> 366 RR `A, pc, 1366 `RR `A, pc, 1 367 367 | (false,false,false,true),(false,false,true,true) -> 368 RRC `A, pc, 1368 `RRC `A, pc, 1 369 369 | (true,true,false,true),(false,false,true,true) -> 370 SETB `C, pc, 1370 `SETB `C, pc, 1 371 371 | (true,true,false,true),(false,false,true,false) -> 372 372 let pc,b1 = next pc in 373 SETB (`BIT b1), pc, 1373 `SETB (`BIT b1), pc, 1 374 374 | (true,false,false,false),(false,false,false,false) -> 375 375 let pc,b1 = next pc in 376 SJMP (`REL b1), pc, 2376 `SJMP (`REL b1), pc, 2 377 377 | (true,false,false,true),(true,r1,r2,r3) -> 378 SUBB (`A, `REG(r1,r2,r3)), pc, 1378 `SUBB (`A, `REG(r1,r2,r3)), pc, 1 379 379 | (true,false,false,true),(false,true,false,true) -> 380 380 let pc,b1 = next pc in 381 SUBB (`A, `DIRECT b1), pc, 1381 `SUBB (`A, `DIRECT b1), pc, 1 382 382 | (true,false,false,true),(false,true,true,i1) -> 383 SUBB (`A, `INDIRECT i1), pc, 1383 `SUBB (`A, `INDIRECT i1), pc, 1 384 384 | (true,false,false,true),(false,true,false,false) -> 385 385 let pc,b1 = next pc in 386 SUBB (`A, `DATA b1), pc, 1386 `SUBB (`A, `DATA b1), pc, 1 387 387 | (true,true,false,false),(false,true,false,false) -> 388 SWAP `A, pc, 1388 `SWAP `A, pc, 1 389 389 | (true,true,false,false),(true,r1,r2,r3) -> 390 XCH (`A, `REG(r1,r2,r3)), pc, 1390 `XCH (`A, `REG(r1,r2,r3)), pc, 1 391 391 | (true,true,false,false),(false,true,false,true) -> 392 392 let pc,b1 = next pc in 393 XCH (`A, `DIRECT b1), pc, 1393 `XCH (`A, `DIRECT b1), pc, 1 394 394 | (true,true,false,false),(false,true,true,i1) -> 395 XCH (`A, `INDIRECT i1), pc, 1395 `XCH (`A, `INDIRECT i1), pc, 1 396 396 | (true,true,false,true),(false,true,true,i1) -> 397 XCHD(`A, `INDIRECT i1), pc, 1397 `XCHD(`A, `INDIRECT i1), pc, 1 398 398 | (false,true,true,false),(true,r1,r2,r3) -> 399 XRL(`U1(`A, `REG(r1,r2,r3))), pc, 1399 `XRL(`U1(`A, `REG(r1,r2,r3))), pc, 1 400 400 | (false,true,true,false),(false,true,false,true) -> 401 401 let pc,b1 = next pc in 402 XRL(`U1(`A, `DIRECT b1)), pc, 1402 `XRL(`U1(`A, `DIRECT b1)), pc, 1 403 403 | (false,true,true,false),(false,true,true,i1) -> 404 XRL(`U1(`A, `INDIRECT i1)), pc, 1404 `XRL(`U1(`A, `INDIRECT i1)), pc, 1 405 405 | (false,true,true,false),(false,true,false,false) -> 406 406 let pc,b1 = next pc in 407 XRL(`U1(`A, `DATA b1)), pc, 1407 `XRL(`U1(`A, `DATA b1)), pc, 1 408 408 | (false,true,true,false),(false,false,true,false) -> 409 409 let pc,b1 = next pc in 410 XRL(`U2(`DIRECT b1, `A)), pc, 1410 `XRL(`U2(`DIRECT b1, `A)), pc, 1 411 411 | (false,true,true,false),(false,false,true,true) -> 412 412 let pc,b1 = next pc in 413 413 let pc,b2 = next pc in 414 XRL(`U2(`DIRECT b1, `DATA b2)), pc, 2 414 `XRL(`U2(`DIRECT b1, `DATA b2)), pc, 2 415 | _,_ -> assert false 415 416 with 416 417 Not_found -> raise (Fetch_exception "Key not found") 417 418 ;; 418 419 419 let lift a f g =420 let (x, y) = f a in421 (g x, g y)422 423 420 let assembly1 = 424 421 function 425 ACALL (`ADDR11 w) ->422 `ACALL (`ADDR11 w) -> 426 423 let (a10,a9,a8,b1) = from_word11 w in 427 424 [mk_byte_from_bits ((a10,a9,a8,true),(false,false,false,true)); b1] 428 | ADD (`A,`REG (r1,r2,r3)) ->425 | `ADD (`A,`REG (r1,r2,r3)) -> 429 426 [mk_byte_from_bits ((false,false,true,false),(true,r1,r2,r3))] 430 | ADD (`A, `DIRECT b1) ->427 | `ADD (`A, `DIRECT b1) -> 431 428 [mk_byte_from_bits ((false,false,true,false),(false,true,false,true)); b1] 432 | ADD (`A, `INDIRECT i1) ->429 | `ADD (`A, `INDIRECT i1) -> 433 430 [mk_byte_from_bits ((false,false,true,false),(false,true,true,i1))] 434 | ADD (`A, `DATA b1) ->431 | `ADD (`A, `DATA b1) -> 435 432 [mk_byte_from_bits ((false,false,true,false),(false,true,false,false)); b1] 436 | ADDC (`A, `REG(r1,r2,r3)) ->433 | `ADDC (`A, `REG(r1,r2,r3)) -> 437 434 [mk_byte_from_bits ((false,false,true,true),(true,r1,r2,r3))] 438 | ADDC (`A, `DIRECT b1) ->435 | `ADDC (`A, `DIRECT b1) -> 439 436 [mk_byte_from_bits ((false,false,true,true),(false,true,false,true)); b1] 440 | ADDC (`A,`INDIRECT i1) ->437 | `ADDC (`A,`INDIRECT i1) -> 441 438 [mk_byte_from_bits ((false,false,true,true),(false,true,true,i1))] 442 | ADDC (`A,`DATA b1) ->439 | `ADDC (`A,`DATA b1) -> 443 440 [mk_byte_from_bits ((false,false,true,true),(false,true,false,false)); b1] 444 | AJMP (`ADDR11 w) ->441 | `AJMP (`ADDR11 w) -> 445 442 let (a10,a9,a8,b1) = from_word11 w in 446 443 [mk_byte_from_bits ((a10,a9,a8,false),(false,false,false,true))] 447 | ANL (`U1 (`A, `REG (r1,r2,r3))) ->444 | `ANL (`U1 (`A, `REG (r1,r2,r3))) -> 448 445 [mk_byte_from_bits ((false,true,false,true),(true,r1,r2,r3))] 449 | ANL (`U1 (`A, `DIRECT b1)) ->446 | `ANL (`U1 (`A, `DIRECT b1)) -> 450 447 [mk_byte_from_bits ((false,true,false,true),(false,true,false,true)); b1] 451 | ANL (`U1 (`A, `INDIRECT i1)) ->448 | `ANL (`U1 (`A, `INDIRECT i1)) -> 452 449 [mk_byte_from_bits ((false,true,false,true),(false,true,true,i1))] 453 | ANL (`U1 (`A, `DATA b1)) ->450 | `ANL (`U1 (`A, `DATA b1)) -> 454 451 [mk_byte_from_bits ((false,true,false,true),(false,true,false,false)); b1] 455 | ANL (`U2 (`DIRECT b1,`A)) ->452 | `ANL (`U2 (`DIRECT b1,`A)) -> 456 453 [mk_byte_from_bits ((false,true,false,true),(false,false,true,false)); b1] 457 | ANL (`U2 (`DIRECT b1,`DATA b2)) ->454 | `ANL (`U2 (`DIRECT b1,`DATA b2)) -> 458 455 [mk_byte_from_bits ((false,true,false,true),(false,false,true,true)); b1; b2] 459 | ANL (`U3 (`C,`BIT b1)) ->456 | `ANL (`U3 (`C,`BIT b1)) -> 460 457 [mk_byte_from_bits ((true,false,false,false),(false,false,true,false)); b1] 461 | ANL (`U3 (`C,`NBIT b1)) ->458 | `ANL (`U3 (`C,`NBIT b1)) -> 462 459 [mk_byte_from_bits ((true,false,true,true),(false,false,false,false)); b1] 463 | CJNE (`U1 (`A, `DIRECT b1), `REL b2) ->460 | `CJNE (`U1 (`A, `DIRECT b1), `REL b2) -> 464 461 [mk_byte_from_bits ((true,false,true,true),(false,true,false,true)); b1; b2] 465 | CJNE (`U1 (`A, `DATA b1), `REL b2) ->462 | `CJNE (`U1 (`A, `DATA b1), `REL b2) -> 466 463 [mk_byte_from_bits ((true,false,true,true),(false,true,false,false)); b1; b2] 467 | CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2) ->464 | `CJNE (`U2 (`REG(r1,r2,r3), `DATA b1), `REL b2) -> 468 465 [mk_byte_from_bits ((true,false,true,true),(true,r1,r2,r3)); b1; b2] 469 | CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2) ->466 | `CJNE (`U2 (`INDIRECT i1, `DATA b1), `REL b2) -> 470 467 [mk_byte_from_bits ((true,false,true,true),(false,true,true,i1)); b1; b2] 471 | CLR `A ->468 | `CLR `A -> 472 469 [mk_byte_from_bits ((true,true,true,false),(false,true,false,false))] 473 | CLR `C ->470 | `CLR `C -> 474 471 [mk_byte_from_bits ((true,true,false,false),(false,false,true,true))] 475 | CLR (`BIT b1) ->472 | `CLR (`BIT b1) -> 476 473 [mk_byte_from_bits ((true,true,false,false),(false,false,true,false)); b1] 477 | CPL `A ->474 | `CPL `A -> 478 475 [mk_byte_from_bits ((true,true,true,true),(false,true,false,false))] 479 | CPL `C ->476 | `CPL `C -> 480 477 [mk_byte_from_bits ((true,false,true,true),(false,false,true,true))] 481 | CPL (`BIT b1) ->478 | `CPL (`BIT b1) -> 482 479 [mk_byte_from_bits ((true,false,true,true),(false,false,true,false)); b1] 483 | DA `A ->480 | `DA `A -> 484 481 [mk_byte_from_bits ((true,true,false,true),(false,true,false,false))] 485 | DEC `A ->482 | `DEC `A -> 486 483 [mk_byte_from_bits ((false,false,false,true),(false,true,false,false))] 487 | DEC (`REG(r1,r2,r3)) ->484 | `DEC (`REG(r1,r2,r3)) -> 488 485 [mk_byte_from_bits ((false,false,false,true),(true,r1,r2,r3))] 489 | DEC (`DIRECT b1) ->486 | `DEC (`DIRECT b1) -> 490 487 [mk_byte_from_bits ((false,false,false,true),(false,true,false,true)); b1] 491 | DEC (`INDIRECT i1) ->488 | `DEC (`INDIRECT i1) -> 492 489 [mk_byte_from_bits ((false,false,false,true),(false,true,true,i1))] 493 | DIV (`A, `B) ->490 | `DIV (`A, `B) -> 494 491 [mk_byte_from_bits ((true,false,false,false),(false,true,false,false))] 495 | DJNZ (`REG(r1,r2,r3), `REL b1) ->492 | `DJNZ (`REG(r1,r2,r3), `REL b1) -> 496 493 [mk_byte_from_bits ((true,true,false,true),(true,r1,r2,r3)); b1] 497 | DJNZ (`DIRECT b1, `REL b2) ->494 | `DJNZ (`DIRECT b1, `REL b2) -> 498 495 [mk_byte_from_bits ((true,true,false,true),(false,true,false,true)); b1; b2] 499 | INC `A ->496 | `INC `A -> 500 497 [mk_byte_from_bits ((false,false,false,false),(false,true,false,false))] 501 | INC (`REG(r1,r2,r3)) ->498 | `INC (`REG(r1,r2,r3)) -> 502 499 [mk_byte_from_bits ((false,false,false,false),(true,r1,r2,r3))] 503 | INC (`DIRECT b1) ->500 | `INC (`DIRECT b1) -> 504 501 [mk_byte_from_bits ((false,false,false,false),(false,true,false,true)); b1] 505 | INC (`INDIRECT i1) ->502 | `INC (`INDIRECT i1) -> 506 503 [mk_byte_from_bits ((false,false,false,false),(false,true,true,i1))] 507 | INC `DPTR ->504 | `INC `DPTR -> 508 505 [mk_byte_from_bits ((true,false,true,false),(false,false,true,true))] 509 | JB (`BIT b1, `REL b2) ->506 | `JB (`BIT b1, `REL b2) -> 510 507 [mk_byte_from_bits ((false,false,true,false),(false,false,false,false)); b1; b2] 511 | JBC (`BIT b1, `REL b2) ->508 | `JBC (`BIT b1, `REL b2) -> 512 509 [mk_byte_from_bits ((false,false,false,true),(false,false,false,false)); b1; b2] 513 | JC (`REL b1) ->510 | `JC (`REL b1) -> 514 511 [mk_byte_from_bits ((false,true,false,false),(false,false,false,false)); b1] 515 | JMP `IND_DPTR ->512 | `JMP `IND_DPTR -> 516 513 [mk_byte_from_bits ((false,true,true,true),(false,false,true,true))] 517 | JNB (`BIT b1, `REL b2) ->514 | `JNB (`BIT b1, `REL b2) -> 518 515 [mk_byte_from_bits ((false,false,true,true),(false,false,false,false)); b1; b2] 519 | JNC (`REL b1) ->516 | `JNC (`REL b1) -> 520 517 [mk_byte_from_bits ((false,true,false,true),(false,false,false,false)); b1] 521 | JNZ (`REL b1) ->518 | `JNZ (`REL b1) -> 522 519 [mk_byte_from_bits ((false,true,true,true),(false,false,false,false)); b1] 523 | JZ (`REL b1) ->520 | `JZ (`REL b1) -> 524 521 [mk_byte_from_bits ((false,true,true,false),(false,false,false,false)); b1] 525 | LCALL (`ADDR16 w) ->522 | `LCALL (`ADDR16 w) -> 526 523 let (b1,b2) = from_word w in 527 524 [mk_byte_from_bits ((false,false,false,true),(false,false,true,false)); b1; b2] 528 | LJMP (`ADDR16 w) ->525 | `LJMP (`ADDR16 w) -> 529 526 let (b1,b2) = from_word w in 530 527 [mk_byte_from_bits ((false,false,false,false),(false,false,true,false)); b1; b2] 531 | MOV (`U1 (`A, `REG(r1,r2,r3))) ->528 | `MOV (`U1 (`A, `REG(r1,r2,r3))) -> 532 529 [mk_byte_from_bits ((true,true,true,false),(true,r1,r2,r3))] 533 | MOV (`U1 (`A, `DIRECT b1)) ->530 | `MOV (`U1 (`A, `DIRECT b1)) -> 534 531 [mk_byte_from_bits ((true,true,true,false),(false,true,false,true)); b1] 535 | MOV (`U1 (`A, `INDIRECT i1)) ->532 | `MOV (`U1 (`A, `INDIRECT i1)) -> 536 533 [mk_byte_from_bits ((true,true,true,false),(false,true,true,i1))] 537 | MOV (`U1 (`A, `DATA b1)) ->534 | `MOV (`U1 (`A, `DATA b1)) -> 538 535 [mk_byte_from_bits ((false,true,true,true),(false,true,false,false)); b1] 539 | MOV (`U2 (`REG(r1,r2,r3), `A)) ->536 | `MOV (`U2 (`REG(r1,r2,r3), `A)) -> 540 537 [mk_byte_from_bits ((true,true,true,true),(true,r1,r2,r3))] 541 | MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))) ->538 | `MOV (`U2 (`REG(r1,r2,r3), (`DIRECT b1))) -> 542 539 [mk_byte_from_bits ((true,false,true,false),(true,r1,r2,r3)); b1] 543 | MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))) ->540 | `MOV (`U2 (`REG(r1,r2,r3), (`DATA b1))) -> 544 541 [mk_byte_from_bits ((false,true,true,true),(true,r1,r2,r3)); b1] 545 | MOV (`U3 (`DIRECT b1, `A)) ->542 | `MOV (`U3 (`DIRECT b1, `A)) -> 546 543 [mk_byte_from_bits ((true,true,true,true),(false,true,false,true)); b1] 547 | MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))) ->544 | `MOV (`U3 (`DIRECT b1, `REG(r1,r2,r3))) -> 548 545 [mk_byte_from_bits ((true,false,false,false),(true,r1,r2,r3)); b1] 549 | MOV (`U3 (`DIRECT b1, `DIRECT b2)) ->546 | `MOV (`U3 (`DIRECT b1, `DIRECT b2)) -> 550 547 [mk_byte_from_bits ((true,false,false,false),(false,true,false,true)); b1; b2] 551 | MOV (`U3 (`DIRECT b1, `INDIRECT i1)) ->548 | `MOV (`U3 (`DIRECT b1, `INDIRECT i1)) -> 552 549 [mk_byte_from_bits ((true,false,false,false),(false,true,true,i1)); b1] 553 | MOV (`U3 (`DIRECT b1, `DATA b2)) ->550 | `MOV (`U3 (`DIRECT b1, `DATA b2)) -> 554 551 [mk_byte_from_bits ((false,true,true,true),(false,true,false,true)); b1; b2] 555 | MOV (`U2 (`INDIRECT i1, `A)) ->552 | `MOV (`U2 (`INDIRECT i1, `A)) -> 556 553 [mk_byte_from_bits ((true,true,true,true),(false,true,true,i1))] 557 | MOV (`U2 (`INDIRECT i1, `DIRECT b1)) ->554 | `MOV (`U2 (`INDIRECT i1, `DIRECT b1)) -> 558 555 [mk_byte_from_bits ((true,false,true,false),(false,true,true,i1)); b1] 559 | MOV (`U2 (`INDIRECT i1, `DATA b1)) ->556 | `MOV (`U2 (`INDIRECT i1, `DATA b1)) -> 560 557 [mk_byte_from_bits ((false,true,true,true),(false,true,true,i1)); b1] 561 | MOV (`U5 (`C, `BIT b1)) ->558 | `MOV (`U5 (`C, `BIT b1)) -> 562 559 [mk_byte_from_bits ((true,false,true,false),(false,false,true,false)); b1] 563 | MOV (`U6 (`BIT b1, `C)) ->560 | `MOV (`U6 (`BIT b1, `C)) -> 564 561 [mk_byte_from_bits ((true,false,false,true),(false,false,true,false)); b1] 565 | MOV (`U4 (`DPTR, `DATA16 w)) ->562 | `MOV (`U4 (`DPTR, `DATA16 w)) -> 566 563 let (b1,b2) = from_word w in 567 564 [mk_byte_from_bits ((true,false,false,true),(false,false,false,false)); b1; b2] 568 | MOVC (`A, `A_DPTR) ->565 | `MOVC (`A, `A_DPTR) -> 569 566 [mk_byte_from_bits ((true,false,false,true),(false,false,true,true))] 570 | MOVC (`A, `A_PC) ->567 | `MOVC (`A, `A_PC) -> 571 568 [mk_byte_from_bits ((true,false,false,false),(false,false,true,true))] 572 | MOVX (`U1 (`A, `EXT_INDIRECT i1)) ->569 | `MOVX (`U1 (`A, `EXT_INDIRECT i1)) -> 573 570 [mk_byte_from_bits ((true,true,true,false),(false,false,true,i1))] 574 | MOVX (`U1 (`A, `EXT_IND_DPTR)) ->571 | `MOVX (`U1 (`A, `EXT_IND_DPTR)) -> 575 572 [mk_byte_from_bits ((true,true,true,false),(false,false,false,false))] 576 | MOVX (`U2 (`EXT_INDIRECT i1, `A)) ->573 | `MOVX (`U2 (`EXT_INDIRECT i1, `A)) -> 577 574 [mk_byte_from_bits ((true,true,true,true),(false,false,true,i1))] 578 | MOVX (`U2 (`EXT_IND_DPTR, `A)) ->575 | `MOVX (`U2 (`EXT_IND_DPTR, `A)) -> 579 576 [mk_byte_from_bits ((true,true,true,true),(false,false,false,false))] 580 | MUL(`A, `B) ->577 | `MUL(`A, `B) -> 581 578 [mk_byte_from_bits ((true,false,true,false),(false,true,false,false))] 582 | NOP ->579 | `NOP -> 583 580 [mk_byte_from_bits ((false,false,false,false),(false,false,false,false))] 584 | ORL (`U1(`A, `REG(r1,r2,r3))) ->581 | `ORL (`U1(`A, `REG(r1,r2,r3))) -> 585 582 [mk_byte_from_bits ((false,true,false,false),(true,r1,r2,r3))] 586 | ORL (`U1(`A, `DIRECT b1)) ->583 | `ORL (`U1(`A, `DIRECT b1)) -> 587 584 [mk_byte_from_bits ((false,true,false,false),(false,true,false,true)); b1] 588 | ORL (`U1(`A, `INDIRECT i1)) ->585 | `ORL (`U1(`A, `INDIRECT i1)) -> 589 586 [mk_byte_from_bits ((false,true,false,false),(false,true,true,i1))] 590 | ORL (`U1(`A, `DATA b1)) ->587 | `ORL (`U1(`A, `DATA b1)) -> 591 588 [mk_byte_from_bits ((false,true,false,false),(false,true,false,false)); b1] 592 | ORL (`U2(`DIRECT b1, `A)) ->589 | `ORL (`U2(`DIRECT b1, `A)) -> 593 590 [mk_byte_from_bits ((false,true,false,false),(false,false,true,false)); b1] 594 | ORL (`U2 (`DIRECT b1, `DATA b2)) ->591 | `ORL (`U2 (`DIRECT b1, `DATA b2)) -> 595 592 [mk_byte_from_bits ((false,true,false,false),(false,false,true,true)); b1; b2] 596 | ORL (`U3 (`C, `BIT b1)) ->593 | `ORL (`U3 (`C, `BIT b1)) -> 597 594 [mk_byte_from_bits ((false,true,true,true),(false,false,true,false)); b1] 598 | ORL (`U3 (`C, `NBIT b1)) ->595 | `ORL (`U3 (`C, `NBIT b1)) -> 599 596 [mk_byte_from_bits ((true,false,true,false),(false,false,false,false)); b1] 600 | POP (`DIRECT b1) ->597 | `POP (`DIRECT b1) -> 601 598 [mk_byte_from_bits ((true,true,false,true),(false,false,false,false)); b1] 602 | PUSH (`DIRECT b1) ->599 | `PUSH (`DIRECT b1) -> 603 600 [mk_byte_from_bits ((true,true,false,false),(false,false,false,false)); b1] 604 | RET ->601 | `RET -> 605 602 [mk_byte_from_bits ((false,false,true,false),(false,false,true,false))] 606 | RETI ->603 | `RETI -> 607 604 [mk_byte_from_bits ((false,false,true,true),(false,false,true,false))] 608 | RL `A ->605 | `RL `A -> 609 606 [mk_byte_from_bits ((false,false,true,false),(false,false,true,true))] 610 | RLC `A ->607 | `RLC `A -> 611 608 [mk_byte_from_bits ((false,false,true,true),(false,false,true,true))] 612 | RR `A ->609 | `RR `A -> 613 610 [mk_byte_from_bits ((false,false,false,false),(false,false,true,true))] 614 | RRC `A ->611 | `RRC `A -> 615 612 [mk_byte_from_bits ((false,false,false,true),(false,false,true,true))] 616 | SETB `C ->613 | `SETB `C -> 617 614 [mk_byte_from_bits ((true,true,false,true),(false,false,true,true))] 618 | SETB (`BIT b1) ->615 | `SETB (`BIT b1) -> 619 616 [mk_byte_from_bits ((true,true,false,true),(false,false,true,false)); b1] 620 | SJMP (`REL b1) ->617 | `SJMP (`REL b1) -> 621 618 [mk_byte_from_bits ((true,false,false,false),(false,false,false,false)); b1] 622 | SUBB (`A, `REG(r1,r2,r3)) ->619 | `SUBB (`A, `REG(r1,r2,r3)) -> 623 620 [mk_byte_from_bits ((true,false,false,true),(true,r1,r2,r3))] 624 | SUBB (`A, `DIRECT b1) ->621 | `SUBB (`A, `DIRECT b1) -> 625 622 [mk_byte_from_bits ((true,false,false,true),(false,true,false,true)); b1] 626 | SUBB (`A, `INDIRECT i1) ->623 | `SUBB (`A, `INDIRECT i1) -> 627 624 [mk_byte_from_bits ((true,false,false,true),(false,true,true,i1))] 628 | SUBB (`A, `DATA b1) ->625 | `SUBB (`A, `DATA b1) -> 629 626 [mk_byte_from_bits ((true,false,false,true),(false,true,false,false)); b1] 630 | SWAP `A ->627 | `SWAP `A -> 631 628 [mk_byte_from_bits ((true,true,false,false),(false,true,false,false))] 632 | XCH (`A, `REG(r1,r2,r3)) ->629 | `XCH (`A, `REG(r1,r2,r3)) -> 633 630 [mk_byte_from_bits ((true,true,false,false),(true,r1,r2,r3))] 634 | XCH (`A, `DIRECT b1) ->631 | `XCH (`A, `DIRECT b1) -> 635 632 [mk_byte_from_bits ((true,true,false,false),(false,true,false,true)); b1] 636 | XCH (`A, `INDIRECT i1) ->633 | `XCH (`A, `INDIRECT i1) -> 637 634 [mk_byte_from_bits ((true,true,false,false),(false,true,true,i1))] 638 | XCHD(`A, `INDIRECT i1) ->635 | `XCHD(`A, `INDIRECT i1) -> 639 636 [mk_byte_from_bits ((true,true,false,true),(false,true,true,i1))] 640 | XRL(`U1(`A, `REG(r1,r2,r3))) ->637 | `XRL(`U1(`A, `REG(r1,r2,r3))) -> 641 638 [mk_byte_from_bits ((false,true,true,false),(true,r1,r2,r3))] 642 | XRL(`U1(`A, `DIRECT b1)) ->639 | `XRL(`U1(`A, `DIRECT b1)) -> 643 640 [mk_byte_from_bits ((false,true,true,false),(false,true,false,true)); b1] 644 | XRL(`U1(`A, `INDIRECT i1)) ->641 | `XRL(`U1(`A, `INDIRECT i1)) -> 645 642 [mk_byte_from_bits ((false,true,true,false),(false,true,true,i1))] 646 | XRL(`U1(`A, `DATA b1)) ->643 | `XRL(`U1(`A, `DATA b1)) -> 647 644 [mk_byte_from_bits ((false,true,true,false),(false,true,false,false)); b1] 648 | XRL(`U2(`DIRECT b1, `A)) ->645 | `XRL(`U2(`DIRECT b1, `A)) -> 649 646 [mk_byte_from_bits ((false,true,true,false),(false,false,true,false)); b1] 650 | XRL(`U2(`DIRECT b1, `DATA b2)) ->647 | `XRL(`U2(`DIRECT b1, `DATA b2)) -> 651 648 [mk_byte_from_bits ((false,true,true,false),(false,false,true,true)); b1; b2] 652 649 ;; -
Deliverables/D4.1/BitVectors.ml
r95 r97 20 20 b1::b2::b3::b4::r -> [b1;b2;b3;b4],r 21 21 | _ -> assert false 22 let bits_of_byte = 23 function 24 [b1;b2;b3;b4;b5;b6;b7;b8] -> (b1,b2,b3,b4),(b5,b6,b7,b8) 25 | _ -> assert false 22 26 let mk_byte7 b1 b2 b3 n1 = b1::b2::b3::n1 23 27 let from_byte7 = … … 32 36 let mk_word11 = mk_byte7 33 37 let from_word11 = from_byte7 34 35 let to_bits l = l36 38 37 39 let get_bit index l = -
Deliverables/D4.1/BitVectors.mli
r95 r97 18 18 val mk_byte_from_bits: ((bit * bit * bit * bit) * (bit * bit * bit * bit)) -> byte 19 19 val from_byte: byte -> nibble * nibble 20 val bits_of_byte: byte -> ((bit * bit * bit * bit) * (bit * bit * bit * bit)) 20 21 val mk_word: byte -> byte -> word 21 22 val from_word: word -> byte * byte … … 23 24 val from_word11: word11 -> bit * bit * bit * byte 24 25 25 val to_bits: 'a vect -> bit list26 26 val get_bit: 'a vect -> int -> bit option 27 27 val set_bit: 'a vect -> int -> bit -> 'a vect option -
Deliverables/D4.1/physical.ml
r92 r97 14 14 15 15 let byte7_of_byte b = 16 let bits = to_bitsb in17 match bitswith18 [false;b1;b2;b3;b4;b5;b6;b7] -> mk_byte7 b1 b2 b3 (mk_nibble b4 b5 b6 b7)16 let n1,n2 = from_byte b in 17 match from_nibble n1 with 18 (false,b1,b2,b3) -> mk_byte7 b1 b2 b3 n2 19 19 | _ -> raise Byte7_conversion 20 20 … … 61 61 ;; 62 62 63 let byte_of_byte7 ([b1;b2;b3]::n) = 64 [false;b1;b2;b3]::n 63 let byte_of_byte7 = 64 function 65 ([b1;b2;b3]::n) -> [false;b1;b2;b3]::n 66 | _ -> assert false 65 67 ;;
Note: See TracChangeset
for help on using the changeset viewer.