For the past couple of weeks I’ve taken a break from my RPG to develop this tool. It’s not finished but I think it’s good enough to share. Its main purpose is for asm debugging and finding performance bottlenecks, but it also makes grayscale development a bit easier.
I sort of wish I understood assembler now., this looks really good and I was wondering how I would test games that use greyscale with my current methods (web-version of project ABE).
The web site is tiny and looks ‘hard-coded’ to a particular resolution. Is there a simple way to fix that?
Darn, sounds like a high DPI issue. I tried for a while but wasn’t able to figure out how to properly make SDL and emscripten work nicely with high DPI. So I’ve just disabled it for the web build. The sizing should be correct now but things will be a bit blurry – I’ll try to revisit it later.
Assembly really isn’t all that difficult, it’s just horribly tedious to read and write compared to structured programming because each instruction is so ‘atomic’.
I recommend reading the Wikipedia article to get an idea of what the registers and status flags are used for and then keeping the instruction reference open to refer to.
Eventually you’ll start memorising the instructions that occur quite often. E.g. LPM is likely to come up a lot - that’s the one that reads a single byte of data from progmem.
Overall AVR’s not too bad - it only has about 128 instructions and very few quirks.
It’s a far cry from x86, which has had thirty-odd years to accumulate new instructions and features, and evolved over time from 16-bit to 64-bit.
Oh, I did a lot of assembly on the 6502 in the mid-80s. I have an electronic book on AVR assembly which I was slowly working through … unfortunately, have forgotten everything I knew and I just do not have the time to invest in it.
LDA, lDX, LDY, BMI, BNE, BPL … I still remember a lot of the 6502 instruction set. But then again, it only had about 50 instructions. It was the first, unintentional RISC chip. The Z80 had 600 or so codes - total 8bit CISC.
I’ve never so much as touched a real 6502, but I started writing a NES emulator once, so I have some experience with it.
(Technically the NES used a Ricoh 2A03/Ricoh 2A07, not a MOS 6502, but the only difference was the lack of a BCD mode.)
But a dozen different addressing modes!
(Half the reason I gave up on the emulator. The other half being the NES’s PPU.)
I’ve always found the choice of ‘branch on minus’ and ‘branch on plus’ to be odd naming choices (compared to e.g. ‘branch on negative set’ and ‘branch on negative clear’, or ‘branch on negative’ and ‘branch on positive’), but AVR followed suit with BRPL and BRMI.
Again, I have a bit of experience due to forays in emulator writing, and some general CPU research.
The Game Boy’s CPU, the Sharp LR35902, was a sort of hybrid of Z80 and 8080.
This is amazing! From a quick test, I’m reminded that HEX files have no symbols, so you need to drag in an ELF file to get useful labels in the disassembler and stack trace.
The tool is looking great I like the different colored symbols from elf and that you can click on calls/addresses. It would be great to have a symbol list and / or being able to search for a symbol in the disassembly.
I noticed that inthe simulator the buttons are ‘A’ and ‘B’ keys. Could ‘S’ be added as a redundant button for ‘B’
just played with the profiler part and it’s great also like the cycle counting on the disassembly Noticed the ijmp instruction counts 3 cycles instead of 2 cycles.
looks like I may soon no longer need to look at manually disassembled elf files for debugging
The desktop version can also intermix source code and assembly, objdump style. But since ELF only contains source file names, not the source data itself, the web version can’t do that. In the future I hope to load local var info for each stack frame as well as type info so global/local vars can be pretty printed…
Wow, nice catch!
New symbols window (click to jump to that symbol in disassembly)
Jump to function dropdown:
EDIT: Also ‘S’ is now an alternate input for the B button.
Thanks for adding the symbols and S key as alternate B button.
Also nice to see the symbols are sorted alfabetical and all labels can be listed. I often use a line asm volatile(“dbg:\n”); in my code to optimize / debug code so it will be easy to find in the sorted list.
Cool! there’s a desktop version too? and with even more features?
Something odd I noticed while I ran the helloworld FX example. When simulating it I noticed the text didn’t scroll. Looking into it, it looks like __do_copy_data doesn’t copy the data section to ram correctly. like the lpm r0,Z+ instruction only reads zeros?