about summary refs log tree commit diff stats
path: root/subx/012direct_addressing.cc
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-07-30 11:23:23 -0700
committerKartik Agaram <vc@akkartik.com>2018-07-30 11:23:23 -0700
commit62c6d1638a2682bbc291987e2d6cb87b5c5d8da1 (patch)
tree2e23d80fac375253199082854d69270e07c0d008 /subx/012direct_addressing.cc
parentb4c78a5939443d4fe08510b75ea51fbad94c2211 (diff)
downloadmu-62c6d1638a2682bbc291987e2d6cb87b5c5d8da1.tar.gz
4456 - example with function calls: factorial
I found a bug with multiply in the process; another case (after the swap
of call/jump opcodes in 4453) where there's no point improving testing.

Unit tests can only tell us if our instructions are internally
consistent. Validating against a real machine has to be manual.

I'm definitely feeling the pain of debugging machine code now, that's
for sure. Going over an instruction trace, comparing the state of
registers line by line.
Diffstat (limited to 'subx/012direct_addressing.cc')
-rw-r--r--subx/012direct_addressing.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/subx/012direct_addressing.cc b/subx/012direct_addressing.cc
index aefe3214..e4f7f8a9 100644
--- a/subx/012direct_addressing.cc
+++ b/subx/012direct_addressing.cc
@@ -109,7 +109,7 @@ case 0xaf: {  // multiply r32 into r/m32
   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);
+  BINARY_ARITHMETIC_OP(*, Reg[arg2].i, *arg1);
   break;
 }
 
@@ -363,6 +363,7 @@ case 0x56:
 case 0x57: {  // push r32 to stack
   uint8_t reg = op & 0x7;
   trace(90, "run") << "push " << rname(reg) << end();
+//?   cerr << "push: " << NUM(reg) << ": " << Reg[reg].u << " => " << Reg[ESP].u << '\n';
   push(Reg[reg].u);
   break;
 }
@@ -409,7 +410,9 @@ case 0x5e:
 case 0x5f: {  // pop stack into r32
   uint8_t reg = op & 0x7;
   trace(90, "run") << "pop into " << rname(reg) << end();
+//?   cerr << "pop from " << Reg[ESP].u << '\n';
   Reg[reg].u = pop();
+//?   cerr << "=> " << NUM(reg) << ": " << Reg[reg].u << '\n';
   break;
 }
 :(code)