Ardens: Arduboy Simulator for Profiling and Debugging

Ardens is a simulator for the Arduboy FX that is designed especially for profiling and debugging Arduboy games.

Try out the full debugger here. Drag and drop an Arduboy game (.hex/.elf/.arduboy) and any FX data (.bin) onto the page. Note that using an ELF file allows greater access to debug info.

Ardens releases include a minimal player with debugging features excluded: you can try it online with one of the game URLs below:

Documentation for how to create a link to a playable game.

Desktop releases can be found in the GitHub Releases page.

Original post from Feb 4, 2023

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.

Link to web version – drag and drop files (hex/bin/arduboy/elf) to load.

17 Likes

Huge props to you for making it look so good!

UI is always challenging and it always ends up looking bad (or at least for me)

1 Like

Thank you. The UI is thanks to the excellent Dear ImGui library.

2 Likes

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’.

If you want some resources to get started:

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.

Switched to a vector font, and the tool is now DPI-aware.

image

image

5 Likes

I’ve tested it with my game, and it works great! Fantastic job!

I’ve also just realized my ā€œclear highscoreā€ option miiight not work :flushed:

3 Likes

Cool! It’s also possible/likely there is some error in the EEPROM or flash chip code – this project is pretty young.

2 Likes

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.

3 Likes

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’

1 Like

just played with the profiler part and it’s great also like the cycle counting on the disassembly :+1: 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 :slight_smile:

2 Likes

Thanks a lot for the great feedback!

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)
image

Jump to function dropdown:
image

EDIT: Also ā€˜S’ is now an alternate input for the B button.

4 Likes

This. Is. AWESOME! I’m already using it to test (and fix) issues with my current project.

Thank you so much for making this!

Keep up the good work!

~Dolorre

1 Like

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? :+1:

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?

Whoops – I had forgotten to copy the .data section when loading from elf. :stuck_out_tongue: It should be fixed now, might have to clear your browser cache to see it.

1 Like

Thanks for the quick fix :+1:

Updates:

  • Improved stepping: into/over/out. ā€œStep Outā€ is only available where stack frame info is loaded (elf with debug sections).
  • Globals window

5 Likes