M68k - 24-bit IDA Pro addressing?

I'm trying to parse a BIOS image for a 68000 and I'm having trouble getting IDA Pro 6.5 to cross-reference correctly.

For those who don't know, the Motorola 68000 has a couple of interesting features / quirks related to addressing:

  • When a 16-bit absolute address is given, the processor sign expands it to 32 bits before dereferencing.
  • 68K uses a 24-bit address bus, so the high byte in a 32-bit address is ignored.

The original authors of this BIOS took advantage of these properties in several places to save multiple bytes: for any address above 0xFF8000, an address can be specified using only two bytes instead of four. For example, if I wanted to access memory at address 0xFF9134:

lea (0x9134).w, a0
< sign extension >
lea (0xFFFF9134).l, a0
< discard high byte >
lea 0xFF9134, a0

      

The problem I am running into is that IDA Pro does sign expansion, but then considers the entire 32-bit address instead of just the least significant 24 bits. IDA tries to cross-reference addresses that don't exist (or at least shouldn't) and any segments / code / data I have in the 0xFF8000-0xFFFFFF address range are completely ignored.

I'm still new to IDA Pro, so I don't know if this will be resolved with a script, let alone how to write such a thing. Is there a way I can get the disassembler to handle this dirty / clever addressing trick correctly?

+3


source to share


1 answer


I have the same problem. My solution was to create a custom_ana callback and then change each operand address to be op.add & = 0xFFFFFF. But it’s not that easy. Because at the moment you have not fully recognized "cmd" and you have to prepare it from your own code.



0


source







All Articles