From a9e15285cb6c364a3cf1fa06da0cf27f4945fe29 Mon Sep 17 00:00:00 2001 From: Preston Skupinski Date: Sun, 12 Jun 2011 18:54:16 -0400 Subject: [PATCH] added JMP absolute indexed x indirect --- TODO | 1 - cpu.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 9efcc2c..5e219b5 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,6 @@ Testing: - Tests needed for interrupt support - Tests needed for the numerous other operations added Operations Not Yet Implemented: -- 0x7c : JMP absolute indexed x indirect - 0xcb : WAI - 0xdb : STP - 0xfc : JSR absolute indexed x indirect diff --git a/cpu.js b/cpu.js index 73a797a..6455fa3 100644 --- a/cpu.js +++ b/cpu.js @@ -102,6 +102,7 @@ function CPU_65816() { 0x3b : TSC, 0x4c : JMP_absolute, 0x5c : JMP_absolute_long, 0xdc : JMP_absolute_indirect_long, + 0x7c : JMP_absolute_indexed_x_indirect, 0x6c : JMP_absolute_indirect, 0x80 : BRA, 0x82 : BRL, 0xf0 : BEQ, 0xd0 : BNE, 0x90 : BCC, 0xb0 : BCS, 0x50 : BVC, 0x70 : BVS, 0x10 : BPL, 0x30 : BMI, @@ -4036,6 +4037,34 @@ var JMP_absolute_indirect_long = { } }; +var JMP_absolute_indexed_x_indirect = { + bytes_required:function() { + return 3; + }, + execute:function(cpu, bytes) { + var location = ((bytes[1]<<8)|bytes[0])+cpu.r.x; + var bank = cpu.r.k; + if(location&0x10000) { + bank++; + } + location &= 0xffff; + var indirect_location_low_byte = cpu.mmu.read_byte_long(location, bank); + var indirect_location_high_byte = cpu.mmu.read_byte_long(location+1, bank); + var indirect_location = (indirect_location_high_byte<<8) | + indirect_location_low_byte; + var low_byte = cpu.mmu.read_byte(indirect_location); + bank = cpu.r.k; + if(indirect_location===0xffff) { + indirect_location = 0; + bank++; + } else { + indirect_location++; + } + var high_byte = cpu.mmu.read_byte_long(indirect_location, bank); + cpu.r.pc = (high_byte<<8)|low_byte; + } +}; + var JMP_absolute = { bytes_required:function() { return 3;