boeckmann / asm6502

Small but useful 6502 assembler in ~3K lines of ANSI C code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement lossless conversion operators [b] and [w]

boeckmann opened this issue · comments

[b] converts a word-sized expression to type byte IF the value is within range. Otherwise an error is thrown. [w] converts an expression to type word.

[b] is different to the byte select operators < and > in the sense that these do not throw errors.

[b] and [w] have a low prority so that the folowing does not need parentheses:

lda [b] IDX + 5  ; 2-byte instruction, would otherwise be 3-byte
IDX = $10

X = [w]1    ; defines word-sized variable

Implemented by f56f7cc.

While running a series of very extensive assembler-lanuage test files (all of which are old now, but proven to be correct), I noticed that something that often fails is: foo: stx bar,y which can result in EITHER of two possible opcodes: STX-ZPY, or STX-ABY. The choice depends on the type of the primary operand ("bar") - if that is a byte, it will create a ZP opcode, otherwise it will leave it to be absolute.

Yes, thats is the reason for this byte / word data type thing, to make the assembler choose either zero page addressing or not depending on the operand size. The assemblers differ what symbols they are able to detect as byte-sized, with forward-references being the problematic ones.

I would be interested in the test files you created. I am currently working on a large test file: a port of the C64 Kernal. I am courious if I can get AS6502 to make an exact binary replicate. Perhaps I will put the source of it into its own repository as soon as it is able to build.