Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DVI works.

  • Loading branch information...
commit 1f71b9b4ef3ea546bb40e4d3dd6c901fe179ef56 1 parent 1fc5aee
Jacob Peck authored
Showing with 58 additions and 2 deletions.
  1. +35 −2 src/CPU.io
  2. +23 −0 test/test.io
37 src/CPU.io
View
@@ -301,9 +301,10 @@ CPU := Object clone do(
new_val := b_val * a_val
if(new_val < 0, new_val = twosCompliment(-new_val))
- ex := ((b_val * a_val) >> 16) & 0xffff
+ ex_val := ((b_val * a_val) >> 16) & 0xffff
+ if(ex_val < 0, new_val = twosCompliment(-ex_val))
- self setEX(ex)
+ self setEX(ex_val)
self write_ram(b_ptr, new_val)
self incCycle incCycle
@@ -334,6 +335,38 @@ CPU := Object clone do(
self incCycle incCycle incCycle
)
+ DVI := method(word,
+ a := word getA
+ b := word getB
+
+ self parseValue(a, true)
+ a_ptr := self addr_pointer
+ self parseValue(b, false)
+ b_ptr := self addr_pointer
+
+ a_val := self read_ram(a_ptr)
+ b_val := self read_ram(b_ptr)
+
+ if(a_val at(15) == 1, a_val = -(twosCompliment(a_val)))
+ if(b_val at(15) == 1, b_val = -(twosCompliment(b_val)))
+
+ if(a_val == 0x0000,
+ self write_ram(b_ptr, 0x0000)
+ self setEX(0x0000)
+ ,
+ if(a_val at(15) == 1, a_val = -(twosCompliment(a_val)))
+ if(b_val at(15) == 1, b_val = -(twosCompliment(b_val)))
+ new_val := (b_val / a_val) & 0xffff
+ if(new_val < 0, new_val = twosCompliment(-new_val))
+ self write_ram(b_ptr, new_val)
+ ex_val := ((b_val << 16) / a_val ) & 0xffff
+ if(ex_val < 0, ex_val = twosCompliment(-ex_val))
+ self setEX(ex_val)
+ )
+
+ self incCycle incCycle incCycle
+ )
+
// ram manipulations
read_ram := method(addr,
retval := nil
23 test/test.io
View
@@ -149,5 +149,28 @@ c printRegisters
c printRamDump(1)
writeln("final value of A (should be 0x0001): " .. pad(c A))
assert(c A == 0x0001)
+assert(c EX == 0x8000)
+writeln(c)
+writeln("\n\n")
+
+writeln("-------------------------------DVI test: DVI A, [A]-------------")
+c initialize
+c write_ram(3, twosCompliment(2)) // 0003: -2
+c setA(0x0003)
+c printRegisters
+c printRamDump(1)
+writeln("initial value of A (should be 0x0003): " .. pad(c A))
+assert(c A == 0x0003)
+w := Word with("0010000000000111" fromBase(2))
+writeln(c)
+
+writeln
+writeln("After DVI op")
+c parseOpcode(w)
+c printRegisters
+c printRamDump(1)
+writeln("final value of A (should be 0xffff): " .. pad(c A))
+assert(c A == 0xffff)
+assert(c EX == 0x8000)
writeln(c)
writeln("\n\n")
Please sign in to comment.
Something went wrong with that request. Please try again.