about summary refs log tree commit diff stats
path: root/subx
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-07-30 09:56:53 -0700
committerKartik Agaram <vc@akkartik.com>2018-07-30 09:56:53 -0700
commit126b4144013114705604fb7c9dc323bc9b4e6ea2 (patch)
treecce0c64877eb59be1823cf1a2285f57e50452e28 /subx
parent5cea4ef897c0aac2b35315c4208140e0ed66bd34 (diff)
downloadmu-126b4144013114705604fb7c9dc323bc9b4e6ea2.tar.gz
4450
Diffstat (limited to 'subx')
-rw-r--r--subx/012direct_addressing.cc26
-rw-r--r--subx/022check_instruction.cc5
2 files changed, 31 insertions, 0 deletions
diff --git a/subx/012direct_addressing.cc b/subx/012direct_addressing.cc
index 43b1137b..aefe3214 100644
--- a/subx/012direct_addressing.cc
+++ b/subx/012direct_addressing.cc
@@ -87,6 +87,32 @@ case 0x29: {  // subtract r32 from r/m32
   break;
 }
 
+//:: multiply
+
+:(before "End Initialize Op Names(name)")
+put(name_0f, "af", "multiply r32 into rm32");
+
+:(scenario multiply_r32_into_r32)
+% Reg[EAX].i = 4;
+% Reg[EBX].i = 2;
+== 0x1
+# op      ModR/M  SIB   displacement  immediate
+  0f af   d8                                      # subtract EBX into EAX
+# ModR/M in binary: 11 (direct mode) 011 (src EBX) 000 (dest EAX)
++run: multiply EBX into r/m32
++run: r/m32 is EAX
++run: storing 0x00000008
+
+:(before "End Two-Byte Opcodes Starting With 0f")
+case 0xaf: {  // multiply r32 into r/m32
+  uint8_t modrm = next();
+  uint8_t arg2 = (modrm>>3)&0x7;
+  trace(90, "run") << "multiply " << rname(arg2) << " into r/m32" << end();
+  int32_t* arg1 = effective_address(modrm);
+  BINARY_ARITHMETIC_OP(*, *arg1, Reg[arg2].i);
+  break;
+}
+
 //:: and
 
 :(before "End Initialize Op Names(name)")
diff --git a/subx/022check_instruction.cc b/subx/022check_instruction.cc
index 31834b38..a4a4ec14 100644
--- a/subx/022check_instruction.cc
+++ b/subx/022check_instruction.cc
@@ -558,6 +558,11 @@ put(Permitted_operands_0f, "8d", 0x08);
 put(Permitted_operands_0f, "8e", 0x08);
 put(Permitted_operands_0f, "8f", 0x08);
 
+//// Class M: using ModR/M byte
+//  imm32 imm8  disp32 |disp16  disp8 subop modrm
+//  0     0     0      |0       0     0     1
+put(Permitted_operands_0f, "af", 0x01);
+
 :(code)
 void check_operands_0f(const line& inst, const word& op) {
   uint8_t expected_bitvector = get(Permitted_operands_0f, op.data);
id='n225' href='#n225'>225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442