[NTLK] ROM Disassembly online?

Matthias Melcher mm at matthiasm.com
Thu Apr 2 08:04:42 EDT 2015


OK, first of all, Albert is now part of the github project DyneE5. It should contain all files needed. You need to add the ROM as a 8MB binary image as Albert/data/717006. 

Next, compile and run 'db2src', and after a ton of log messages, the assembler file should magically appear in Albert/NewtonOS/newtonos.s . The file is huge, and most text editors choke on it or at least become extremely slow. I use good old 'vim', which couldn't care less about the file size, but is extremely cryptic to use.

It should be possible to run this file through an ARM assembler and generate the same binary ROM file. In ARM code, there are commands that do exactly the same, but have different binary representations. 'armdiff' runs a binary diff that accepts those opcodes as equal.

For example, R0=4 can be encoded as 'mov r0, 0x04' or as 'mov r0, 0x01<<2'. Different assemblers use different encodings, but the result is exactly the same.


> On Apr 2, 2015, at 5:56 AM, Steven Frank <stevenf at panic.com> wrote:
> 
> Unless you need specific functionality beyond just inserting, removing, or moving lines of text, this sounds kind of like a traditional diff & patch situation, assuming everyone was starting from the same base file.

It's not that easy because we want t check only the comments in. By removing the source code, diff has no clue where the comments need to be in the end, and will shift them around. 

> You'd start with your raw disassembly as the base, add comments, and then generate a diff to get just the comments.  Put that diff on GitHub.
> Next person generates their own disassembly, applies current diff, adds their comments, generates a new diff, then... appends that to the one on GitHub?  Would that work?

If lines have comments appended, source code will become part of the diff. Also, comments are put in the diff using line numbers, not memory addresses. Once this runs out of sync, all the work would be for nothing.

Finally, it would be nice to be able to still improve the disassembler, and to merge that code in correctly.

But I agree that it has to be a simple solution.


How about this: 

Every line that refers to a fixed address in ROM has the TAG sequence "_@[xxxxxxxx]" ('_' is a space or a tab, 'x' is an upper case hex digit) somewhere. Now we only allow two kinds of comments: 

1: inline. The line has a TAG and end in a comment. Those comments are either "_@@ Text", or "_@@@ Text" . Neither Sequence appears in the ROM

2: above. The line has no TAG, but the first non-comment line has a TAG. Same @@ sequences


Maybe this is more obvious if I put that into an example. If I use indicators for 'inline' (-) and 'above' ('), removing the source should get me something like below. Can anyone put that into a script? It would also just be a few lines in C. We can even merge arbitrary packed files by simply concatenating and sorting by the first column 0-9. If two inline comments exist for the same address, they should probably be concatenated, or one should be promoted to an 'above' comment.

-------- Without source code:

00000000 ' @@ This is the ROM disassembly, generated by a bunch of fans
00000000 ' @@ Make sure that comments you commit are correct
00000000 ' @@
00000000 ' @@ The ARM CPU jumps here when reset is pressed or when switched on
00000000 - @@ jump to ROMBoot
00000004 ' @@ CPU jumps here if an undefined instruction was found
00000004 - @@ What a funny name for a label

-------- With source code:

Reset:
        @ label = 'Reset'
	@@ This is the ROM disassembly, generated by a bunch of fans
	@@ Make sure that comments you commit are correct
	@@
	@@ The ARM CPU jumps here when reset is pressed or when switched on
        b       ROMBoot                         @[00000000] 0xEA0061A0 - ..a. @@ jump to ROMBoot

_UndefinedInstruction:
        @ label = '_UndefinedInstruction'
	@@ CPU jumps here if an undefined instruction was found
        b       VEC_FP_UndefHandlers_Start_JT   @ 0x00000004 0xEA680C7A - .h.z @@ What a funny name for a label

-------- 


 Matthias


More information about the NewtonTalk mailing list