Close

A disassembler is in the works

A project log for zeptoforth

A full-featured Forth-based RTOS for ARM Cortex-M

travis-bemannTravis Bemann 04/29/2020 at 15:244 Comments

A Thumb-2 disassembler is in the works for zeptoforth. It will be quite some time until it is ready - the Thumb-2 instruction set is rather complex - but work has started on it. Note that there will be a slowdown in work on other new features, since my spare time will be taken up by work on the disassembler.

Discussions

Thomas wrote 04/30/2020 at 10:27 point

How is it related to the development approach that you're are using for zeptoforth?


I must admit that a Forth-native assembler (and disassembler) would be an asset. Due to the modified STC in STM8 eForth I rarely felt the need for a disassembler (I used uCsim when I needed it - but it turned out to be a bug in uCsim that created that need).

  Are you sure? yes | no

Travis Bemann wrote 04/30/2020 at 15:51 point

I'm now questioning whether a Forth-native Thumb-2 disassembler is a good idea, simply in numerical terms; I am only on 'BL' and 'BLX' right now, and yet there are ~650 lines of code despite my trying to reuse code whenver possible. If each of these lines was a 16-bit Thumb instruction,  that would mean that that would add up to 1.3K  of memory, but that is not true, there are almost certainly more bytes per line than that, even taking comments and blank lines into account.

  Are you sure? yes | no

Thomas wrote 04/30/2020 at 17:13 point

Sometimes the logic of instruction encoding his difficult to "factor". The last partial disassembler I wrote was for a C167 (alias ST10), and the only one that was kind of complete was for the 6502 (maybe 35 years ago ;-) ).

  Are you sure? yes | no

Travis Bemann wrote 04/30/2020 at 17:43 point

I have been thinking of ways to factor it more. It turns out that the Thumb-2 instruction set reuses the same fields for different things a lot. Therefore, if a field is used in many places, I can factor out the whole field access (and for the sake of efficiency do some rather un-Forthy things such as returning inputs), reducing the number of bytes needed in the code.

  Are you sure? yes | no