tum-ei-eda / M2-ISA-R

CoreDSL2 Parser with backend to generate simulation code for the ETISS instruction set simulator
https://tum-ei-eda.github.io/M2-ISA-R/
Apache License 2.0
5 stars 6 forks source link

Mnemonic support & Improve Disassembler #21

Open PhilippvK opened 1 year ago

PhilippvK commented 1 year ago

Changes

wysiwyng commented 1 year ago

args_disass removal is fine, this was left in for compatibility with legacy CoreDSL2 files.

PhilippvK commented 1 year ago

i would not necessarily say this behavior is correct, how does e.g. objdump handle repeated 0x0000 codepoints?

objdump reads ELF files instead raw .bin files, aka it only dumps the sections which make sense, skipping the zeros in between. Our disassembler also does not print the correct adresses (e.g. staring with 80000000) because that information in not contained in the binary.

RISCV objdump output with --disassemble-all for reference:

800003c0 <pass>:
800003c0:       0ff0000f                fence
800003c4:       00100193                li      gp,1
800003c8:       05d00893                li      a7,93
800003cc:       00000513                li      a0,0
800003d0:       00000073                ecall
800003d4:       c0001073                unimp
        ...

Disassembly of section .tohost:

80001000 <tohost>:
        ...

80001040 <fromhost>:
        ...

Disassembly of section .data:

80002000 <test_2_data>:
80002000:       0000                    .2byte  0x0
80002002:       4020                    .2byte  0x4020
80002004:       0000                    .2byte  0x0
80002006:       3f80                    .2byte  0x3f80
80002008:       0000                    .2byte  0x0
8000200a:       0000                    .2byte  0x0
8000200c:       0000                    .2byte  0x0
8000200e:       4060                    .2byte  0x4060
wysiwyng commented 1 year ago

objdump can also read binary files, the handling of long sequences of equal instruction words remains the same:

23a0:   557d                    li      a0,-1
23a2:   b7c1                    j       0x2362
...
23b0:   1101                    addi    sp,sp,-32
23b2:   cc22                    sw      s0,24(sp)

the disassembler backend was initially a toy project to test how decoders would be implemented using information directly from the M2-ISA-R model. if we want to use this backend seriously, it probably also needs some kind of ELF support.

for this PR, i think expanding the duplicate handling to all codewords is enough.