It is currently Sun Nov 23, 2014 12:09 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: SNAP - a 65816 assembler
PostPosted: Mon Dec 05, 2011 2:56 pm 
Offline

Joined: Sun Mar 27, 2011 10:49 am
Posts: 31
Hey all,

I had some free time and decided to write myself a 65816 assembler. If, for whatever reason, you're not satisfied with the excellent 65816 assemblers out there already, check it out on github.

Any feature requests, bug reports, complaints or praises welcome.

Cheers!

The readme looks something like this:
Code:
snap (Super Nintendo Assembling Program) is a multi-pass 65816 assembler.

USAGE:
snap [-s <sym-file>] <in-file> <out-file>

(<sym-file> is where the assembler will dump its symbol table in the end.
 This way you can easily determine what address a procedure is located at,
 so you can add breakpoints or whatever)

Expression parsing isn't done yet. It may be, one day. As need basis.

Macros are not implemented. They may never be.

Syntax generally follows that laid out in the WDC 65816 docs and datasheets.

COMPILING:
  just compiling all the C files and linking them together should do it.
  One day I might write a makefile.

  gcc -ansi -Wall -g -c *.c
  gcc -ansi -Wall -g *.o -o snap

TODO:
-absolute modifiers
-more math/expression parsing
-a bunch more directives
-more features for the existing directives
-riddled with bugs I am sure
-a makefile

WHAT'S DONE:
-all instructions/addressing modes
-very very basic math/expression parsing
-multipass optimization
-memmap output - very handy!

; comments look like this

LabelsLookLikeThis:
  JMP LabelsLookLikeThis
.localLabelsLookLikeThis:
  beq .localLabelsLookLikeThis

DefinesLookLikeThis: equ $20

LDA #DefinesLookLikeThis
STA DefinesLookLikeThis

INCSRC "defines.asm"
INCBIN "binarydata.bin"

ORG $8000 ; doesn't actually write any data, just changes the current PC

; the usual 65816 stuff
XCE
CLC
lda #$12       ; case insensitivity
sta $2100
LdA #%10010100 ; case insensitivity!
STA $00
LONGA ON
LONGA OFF
LONGI ON
LONGI OFF ; these don't actually emit the necessary REP/SEP ops - they're for
          ; the assembler only

PAD $FFC0 ; writes 0s until PC = operand

ASCII "GAME TITLE"
PAD $FFD5
DB $20
PAD $FFFC
DW Start



Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 4:07 pm 
Offline
User avatar

Joined: Thu Jan 19, 2006 5:08 pm
Posts: 642
Location: Shelton, Washington.
My criticism on this new assembler:

1: I hope it is ASM6/CA65/DASM syntax compatible (Syntax Standard)!

2: Macros are essential and helpful, and needed in order to make games, Otherwise it will be a mess of code.

3: Implenting Conditions like the common syntax is the best thing to do.
(such as IF, NOT, ELSE, THEN, and more.)

4: If you plan to do ASCII text, Make sure you do two things:

- Add Functions to Remap Table for certain SNES Fonts!
- Add an ERROR function to make the console pause with a custom message

5: A basic library of routines is optional, but needed. Note that I may create it for the next official release for you IF you can implent those**!

** Conversion will be based off Nevketsi's/Grog's code, Credit goes for them and me for any conversion

_________________
AKA SmilyMZX/AtariHacker.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2011 10:33 am 
Offline

Joined: Sun Mar 27, 2011 10:49 am
Posts: 31
Not sure what you mean by "syntax compatible". My syntax for the standard ops adheres to what WDC lays out, which is as close to a standard as there is, as far as I know. If other assemblers deviate from it without cause, that's on their head. The only thing not specified by WDC are assembler directives. I'm not especially familiar with ASM6/CA65/DASM, but my impression these vary wildly in terms of directives and aren't source compatible at all. Am I wrong?

Most of the other features you've suggested constitute a sort of bloat I'm not really interested in right now. If they happen to become useful to me in the future I may add them in. The source is also available, so if you're interested, feel free to fork and do your thing.

Aside: not to start an Us v. Them sort of thing, but I've always found the value of macros to be overstated. I've been working on a Game Boy game for the past year or so that stands at 15,000 lines of code, and despite working with an instruction set much less capable than the 65816's, and despite using an assembler loaded with macro capabilities (RGBDS), it doesn't contain a single macro. And while it's not the prettiest code in the world, to be sure, I don't think that (for the most part) it's a mess; I've been able to come back to it after weeks or months away just fine. In places where I did use macros, I eventually had to remove them to keep code size down, and the result was much cleaner and tidier than before. So my intuition is that macros generally serve to hide messy code and sweep it under the hug, not prevent it. Of course, macros are wildly popular, and I don't intend on criticizing their use by people who find them useful. Live and let live.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2011 11:31 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 846
I also consider macros an important feature of an assembler. I have a SNES project that contains maybe around 8000 lines of assembly code - and while I don't use macros everywhere, they do come in handy in some places to keep code verbosity down (e.g. by wrapping function calls with immediate arguments).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2011 12:15 pm 
Offline
User avatar

Joined: Thu Jan 19, 2006 5:08 pm
Posts: 642
Location: Shelton, Washington.
Syntax compatibility kinda in a way of ASM6.

Also: Labels should have both of the following methods:

Code:
;This needs Implentation
LBL1: .DB "Data Here"

;The bottom is implented already
LBL2:
         LDA #$12
         STA $1234

_________________
AKA SmilyMZX/AtariHacker.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 06, 2011 1:49 pm 
Offline

Joined: Sun Mar 27, 2011 10:49 am
Posts: 31
Ah - I didn't document that, mea culpa. Yes, labels on the same line as instructions is implemented and works well.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group