<div dir="ltr">Hi Brian,<div><br></div><div>Yes, probably my mail was a bit too generic, but my warning was exactly the following you synthesized:</div><div><br></div><div>"<span style="font-size:12.8px">Don’t trust a disassembler unless you verify its translation against the official data book for the CPU."</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I'm quite sure Roland wrote that code directly in Assembly...</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Still, my suggestion on a general level is to try different disassemblers, and see if setting same exact processor part number gives you different output.. (if really your disassembler also works with that specific CPU.. does it ? really ? )</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I do know and understand optimization of code is done on higher level codes, not machine level where it is already translated to its lowest form, but still, Disassemblers might work differently, and as you do, writing your own one is really the only option to be 100% sure of what it does IMHO...</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Nevertheless, i would suggest everybody interested on this thread to read what Robin Whittle has said regarding Roland original CPU replacements attempts and reverse engineering in the past:</span></div><div><span style="font-size:12.8px"><a href="http://goog_732003771" target="_blank"><br></a></span></div><div><span style="font-size:12.8px"><a href="http://analogue-heaven.1065350.n5.nabble.com/Re-Obsolete-MASK-ROM-CPUs-re-issued-td80564i20.html" target="_blank">http://analogue-heaven.<wbr>1065350.n5.nabble.com/Re-<wbr>Obsolete-MASK-ROM-CPUs-re-<wbr>issued-td80564i20.html</a></span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">So first of all.. do "we" have the original Data Book ?</span></div><div><span style="font-size:12.8px"><br></span></div><div><div><span style="font-size:12.8px">Robin talked about a: </span></div><div><span style="font-size:12.8px"><b><br></b></span></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><span style="font-size:12.8px"><b>NEC Microcomputer Products 1984 Data Book</b></span></div></div></blockquote><div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">In the PDF from Julian i see this reference:</span></div><div><span style="font-size:12.8px"><br></span></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><span style="font-size:12.8px"><b>(Japan, july 12, 1983 E2).</b></span></div></div><div><div><span style="font-size:12.8px"><b>[5] NEC Microcomputers, Inc., “µCOM-43 Users’</b></span></div></div><div><div><span style="font-size:12.8px"><b>Manual,” (NEC Microcomputers, Inc. 1978)</b></span></div></div></blockquote><div><span style="font-size:12.8px"><br></span></div><div>Are we sure its the same, and we have all necessary documentation to make this checks and confirm the output of the disassembler ?</div><div><br></div><div>This referenced one and linked by Robin looks to be still up :</div><div><br></div><div><a href="http://pdf.datasheetcatalog.com/datasheets/400/500004_DS.pdf" target="_blank">http://pdf.datasheetcatalog.<wbr>com/datasheets/400/500004_DS.<wbr>pdf</a><br></div><div><br></div><div>I'm citing a fraction of Robin's mail cause its related to previous exchanges related to mask ROM decoding:</div><div><br></div><div>"The only way I know of getting a dump of the program memory is to </div><div>decapsulate the chip and analyse it with an electron microscope.  As </div><div>far as I know, whatever eats the epoxy (not much - maybe nitric and </div><div>sulphuric acid) will make a mess of the delicate aluminium tracks. </div><div>Theoretically a scanning electron microscope image might be analysed </div><div>to reveal a pattern of 0s and 1s in the ROM section.  With some </div><div>educated guesswork, this could be turned into the program memory contents. "</div><div><br></div><div>Haven't follow this thread carefully maybe, and i apologize if i missed anything,</div><div>but in the end looks like having an electron microscope was not needed to obtain a dump of the program memory and now you guys have a full dump and successfully disassembled it, right ?</div><div><br></div><div>Well if yes, then of course still you need the official DataBook from NEC,</div><div>and carefully check what came out from your disassemblers to see if everything was translated correctly.</div><div><br></div><div>Only after having completed this phase successfully you can go to the code interpretation and analysis.</div><div><br></div><div><b>@Roman Sowa</b>: </div><div><br></div><div>Most experienced people i talked to about disassemblers in the end said "... but i prefer/preferred writing my own one."</div><div><br></div><div>Now i'm curios to know:</div><div><br></div><div>Which disassemblers has been used for this 303 reverse engineering testing ?</div><div><br></div><div>Was it possibile on them to select exactly that NEC family part number ?</div><div><br></div><div>How many disassemblers do you know that perfectly support that old 1982 CPU ?</div><div><br></div><div>Have you compared the output of more than 1 disassembler that was configured to translate for that exact CPU ?</div><div><br></div><div>What you and Brian said about how disassembler are supposed to work is totally true.</div><div><br></div><div>Still i don't see enough technical evidence being shared here to tell if this is also true in the facts, or not.</div><div><br></div><div>K</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-03-20 12:11 GMT+01:00  <span dir="ltr"><<a href="mailto:rsdio@audiobanshee.com" target="_blank">rsdio@audiobanshee.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">There’s no need to chase three or four different disassemblers. All you need is the data book for the exact processor part number, and it will list a definitive set of opcodes. You’re correct that a generic disassembler might get some opcodes wrong, but then your listing will quickly turn into garbage, and that should be blatantly obvious. For these 8-bit processors, it’s usually a very quick task to check a few tens of opcodes (there are usually less than that, and not more than 256, of course). There is a one-to-one mapping between machine code and assembly code.<br>
<br>
There is no such thing as disassembler optimization. You have it backwards. When code is written in a high-level language like C, the compiler can create different opcodes for the same source depending upon the optimization level and the compiler vendor. However, when you’re looking at assembly or machine code, there is no optimization layer. What you see is what the processor will execute. In fact, the timing is precisely known when looking at machine code or disassembly of machine code into assembler syntax.<br>
<br>
So, the trouble here is not the disassembler, but recreating the original source code that the developers used. For something of the TB-303 era, the developers probably wrote the entire firmware in assembler. Writing firmware in C was not very common, especially when the ROM was only 2 KB. That’s fewer than 2048 instructions, because many instructions have operands that take an extra byte or two, and then there are the tables of data that should not be disassembled.<br>
<br>
Uncommented assembly is very difficult to read because there are no variable names or comments. It has nothing to do with optimization and everything to do with human-readable code. The processor doesn’t need the comments, so the ROM doesn’t include them.<br>
<br>
I write my own disassemblers for projects like this one. I do that because I can embed symbols that represent the custom hardware of the particular vintage synth in question. That means my disassembler listing is more human readable (at least for one particular human) than the default disassembler.<br>
<br>
Basically, you’re right: Don’t trust a disassembler unless you verify its translation against the official data book for the CPU. But optimization is not part of the process of disassembly. That’s in the realm of compilers. You’ll be able to determine the precise timing from the ROM data and the data book.<br>
<br>
Brian Willoughby<br>
Sound Consulting<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Mar 20, 2017, at 3:50 AM, KRiSh <<a href="mailto:krish0005@gmail.com">krish0005@gmail.com</a>> wrote:<br>
> as far as i remember, disassemblers are not guaranteed to output exactly the original code.<br>
><br>
> it depends how the disassembler work and only defining the processor family or model could not be enough..<br>
><br>
> you might obtain a very similar version of the original code, but not as optimized as the original nor 100% identical.<br>
><br>
> any "optimization" is of course useful in the context of each corresponding project,<br>
> and we are talking about a 1981 project so, probably there where some..<br>
><br>
> i understood the thread is to try re-creating the original source code and understand deeply how the 303 seq works,<br>
> especially including any quirk that might contribute to its disputed "magic" or "unique" feel.<br>
><br>
> If that's the objective, then i assume more work is needed on the pre-requisites in this case.<br>
><br>
> I would compare at least 3/4 different disassemblers output and see if the code resulting code is the same.<br>
><br>
> Is it the same ?<br>
><br>
> If not what is different ?<br>
><br>
> which disassemblers have been used so far ?<br>
><br>
> Trusting your disassembler 100% and use the resulting code being confident it is already 100% equal to original is a wrong assumption IMHO that could lead you to waste your time (in this particular case).<br>
><br>
> If recreating also the quirks is important here, then you really need the correct original code to understand and identify all the interactions of the routines/interrupts and their timings, especially because efficiency of code and, as said any "optimization", would be very important or crucial to the resulting timing.<br>
><br>
> IMHO, just my 2 cents, etc<br>
><br>
> K<br>
<br>
</div></div></blockquote></div><br></div>