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

snarfblASM-Anybody willing to test?

snarfblASM-Anybody willing to test?
by on (#78273)
Hello NesDev.

I've written a 6502 assembler, snarfblASM, as part of a larger project. Not that the world really needs another 6502 assembler, but I wanted an assembler that could be integrated into my project, and I couldn't find one written in C#, so I wrote my own. I figured I would release a stand-alone version as well.

I was hoping that I could get some help testing. The help I've gotten so far has proven invaluable.

Notes (More detailed documentation is available at http://snarfblam.com/words/?p=210):
  • Requires .Net Framework 2.0
  • The assembler is aimed to be most similar to ASM6, but is stricter on syntax (labels require colons, directives require dots).
  • There is no macro support.
  • For users of ASM6 this means you can't declare constants with the EQU syntax (but "name = value" works fine).
  • ASM6-style + and - labels are supported, as well as * labels, which work a bit differently.
  • Where as ASM6 would use zero-page addressing for something like (LDA $0000) snarfblASM only uses zero-page addressing when an 8-bit value is specified (LDA $00). This can cause differences between ASM6 and snarfblASM output.


Whether you do something simple, like run a couple of ASM files you have sitting around, or throw everything in your bag of tricks at it to try to break it, it would be hugely appreciated.
Re: snarfblASM 6502 Assembler - Anyone want to test?
by on (#78274)
snarfblam wrote:
Where as ASM6 would use zero-page addressing for something like (LDA $0000) snarfblASM only uses zero-page addressing when an 8-bit value is specified (LDA $00). This can cause differences between ASM6 and snarfblASM output.

Then what kind of addressing does it use if you define a label using an equate?
Re: snarfblASM 6502 Assembler - Anyone want to test?
by on (#78275)
tepples wrote:
Then what kind of addressing does it use if you define a label using an equate?

Some might say it depends on the value you used in the equate (variable EQU $0000 vs variable EQU $00), but I for example never define my variables like that. I use "reserve" commands to declare my variables, so that it's easier to move them around in case I want to. In that case the variables aren't assigned explicit addresses, they are relative to the last value of the PC.

by on (#78276)
snarfblASM makes a distinction between 8- and 16-bit values, similar to the way that C would distinguish between "short int" and "char" values.

Code:
zpAddress1 = $02
absoluteAddress1 = $0002

.enum 0
    zpAddress2: .dsb
.ende

.org $8000
absoluteAddress2:

by on (#78278)
Code:
; does this wrap or is it in stack?
zpAddress0 = $C0
zpAddress64 = zpAddress0 + 64

; and what happens with base 10 addresses?
zpAddress = 255


See also the last time we discussed typed pointers, along with some syntax suggestions that resulted.

by on (#78281)
tepples wrote:
Code:
; does this wrap or is it in stack?
zpAddress0 = $C0
zpAddress64 = zpAddress0 + 64

; and what happens with base 10 addresses?
zpAddress = 255



TFM wrote:
snarfblASM works with two kinds of values: 8-bit values (byte) and 16-bit values (referred to as “word”, though, technically, the word size for 6502 is 8-bit). The byte versus word distinction can be important in certain circumstances. Adding two 8-bit values produces an 8-bit value, and truncation may occur


As far as decimal literals, right now values less than 256 are treated as 8-bit, though I would encourage you to think of the behavior as undefined. I've got a unary "widen" operator, <> (which compliments the low-byte < and high-byte > operators). So you could write a 16-bit decimal number as "<>105" and an 8-bit decimal number as "<105".

If you perform math on 8-bit numbers, the result will be truncated. $C0 + 64 = 0. Interestingly, this mirrors the behavior of zero-page addressing. If this bothers you, there is an option to enable overflow checking, which will throw an error when truncation would occur. I can see where you might have a problem with 200 + 200 = 144. It might be best to enable overflow checking by default, or provide an option for asm6-like behavior.

I could have gone with special mnemonics or operations to force addressing (lda.zp or lda<), but I found the sort of "typing" system I have more attractive. Again, I sought something resembling C-style integer typing. To me this best reflects intentions; if you write $0000 you are probably thinking in terms of absolute addressing, and if you write $00 you are probably thinking it terms of zero-page. But this approach still leaves the option of using an operator to specify an addressing mode (lda <label or lda <>label).