6502 Assembler

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
67726e
Posts: 129
Joined: Sat Apr 03, 2010 5:45 pm
Location: South Carolina
Contact:

6502 Assembler

Post by 67726e » Wed May 04, 2011 10:30 am

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.

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq » Wed May 04, 2011 10:35 am

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.

User avatar
67726e
Posts: 129
Joined: Sat Apr 03, 2010 5:45 pm
Location: South Carolina
Contact:

Post by 67726e » Wed May 04, 2011 1:36 pm

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

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Post by koitsu » Wed May 04, 2011 11:22 pm

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... :(

User avatar
67726e
Posts: 129
Joined: Sat Apr 03, 2010 5:45 pm
Location: South Carolina
Contact:

Post by 67726e » Thu May 05, 2011 3:24 am

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.

User avatar
qbradq
Posts: 951
Joined: Wed Oct 15, 2008 11:50 am

Post by qbradq » Thu May 05, 2011 3:45 am

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: Select all

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.

User avatar
cartlemmy
Posts: 193
Joined: Fri Sep 24, 2010 4:41 pm
Location: California, USA
Contact:

Post by cartlemmy » Thu May 05, 2011 8:15 am

qbradq wrote: Here's what I'm talking about:

Code: Select all

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: Select all

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

User avatar
67726e
Posts: 129
Joined: Sat Apr 03, 2010 5:45 pm
Location: South Carolina
Contact:

Post by 67726e » Thu May 05, 2011 11:38 am

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?

Post Reply