EmbeddedRelated.com
Forums

MDX AVR Assembly Simulator and Disassembler

Started by Milo_D 4 years ago3 replieslatest reply 3 years ago949 views
Hey Guys,

I just wanted to share with you a project in order to get some constructive feedback.

MDX is an Assembly Simulator for 8-bit AVRs. It has an integrated Disassembler, which reconstructs labels and comments in order to increase readability.

mdx_debug_3634.png

What's different ?

- Backstepping is supported
- Headless Mode
- Redefine constants or even mnemonics on Source level
- Open up to 4 files and switch fast between them

Currently there are 3 different modes:

(i) Interactive Simulation
MDX accepts Hex Files as input, then decodes them into readable Assembly Source Code. Now you may step through your Code.

(ii) Headless Mode
MDX accepts a single hex file as input. This file will be silently simulated and the end state of the MCU will be printed out directly in form of a JSON File. This may be interesting for fuzzing and testing.

(iii) Disassembler
MDX will disassemble Hex Files, while reconstructing Labels, new lines and comments. The output will be printed out directly.

In the future:
- I will be working on an interactive Graph to show off relations between code segments.
- Watchpoints, Step in/out, etc.
- Adding more MCUs with different architecture
- many more...

Reason of this post:
MDX is still in development, although it is possible to simulate more complex algorithms like a recursive DFS in a Graph, some instructions are still missing (over 60 instructions are supported).

And now I am asking for some feedback. What's wrong/good, what should be added/removed, etc.

I would be happy to hear your opinion

Written in: C++
OS: Linux/Unix
Github: https://github.com/Milo-D/MDX-Assembly-Debugger/

[ - ]
Reply by BVRameshJanuary 5, 2021

Once (during 1980/90's) I developed a simulator / assembler /disassembler for z80 micro, on DOS 4.2 on MASM. I am thrilled to see such an attempt now (almost 30 years).

Those days screen was 80 x 25 and I was forced to limit all the display within that screen, so my two cents of suggestion:

since you use hex in all your data do not prefix 0x you will save a lot of space and it will give better visibility.

Whenever you simulate and instruction, the source and destination data highlight in different colour including the flags, it is very helpful for debugging.

Whenever you access data memory / update data memory, scroll to that location such that it lies in the centre of scroll, so that previous / next locations seen

In disassembler you print the address at left along with data so that it should be easy to locate the code in the address space, for example:

0000 9F E5        ldi r25, 5F        ; R25 <- 5F
0002 9D BF        out 3D, R25        ; DATA[addr] <- R25

Also in disassembler there is no necessity to generate labels, instead you can put the computed address itself!. (Or you can make it as optional).

0009 27 00        rjmp 000A          ; PC <- PC + 1
optional:

0009 27 00        rjmp L0            ; PC <- PC + 1
L0:
000A C0 A4        ldi r26, C4        ; R26 <- C4

               OR

0009 27 00        rjmp L0            ; PC <- PC + 1
000A C0 A4   L0:  ldi r26, C4        ; R26 <- C4

I hope that this will give you some user type requirement.

Best Wishes for a useful tool.


[ - ]
Reply by Milo_DJanuary 5, 2021

Thank you for your reply. By far the best and most constructive advice :D

"Whenever you simulate and instruction, the source and destination data highlight in different colour including the flags, it is very helpful for debugging.

Whenever you access data memory / update data memory, scroll to that location such that it lies in the centre of scroll, so that previous / next locations seen"

I am already doing this;)

Read Access is red colored and write is green. When reading writing data to Eeprom/Data program will jump to this location so that the accessed Cell is centered.

Thank you for your feedback, I will definetely consider it :D


[ - ]
Reply by Milo_DJanuary 5, 2021
103389512-93ba8800-4b0f-11eb-911b-fa8c8d


Long time ago I've started this post and between now and then much has changed.

Most important changes:

  • All 131 instructions are now supported
  • Currently 17 MHz execution speed
  • Timer0 support (Normal, CTC) + IRQs
  • EEPROM support + IRQs
  • cycle accurate simulation of peripherals
  • added analyzer for static code analysis
  • SFRs are annotated in dataspace block
  • Syntax Highlight

Also this project was rewritten in C due to simplicity and beauty of the C language ;)