about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-10-21 20:36:43 -0700
committerKartik Agaram <vc@akkartik.com>2018-10-21 20:36:43 -0700
commit417a05ee7dbecbf846c54cd1e186e000415fb0a3 (patch)
tree9534f3e40e9e533b9818bac6bfa65095d2e1f30f
parentb84753807126665df66f85abba7afaaba7456e64 (diff)
downloadmu-417a05ee7dbecbf846c54cd1e186e000415fb0a3.tar.gz
4712
-rw-r--r--subx/opcodes181
1 files changed, 92 insertions, 89 deletions
diff --git a/subx/opcodes b/subx/opcodes
index f1229922..e39eedfe 100644
--- a/subx/opcodes
+++ b/subx/opcodes
@@ -1,91 +1,94 @@
 Opcodes currently supported by SubX:
-  01: add r32 to rm32
-  03: add rm32 to r32
-  05: add imm32 to R0 (EAX)
-  09: rm32 = bitwise OR of r32 with rm32
-  0b: r32 = bitwise OR of r32 with rm32
-  0d: R0 = bitwise OR of imm32 with R0 (EAX)
-  21: rm32 = bitwise AND of r32 with rm32
-  23: r32 = bitwise AND of r32 with rm32
-  25: R0 = bitwise AND of imm32 with R0 (EAX)
-  29: subtract r32 from rm32
-  2b: subtract rm32 from r32
-  2d: subtract imm32 from R0 (EAX)
-  31: rm32 = bitwise XOR of r32 with rm32
-  33: r32 = bitwise XOR of r32 with rm32
-  35: R0 = bitwise XOR of imm32 with R0 (EAX)
-  39: compare: set SF if rm32 < r32
-  3b: compare: set SF if r32 < rm32
-  3d: compare: set SF if R0 < imm32
-  40: increment R0 (EAX)
-  41: increment R1 (ECX)
-  42: increment R2 (EDX)
-  43: increment R3 (EBX)
-  44: increment R4 (ESP)
-  45: increment R5 (EBP)
-  46: increment R6 (ESI)
-  47: increment R7 (EDI)
-  48: decrement R0 (EAX)
-  49: decrement R1 (ECX)
-  4a: decrement R2 (EDX)
-  4b: decrement R3 (EBX)
-  4c: decrement R4 (ESP)
-  4d: decrement R5 (EBP)
-  4e: decrement R6 (ESI)
-  4f: decrement R7 (EDI)
-  50: push R0 (EAX) to stack
-  51: push R1 (ECX) to stack
-  52: push R2 (EDX) to stack
-  53: push R3 (EBX) to stack
-  54: push R4 (ESP) to stack
-  55: push R5 (EBP) to stack
-  56: push R6 (ESI) to stack
-  57: push R7 (EDI) to stack
-  58: pop top of stack to R0 (EAX)
-  59: pop top of stack to R1 (ECX)
-  5a: pop top of stack to R2 (EDX)
-  5b: pop top of stack to R3 (EBX)
-  5c: pop top of stack to R4 (ESP)
-  5d: pop top of stack to R5 (EBP)
-  5e: pop top of stack to R6 (ESI)
-  5f: pop top of stack to R7 (EDI)
-  68: push imm32 to stack
-  74: jump disp8 bytes away if ZF is set
-  75: jump disp8 bytes away if ZF is not set
-  7c: jump disp8 bytes away if lesser (SF != OF)
-  7d: jump disp8 bytes away if greater or equal (SF == OF)
-  7e: jump disp8 bytes away if lesser or equal (ZF is set or SF != OF)
-  7f: jump disp8 bytes away if greater (ZF is unset, SF == OF)
-  81: combine rm32 with imm32 based on subop
-  87: swap the contents of r32 and rm32
-  88: copy r8 (lowermost byte of r32) to r8/m8-at-r32
-  89: copy r32 to rm32
-  8a: copy r8/m8-at-r32 to r8 (lowermost byte of r32)
-  8b: copy rm32 to r32
-  8d: load effective address of memory in rm32 into r32
-  8f: pop top of stack to rm32
-  b8: copy imm32 to R0 (EAX)
-  b9: copy imm32 to R1 (ECX)
-  ba: copy imm32 to R2 (EDX)
-  bb: copy imm32 to R3 (EBX)
-  bc: copy imm32 to R4 (ESP)
-  bd: copy imm32 to R5 (EBP)
-  be: copy imm32 to R6 (ESI)
-  bf: copy imm32 to R7 (EDI)
-  c3: return from most recent unfinished call
-  c7: copy imm32 to rm32
-  cd: software interrupt
-  e8: call disp32
-  e9: jump disp16 bytes away
-  eb: jump disp8 bytes away
-  f4: halt
-  f7: bitwise complement of rm32
-  ff: inc/dec/jump/push/call rm32 based on subop
-  0f 84: jump disp16 bytes away if ZF is set
-  0f 85: jump disp16 bytes away if ZF is not set
-  0f 8c: jump disp16 bytes away if lesser (SF != OF)
-  0f 8d: jump disp16 bytes away if greater or equal (SF == OF)
-  0f 8e: jump disp16 bytes away if lesser or equal (ZF is set or SF != OF)
-  0f 8f: jump disp16 bytes away if greater (ZF is unset, SF == OF)
-  0f af: multiply rm32 into r32
+  01: add r32 to rm32 (add)
+  03: add rm32 to r32 (add)
+  05: add imm32 to EAX (add)
+  09: rm32 = bitwise OR of r32 with rm32 (or)
+  0b: r32 = bitwise OR of r32 with rm32 (or)
+  0d: EAX = bitwise OR of imm32 with EAX (or)
+  21: rm32 = bitwise AND of r32 with rm32 (and)
+  23: r32 = bitwise AND of r32 with rm32 (and)
+  25: EAX = bitwise AND of imm32 with EAX (and)
+  29: subtract r32 from rm32 (sub)
+  2b: subtract rm32 from r32 (sub)
+  2d: subtract imm32 from EAX (sub)
+  31: rm32 = bitwise XOR of r32 with rm32 (xor)
+  33: r32 = bitwise XOR of r32 with rm32 (xor)
+  35: EAX = bitwise XOR of imm32 with EAX (xor)
+  39: compare: set SF if rm32 < r32 (cmp)
+  3b: compare: set SF if r32 < rm32 (cmp)
+  3d: compare: set SF if EAX < imm32 (cmp)
+  40: increment EAX (inc)
+  41: increment ECX (inc)
+  42: increment EDX (inc)
+  43: increment EBX (inc)
+  44: increment ESP (inc)
+  45: increment EBP (inc)
+  46: increment ESI (inc)
+  47: increment EDI (inc)
+  48: decrement EAX (dec)
+  49: decrement ECX (dec)
+  4a: decrement EDX (dec)
+  4b: decrement EBX (dec)
+  4c: decrement ESP (dec)
+  4d: decrement EBP (dec)
+  4e: decrement ESI (dec)
+  4f: decrement EDI (dec)
+  50: push EAX to stack (push)
+  51: push ECX to stack (push)
+  52: push EDX to stack (push)
+  53: push EBX to stack (push)
+  54: push ESP to stack (push)
+  55: push EBP to stack (push)
+  56: push ESI to stack (push)
+  57: push EDI to stack (push)
+  58: pop top of stack to EAX (pop)
+  59: pop top of stack to ECX (pop)
+  5a: pop top of stack to EDX (pop)
+  5b: pop top of stack to EBX (pop)
+  5c: pop top of stack to ESP (pop)
+  5d: pop top of stack to EBP (pop)
+  5e: pop top of stack to ESI (pop)
+  5f: pop top of stack to EDI (pop)
+  68: push imm32 to stack (push)
+  74: jump disp8 bytes away if equal, if ZF is set (jcc/jz/je)
+  75: jump disp8 bytes away if not equal, if ZF is not set (jcc/jnz/jne)
+  7c: jump disp8 bytes away if lesser, if SF != OF (jcc/jl/jnge)
+  7d: jump disp8 bytes away if greater or equal, if SF == OF (jcc/jge/jnl)
+  7e: jump disp8 bytes away if lesser or equal, if ZF is set or SF != OF (jcc/jle/jng)
+  7f: jump disp8 bytes away if greater, if ZF is unset and SF == OF (jcc/jg/jnle)
+  81: combine rm32 with imm32 based on subop (add/sub/and/or/xor/cmp)
+  87: swap the contents of r32 and rm32 (xchg)
+  88: copy r8 to r8/m8-at-r32
+  89: copy r32 to rm32 (mov)
+  8a: copy r8/m8-at-r32 to r8
+  8b: copy rm32 to r32 (mov)
+  8d: copy address in rm32 into r32 (lea)
+  8f: pop top of stack to rm32 (pop)
+  b8: copy imm32 to EAX (mov)
+  b9: copy imm32 to ECX (mov)
+  ba: copy imm32 to EDX (mov)
+  bb: copy imm32 to EBX (mov)
+  bc: copy imm32 to ESP (mov)
+  bd: copy imm32 to EBP (mov)
+  be: copy imm32 to ESI (mov)
+  bf: copy imm32 to EDI (mov)
+  c3: return from most recent unfinished call (ret)
+  c7: copy imm32 to rm32 (mov)
+  cd: software interrupt (int)
+  e8: call disp32 (call)
+  e9: jump disp16 bytes away (jmp)
+  eb: jump disp8 bytes away (jmp)
+  f4: halt (hlt)
+  f7: negate/multiply rm32 (with EAX if necessary) depending on subop (neg/mul)
+  ff: increment/decrement/jump/push/call rm32 based on subop (inc/dec/jmp/push/call)
+  0f 84: jump disp16 bytes away if equal, if ZF is set (jcc/jz/je)
+  0f 85: jump disp16 bytes away if not equal, if ZF is not set (jcc/jnz/jne)
+  0f 8c: jump disp16 bytes away if lesser, if SF != OF (jcc/jl/jnge)
+  0f 8d: jump disp16 bytes away if greater or equal, if SF == OF (jcc/jge/jnl)
+  0f 8e: jump disp16 bytes away if lesser or equal, if ZF is set or SF != OF (jcc/jle/jng)
+  0f 8f: jump disp16 bytes away if greater, if ZF is unset and SF == OF (jcc/jg/jnle)
+  0f af: multiply rm32 into r32 (imul)
 Run `subx help instructions` for details on words like 'r32' and 'disp8'.
+For complete details on these instructions, consult the IA-32 manual (volume 2).
+There's various versions of it online, such as https://c9x.me/x86.
+The mnemonics in brackets will help you locate each instruction.
ref='#n452'>452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711