6502 Assemblers

Programming the 6502 microprocessor and its relatives in assembly and other languages.
bartleph
Posts: 20
Joined: 06 May 2013

Re: 6502 Assemblers

Post by bartleph »

Well thanks to your considerable help I now have a source file that assembles albeeit with 10 Warnings regarding changed values on the 2nd Pass. I've checked out the byte values in those locations and the assembly is correct so a good result there. btw the -OP00/256*256+OP00 worked a treat. Those .BYTE lines showing as CMDERR-* and similar work fine left alone. I just removed the '?' and all assembles ok.

I've posted the modified asm listing in my public dropbox folder in case anyone would like a copy of it:- https://www.dropbox.com/s/l3gpkua9ynjyj ... 5.ASM?dl=0
Thanks again.
Paul
User avatar
BigEd
Posts: 11464
Joined: 11 Dec 2008
Location: England
Contact:

Re: 6502 Assemblers

Post by BigEd »

Great result - glad we were able to help.
User avatar
BigDumbDinosaur
Posts: 9428
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: 6502 Assemblers

Post by BigDumbDinosaur »

bartleph wrote:
Well thanks to your considerable help I now have a source file that assembles albeeit with 10 Warnings regarding changed values on the 2nd Pass
Such warnings are referred to as phase errors and often occur when an eight bit value is referenced in the source code before it's actually declared. For example, if you have LDA ZPADDR in the source before declaring that ZPADDR = $00 you have set up a condition for a phase error.

During the assembler's first pass, it doesn't "know" that ZPADDR can be represented in eight bits, since the ZPADDR declaration has yet to be encountered. Hence assembly of the instruction defaults to a 16-bit operand in most 6502 assemblers. Later on, the ZPADDR declaration is encountered, but the assembler has already internally defined ZPADDR as a 16-bit value. The result is the instruction is assembled with absolute addressing with a warning, or a phase error is emitted and assembly is halted. The latter behavior is the more common one in two-pass assemblers. In contrast, a three-pass assembler will correct the instruction's operand to reflect the declaration, this occurring during the third pass. A warning is issued to let the programmer know about the correction.

It's good programming practice to declare zero page locations and other eight bit values before you use them. That way the assembler will "understand" your intentions.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
bartleph
Posts: 20
Joined: 06 May 2013

Re: 6502 Assemblers

Post by bartleph »

Thank you so much for all your help and brilliant explanations chaps. It really does help to understand what is going on in order to get the right result.
KRs
Paul
Post Reply