gpdaniels / spike-prime

Experiments with the LEGO Mindstorms (51515) and SPIKE Prime (45678)
MIT License
282 stars 39 forks source link

Add the disassembler #10

Closed pitust closed 3 years ago

pitust commented 3 years ago

This adds the disassembler.

Signed-off-by: pitust piotr@stelmaszek.com

pitust commented 3 years ago

A sample of what it produces:

<module>:
    129
    str LightMatrix
    tuple 1
    import.nm lightmatrix
    import.from LightMatrix
    st.name LightMatrix
    pop
    129
    str Button
    tuple 1
    import.nm button
    import.from Button
    st.name Button
    pop
    129
    str StatusLight
    tuple 1
    import.nm statuslight
    import.from StatusLight
    st.name StatusLight
    pop
    129
pitust commented 3 years ago

It does seem to be a bit buggy though.

pitust commented 3 years ago

Is there any reason to not merge it now?

gpdaniels commented 3 years ago

I'm hesitant to add the entire micropython repo as a submodule. If it only depends on the mpy-tool.py it'd probably be better to just copy that file over.

Also as the firmware/filesysystem will keep getting updated, I'd prefer a short bash or batch script to create the decompiled output rather than including it all in the repo.

pitust commented 3 years ago

Unfortunatly, micropython's tools are really tightly interconnected. I will write a batch script to do (2) though.

gpdaniels commented 3 years ago

Playing with this, you can extract the mpy-tool.py you just need the makeqstrdata.py file too.

pitust commented 3 years ago

Great! i will refactor it and push it all soon.

pitust commented 3 years ago

^ Yeah, i am done refactoring this

gpdaniels commented 3 years ago

Can you also remove the generated files, as they'll change with each release, and with improvements to the decompiler.

pitust commented 3 years ago

Sure! They are actually already out of date, since the decompiler got a lot of changes over the last two hours.

gpdaniels commented 3 years ago

Looking good! I've been attempting to port it across to python too for my convenience, so will make sure to add any changes. I think the micropython submodule is still here?

pitust commented 3 years ago

I don't think so. I removed it in eeb94d1

pitust commented 3 years ago

Actually, i removed it in 778292, because i didn't remove the submodule properly

pitust commented 3 years ago

Wait, i am going to push my latest disassembler

pitust commented 3 years ago

here, my latest disassembler is up