Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Provide an offset for disassembly #226

Open
markcox opened this issue Jul 7, 2022 · 6 comments
Open

Feature Request: Provide an offset for disassembly #226

markcox opened this issue Jul 7, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@markcox
Copy link

markcox commented Jul 7, 2022

When performing a disassembly if the start bytes are not code then the disassembly fails. Could you please add an option to either provide an offset to disassemble from or a way for the disassembly to ignore errors so any headers are skipped over.

@prb28
Copy link
Owner

prb28 commented Jul 7, 2022

This is for memory disassembly or file ?

@grahambates
Copy link
Contributor

If you're disassembling from a symbol address you can apply an offset by writing it as an expression e.g. init+8 to disassemble starting from 8 bytes after the init label:

image

Hopefully this handles your use case.

@prb28 the help text could do with updating to document that expressions are supported. Also the ${symbol} syntax is still supported but not necessary. You can just use symbol. I'm happy to create a PR for this.

As far as having the disassembler ignore errors, we're really limited by Capstone, which does appear to just give up when it reaches invalid instructions.

@prb28
Copy link
Owner

prb28 commented Jul 8, 2022

@grahambates yes, I've missed that syntax change you've added. If you want you can add a pr of course, but I can do it too.

Capstone is a limitation here. I don't know if there is a better pure JavaScript choice.
At the time emoon, told me that it was the best disassembler (he did part of the m68k code) and it was a tricky game to reimplement it.

@grahambates
Copy link
Contributor

Yeah I agree that writing a new disassembler in JS is not realistic and Capstone is the best option, especially now that WASM means we don't have a dependency on the native binary. I'm also not sure that Capstone's behaviour is necessarily wrong in this case.

@markcox
Copy link
Author

markcox commented Jul 10, 2022

Thanks for your comments. This is for disassembling a file.
I found a way to do the disassembly using capstone via radare2.
These are the commands I used to disassemble a boot block ...
I can set the start of the disassembly to 0xc using the 's' command and disassemble using the 'pd' commands.

$ radare2  -am68k decrypted_loader.bin
[0x00000000]> s 0xc
[0x0000000c]> pd
        ┌─< 0x0000000c      601a           bra.b 0x28
        │   0x0000000e      1902           move.b d2, -(a4)
        │   0x00000010      0100           btst.l d0, d0
        │   0x00000012      00e0           invalid
...
[0x0000000c]> s 0x28
[0x00000028]> pdR 5
            0x00000028      49f900dff000   lea.l 0xdff000.l, a4
            0x0000002e      397c7fff009a   move.w 0x7fff, 0x9a(a4)
            0x00000034      397c7fff0096   move.w 0x7fff, 0x96(a4)
            0x0000003a      41ec0180       lea.l 0x180(a4), a0
            0x0000003e      700f           moveq 0xf, d0


image

When I try to do the dissassembly in vscode...
I press F1 and choose
"amiga assembly: disassemble file"
I get this message:
image

@prb28
Copy link
Owner

prb28 commented Jul 10, 2022

Never tried to disassemble a boot block. And didn't know radare2 tool. I'll try it to see if it can be improved.

@prb28 prb28 added the enhancement New feature or request label Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants