Move signed_byte to Bit

master
Fabien Freling 2015-08-11 22:49:27 +02:00
parent 845d4fff8b
commit 54def17c26
2 changed files with 7 additions and 9 deletions

View File

@ -4,3 +4,9 @@ let is_set num i =
else
(num lsr i) land 0b00000001 <> 0
let two_complement n =
(lnot n) + 1
let signed_byte n =
if n land 0x80 <> 0 then -((two_complement n) land 0xFF)
else n

View File

@ -127,14 +127,6 @@ let pop_stack cpu mem =
cpu.reg.sp <- (cpu.reg.sp + 1) mod 0xFFFF;
merge_bytes low high
let two_complement n =
(lnot n) + 1
let signed_byte n =
if n land 0x80 <> 0 then -((two_complement n) land 0xFF)
else n
(**
http://imrannazar.com/GameBoy-Z80-Opcode-Map
@ -172,7 +164,7 @@ let run cpu (mem: Memory.map) =
(* jump *)
| '\x20' -> let n = read_pc_byte cpu mem in
let s = signed_byte n in
let s = Bit.signed_byte n in
let inst = sprintf "JR \tNZ, 0x%02X (%d)" n s in
if cpu.flag.z = false then
begin