I’ve been writing some 6502 assembly code in the past year, and have found the developer experience for this language to be lacking some modern conveniences.
In my last blog post, I described the development tools that I used to implement a simple NES game on Linux. I used text editor to write the code, and it couldn’t do much more than syntax highlighting.
I write most of my other code in IntelliJ, so I decided to take a look at what would be required to write a plugin for 6502 assembly support. I managed to together something that mostly works, which I published to the JetBrains Marketplace last weekend.
You can find it by searching “6502 Assembly” in most JetBrains IDE’s.
Firstly, it supports syntax highlighting. I limited the scope of the plugin to ca65 assembler syntax only, since it’s the assembler that I know best.
You can navigate to any label with Ctrl+Click. This will not yet work for other types of symbols, such as constants, macros, and imports.
If the plugin sees a jump or branch statement, and can figure out where the jump goes, then it will show a gutter icon which navigates to the target.
You can find the usages of a label.
In ca65, you can use nested scopes. The plugin shows code folding buttons to collapse these scopes.
You can navigate to a symbol by name using the “Go To Symbol” action.
The plugin allows for commenting and un-commenting blocks of code, though there is no formatter, so indentation sometimes still has to be fixed manually.
It also allows you to rename a label and its usages, which is a great time-saver.
One limitation is that the plugin does not fully parse expressions, so it will not detect errors from mis-matched brackets.
Secondly, the plugin does not understand the project structure. This means that if you re-use the same label name in different places in your project, the “Rename” and “Find Usages” function will match all of them at once, because it is not smart enough to follow imports and apply scope rules.
A lot of things can be done with an IDE plugin, but I’m planning to use this initial implementation for a while before attempting to add any big-ticket features.
A reasonable goal might be to have “Hello World” project skeletons for common 6502 systems, and to support launching with some common emulators. I would like to be able to set breakpoints and debug 6502 programs in an IDE, but external debugging interfaces are not commonly available for retro emulators, so this is probably not a reasonable goal.
The code is on GitHub under an MIT license. If you are using this plugin and would like to help improve it, then pull requests are welcome.