News: 11 March 2016 - Forum Rules

Author Topic: 65816 opcode/syntax highlighting for Sublime Text?  (Read 5748 times)

benjaminshinobi

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
    • benjaminsantiago.com
65816 opcode/syntax highlighting for Sublime Text?
« on: December 22, 2013, 06:22:48 pm »
Just curious if anyone knows about any 65816/Super Nintendo specific syntax highlighting for programs like Sublime Text or Notepad++?

I've seen some more sophisticated stuff like what dforce is doing, but I am trying to stick closer to the metal for now while I am learning stuff.

Revenant

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: 65816 opcode/syntax highlighting for Sublime Text?
« Reply #1 on: December 22, 2013, 06:53:56 pm »
Programmer's Notepad 2 (my personal favorite coding text editor forever :) ) comes with a syntax highlighting scheme for x86 assembly - it wouldn't be too hard to use it as a base for other architectures / assemblers. I've actually thought about ones for 6502/65816 assembly for my own use, but laziness always wins.

Zoinkity

  • Hero Member
  • *****
  • Posts: 565
    • View Profile
Re: 65816 opcode/syntax highlighting for Sublime Text?
« Reply #2 on: December 22, 2013, 07:08:21 pm »
It's fairly simple to add syntax highlighting in Notepad++.  Made a setting for R4300 in about five minutes.
Basically all it is would be a list of ops you want for each color and a couple flags for rules governing colorizing everything else.  The readme outlines it pretty well.

snarfblam

  • Submission Reviewer
  • Hero Member
  • *****
  • Posts: 595
  • CANT HACK METROID
    • View Profile
    • snarfblam
Re: 65816 opcode/syntax highlighting for Sublime Text?
« Reply #3 on: December 22, 2013, 07:16:05 pm »
I just use Notepad++, and add the 6502-specific (or in your case, 65816-specific) instructions and directives to the "user-defined" lists of the existing "assembly" highlighting.


Spoiler:



FAST6191

  • Hero Member
  • *****
  • Posts: 3358
    • View Profile
Re: 65816 opcode/syntax highlighting for Sublime Text?
« Reply #4 on: December 22, 2013, 07:18:58 pm »
Heh I press reply and in the "Warning - while you were typing...." thing I see many of us said roughly the same thing, I will add to the forum clutter I guess.

It does not matter so much here but in general saying things like "65816/Super Nintendo specific syntax highlighting" is a meaningless term as far as assemblers go. As the SNES is not exactly the most register heavy device (two and an accumulator) it is OK here and things are encoded at instruction level. Still
Some assemblers might interpret "mov r1, r2" as "mov the contents of r1 into r2".
Others though will interpret it as "mov the contents of r2 into r1".

More generally
instruction source, destination
instruction destination, source

Both are quite valid to write an assembler with. It can be the source of many bitter arguments, others are made for people that like one way and are coming in from using a chip that does the other way (and then bitter arguments). I would probably still flip a coin and go with that but my gut says "instruction destination, source" is the more common method in general. Again though this is the SNES so you can put that to back of your mind.

Even so you will still find that not all SNES assemblers are made equal (very far from it) but as long as you are not getting too deep into the macros, variables, in assembler maths and maybe some of the pseudoinstructions you should be OK. I am prepared to find out all known viable 65816/Super Nintendo friendly assemblers use one particular method but if you go on to learn assembly language for other chips then remember it is assembler specific (and maybe even version specific) and not device specific.

That said I guess you are probably going to go in for bass or maybe xkas (bass is the better tool but xkas has history and fans among many extensively hacked SNES games) so you have something to work towards. Should you be working with another existing assembly hack of some form then it is up to you to figure it out (and reading around there are all sorts of people using all sorts of things).

On the syntax highlighting thing though why not write your own? If this is a learning exercise it might not be quite as nice as writing an emulator for the chip but it will probably be considerably better than staring at an instruction set for the chip and hoping something sticks. You will still have to disassemble and figure out a whole bunch of existing code and spend your time staring at some combo of ( http://www.smwiki.net/wiki/65c816_instructions , http://wiki.superfamicom.org/snes/show/Jay%27s+ASM+Tutorial , http://wiki.superfamicom.org/snes/show/65816+Reference and http://nocash.emubase.de/fullsnes.htm#cpu65xxmicroprocessor or something along those lines) but it would undoubtedly help in such a process.

DanielOaks

  • Guest
Re: 65816 opcode/syntax highlighting for Sublime Text?
« Reply #5 on: January 14, 2014, 05:30:02 am »
Hi Ben, I actually started up a similar thing a while ago, which if nothing else should at least be an alright starting point for you: https://github.com/DanielOaks/65816-Assembly-TMlanguage

However, FAST6191's advice is sound. Is always fun and useful to try and write your own!

benjaminshinobi

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
    • benjaminsantiago.com
Re: 65816 opcode/syntax highlighting for Sublime Text?
« Reply #6 on: January 16, 2014, 04:38:36 pm »
Hey Daniel + FAST16191!
 
Weird I actually just looked at how to do custom syntax highlighting in Sublime Text last night. I'm going to peruse this, I totally forgot whatever Regular Expressions I knew, so going to be a little bit of a process. I'm not sure what's in your JSON, but I'd like to also add stuff to make the highlighting work with the preprocessor directives of WLA.

Daniel have you looked at the stuff that lint has done in C with WLA/Ecliplse/Super Nintendo or are you just doing pure assembly? (I'm just doing ASM right now, part of my interest in this was to get better at ASM without having to build hardware)

I'm not fully understanding how sound works on the SNES (taking it one step at a time), but it looks like there'd also have to be some kind of highlighting for the SPC700 code as well.

My goal is to also have a build engine so you could use CTRL+B or something and it would compile the current project, and then open it ZSNES/SNES9x.



January 21, 2014, 12:15:15 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Hey DanielOaks, finally tried out your syntax highlighting and it looks pretty cool so far!
« Last Edit: January 21, 2014, 12:15:15 am by benjaminshinobi »