This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

6502 Assembler

6502 Assembler
by on (#77611)
I just wrote this for my final project for my IB Comp. Sci. class a few months back. I guess I just got around to releasing it. Its not much compared to most other assemblers out but it does support a few things I always wanted in NESASM.

Its called hasm. Its probably really buggy right now but it *can* compile. I haven't had the time to write any test games or anything so it may well have some nice bugs.

by on (#77613)
That's awesome! It's always fun to write a 6502 assembler. I wrote one in JavaScript about a year ago :D

Can you describe the special features you implemented? I read the text files in the repo but they do not seem to describe special functionality.

I noticed the C-style comment blocks in the test assembly file. That's one feature I wish all assemblers included.

by on (#77624)
Block commenting was one of them. I also hated how with NESASM you had to have a symbol to force zero-page addressing so I did away with that.

I was/am also working on an optimization tool that recommends possible areas to work on (assuming you enable the feature).

by on (#77657)
Can't tell from the .txt files in the main repo dir, but it doesn't look like decimal (e.g. LDA #123) or binary (e.g. LDA #%11011110) immediates are supported. Yes/no?

EDIT: Nevermind, Java... :(

by on (#77664)
koitsu wrote:
Can't tell from the .txt files in the main repo dir, but it doesn't look like decimal (e.g. LDA #123) or binary (e.g. LDA #%11011110) immediates are supported. Yes/no?(


Holy hell I don't know how I managed to miss that. I guess just give me a day or so to take care of that.

by on (#77667)
This is really making me want to code a new assembler myself But since I'm already two projects deep I'll ask you to implement the things I want :D

Ever consider namespaces? I have always wanted an assembler that has true support for nested namespaces that work like C++ namespace or JavaScript container objects. Seems like it would work a lot better than CA65's named scope mess.

How about implementing curly brackets as anonymous labels? Here's what I'm talking about:

Code:
lda my_label
beq }
{
   // DO STUFF
   jmp }}
}
{
   // DO OTHER STUFF
  {  // Some other block that does not interferer with the jmp }} above
  }
}


I don't know, I haven't thought out the syntax on that very well yet. I just hate having to invent names for my if / else / for / while jump locations, and real anonymous labels have too many problems.

by on (#77674)
qbradq wrote:
Here's what I'm talking about:
Code:
lda my_label
beq }
{
   // DO STUFF
   jmp }}
}
{
   // DO OTHER STUFF
  {  // Some other block that does not interferer with the jmp }} above
  }
}


Cool, that's kinda like what my pre-parser does:
Code:
//16 bit comparisons
CMP16 i, cameraX, BPL { ; Move camera to the left ...
   CMP16 i, #$00, BMI { ; ... unless we are at the beginning of the map
      LDA i
      STA cameraX
      LDA j
      STA cameraX+1
   }
}

//switches:
LDA objectType,x
TAX
switch (x) {
   case 0:
   JMP doneWithThisObject
   
   case 1: ;Useless Splink
   .include "objects/uselessSplink.asm"
   JMP   doneWithThisObject   
}

//And other stuff too, but I'm lazy.

by on (#77690)
So perhaps a feature list of things to implement?

So far I think:

1) Anonymous labels
2) Switch/Case
3) Decimal/Binary modes

Anyone want to add anything they think is a good idea?