Skip to content

Commit

Permalink
Fixed #33: fixed memory map with opcode/instruction mode checks added…
Browse files Browse the repository at this point in the history
… to new udis disassembler

* added memory map menu item selection
* reformatted memory maps for Atari 800 & 5200 into single file
  • Loading branch information
robmcmullen committed Apr 11, 2016
1 parent 25bdfa8 commit 3e6b124
Show file tree
Hide file tree
Showing 7 changed files with 1,062 additions and 988 deletions.
8 changes: 7 additions & 1 deletion omnivore/arch/disasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ class BaseDisassembler(disasm.Disassembler):
name = "generic disassembler"
cpu = "undefined"
allow_undocumented = False
read_instructions = set()
write_instructions = set()
rw_modes = set()

cached_miniassemblers = {}

def __init__(self, memory_map=None, hex_lower=True, mnemonic_lower=False):
disasm.Disassembler.__init__(self, self.cpu, memory_map=memory_map, allow_undocumented=self.allow_undocumented, hex_lower=hex_lower, mnemonic_lower=mnemonic_lower)
disasm.Disassembler.__init__(self, self.cpu, memory_map, self.allow_undocumented, hex_lower, mnemonic_lower, self.read_instructions, self.write_instructions, self.rw_modes)

@classmethod
def get_miniassembler(cls, cpu):
Expand All @@ -30,6 +33,9 @@ def assemble_text(self, pc, cmd):
class Basic6502Disassembler(BaseDisassembler):
name = "6502"
cpu = "6502"
read_instructions = {"adc", "and", "asl", "bit", "cmp", "cpx", "cpy", "dec", "eor", "inc", "lda", "ldx", "ldy", "lsr", "ora", "rol", "ror", "sbc", "jsr", "jmp"}
write_instructions = {"sax", "shx", "shy", "slo", "sre", "sta", "stx", "sty"}
rw_modes = {"absolute", "absolutex", "absolutey", "indirect", "indirectx", "indirecty", "relative", "zeropage", "zeropagex", "zeropagey"}


class Undocumented6502Disassembler(Basic6502Disassembler):
Expand Down
24 changes: 16 additions & 8 deletions omnivore/arch/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import fonts
import colors
import disasm
import machine_atari800
import machine_atari5200
import memory_map
import antic_renderers

class Machine(HasTraits):
Expand All @@ -26,7 +25,7 @@ class Machine(HasTraits):

disassembler = Any(transient=True)

memory_map = Dict(key_trait=Int, value_trait=Str)
memory_map = Any(transient=True)

antic_font_data = Any

Expand Down Expand Up @@ -160,7 +159,7 @@ def _disassembler_default(self):
return predefined['disassembler'][0]

def _memory_map_default(self):
return {}
return predefined['memory_map'][0]

def _antic_font_default(self):
return self.get_antic_font()
Expand Down Expand Up @@ -310,6 +309,10 @@ def set_disassembler(self, disassembler):
self.disassembler = disassembler
self.disassembler_change_event = True

def set_memory_map(self, memory_map):
self.memory_map = memory_map
self.disassembler_change_event = True

def set_font(self, font=None, font_renderer=None):
if font is None:
font = self.antic_font_data
Expand Down Expand Up @@ -393,13 +396,13 @@ def get_disassembler(self, hex_lower, mnemonic_lower):

Generic6502 = Machine(name="Generic 6502", disassembler=disasm.Basic6502Disassembler)

Atari800 = Machine(name="Atari 800", disassembler=disasm.Basic6502Disassembler, memory_map=dict(machine_atari800.memmap))
Atari800 = Machine(name="Atari 800", disassembler=disasm.Basic6502Disassembler, memory_map=memory_map.Atari800MemoryMap)

Atari800Undoc = Machine(name="Atari 800 (show undocumented opcodes)", disassembler=disasm.Undocumented6502Disassembler, memory_map=dict(machine_atari800.memmap))
Atari800Undoc = Machine(name="Atari 800 (show undocumented opcodes)", disassembler=disasm.Undocumented6502Disassembler, memory_map=memory_map.Atari800MemoryMap)

Atari800Flagged = Machine(name="Atari 800 (highlight undocumented opcodes)", disassembler=disasm.Flagged6502Disassembler, memory_map=dict(machine_atari800.memmap))
Atari800Flagged = Machine(name="Atari 800 (highlight undocumented opcodes)", disassembler=disasm.Flagged6502Disassembler, memory_map=memory_map.Atari800MemoryMap)

Atari5200 = Machine(name="Atari 5200", disassembler=disasm.Basic6502Disassembler, memory_map=dict(machine_atari5200.memmap))
Atari5200 = Machine(name="Atari 5200", disassembler=disasm.Basic6502Disassembler, memory_map=memory_map.Atari5200MemoryMap)



Expand All @@ -411,6 +414,11 @@ def get_disassembler(self, hex_lower, mnemonic_lower):
Atari800Flagged,
Atari5200,
],
"memory_map": [
memory_map.EmptyMemoryMap,
memory_map.Atari800MemoryMap,
memory_map.Atari5200MemoryMap,
],
"disassembler": [
disasm.Basic6502Disassembler,
disasm.Undocumented6502Disassembler,
Expand Down
155 changes: 0 additions & 155 deletions omnivore/arch/machine_atari5200.py

This file was deleted.

Loading

0 comments on commit 3e6b124

Please sign in to comment.