Monday, November 03, 2025
Limitations of a two-pass assembler
I’ve come to realize that supporting foward references in a two-pass assembler isn’t always easy. The simple case of forward references I support:
lda	#alpha
alpha	equ	5
On pass 1, alpha isn’t defined, but by pass two, we have its value—5.
With this code, however:
lda	#alpha
alpha	equ	bravo
bravo	equ	5
alpha is undefined on line 1, and it remains undefined even on line 2 because we haven’t defined bravo yet. Thus when we end pass 1, alpha is still undefined. That it took me two years to even stumble across this issue is a bit surprising to me. I just haven’t written 6809 assemb…
Monday, November 03, 2025
Limitations of a two-pass assembler
I’ve come to realize that supporting foward references in a two-pass assembler isn’t always easy. The simple case of forward references I support:
lda	#alpha
alpha	equ	5
On pass 1, alpha isn’t defined, but by pass two, we have its value—5.
With this code, however:
lda	#alpha
alpha	equ	bravo
bravo	equ	5
alpha is undefined on line 1, and it remains undefined even on line 2 because we haven’t defined bravo yet. Thus when we end pass 1, alpha is still undefined. That it took me two years to even stumble across this issue is a bit surprising to me. I just haven’t written 6809 assembly code like this.
Can I fix this? If I add another pass, probably. If I don’t want to add another pass … I don’t know. I would have to track expressions that aren’t fully defined in pass 1, which could be a lot of work for an issue that might not come up all that often (if my own code is to go by). I mean, things can get quite pathological:
lda	#Alpha
Alpha 		equ	Bravo+1
Bravo           equ	Charlie+1
Charlie		equ	Delta+1
Delta		equ	Echo+1
Echo		equ	Foxtrot+1
Foxtrot		equ	Golf+1
Golf		equ	Hotel+1
Hotel		equ	India+1
India		equ	Juliet+1
Juliet		equ	Kilo+1
Kilo		equ	Lima+1
Lima		equ	Mike+1
Mike		equ	November+1
November	equ	Oscar+1
Oscar		equ	Papa+1
Papa		equ	Quebec+1
Quebec		equ	Romeo+1
Romeo		equ	Sierra+1
Sierra		equ	Tango+1
Tango		equ	Uniform+1
Uniform		equ	Victor+1
Victor		equ	Whiskey+1
Whiskey		equ	Xray+1
Xray		equ	Yankee+1
Yankee		equ	Zulu+1
Zulu 		equ	1
lsawm (part of LWTools) does properly handle this pathological case but it does six passes, not two. The other 6809 assembler I have, an older one written back in the 90s, doesn’t and issues deceptive error messages, so it’s not like I’m the only one to not handle this properly.
As of now, I just issue an error and let the programmer deal with it.
You have my permission to link freely to any entry here. Go ahead, I won’t bite. I promise.
The dates are the permanent links to that day’s entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:
https://boston.conman.org/2000/08/01
You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.
You may also note subtle shading of the links and that’s intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It’s an experiment in using color shading to denote the distance a link is from here. If you don’t notice it, don’t worry; it’s not all that important.
It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.