emustudio / edigen

Emulator Disassembler Generator
GNU General Public License v3.0
4 stars 0 forks source link

Implement multiple decoding strategies #32

Closed vbmacher closed 4 years ago

vbmacher commented 4 years ago

In SSEM, bits in memory cells are reversed and stored in two's complement format. I would like to decode the numbers applying both:

I would like to achieve that as follows:

instruction = "JMP": line(5)     ignore8(8) 000 ignore16(16) |
              "JPR": line(5)     ignore8(8) 100 ignore16(16) |
              "LDN": line(5)     ignore8(8) 010 ignore16(16) |
              "STO": line(5)     ignore8(8) 110 ignore16(16) |
              "SUB": line(5)     ignore8(8) 001 ignore16(16) |
              "CMP": 00000       ignore8(8) 011 ignore16(16) |
              "STP": 00000       ignore8(8) 111 ignore16(16);

line = arg: arg(5);

ignore8 = arg: arg(8);

ignore16 = arg: arg(16);

%%

"%s %d" = instruction line(shift_left, shift_left, shift_left, bit_reverse, absolute) ignore8 ignore16;
"%s" = instruction ignore8 ignore16;

As in the example above, I would like to apply multiple decoding strategies in parenthesis. They will be applied in order from left to right as defined.

vbmacher commented 4 years ago

I've updated the disassembler template. Here you can see the implementation of the strategies in emuLib: https://github.com/emustudio/emuLib/blob/master/src/main/java/net/emustudio/emulib/plugins/cpu/DecodingStrategy.java