BigDumbDinosaur wrote:
Garth's suggestion that you structure your assembler to process in two passes and then use additional passes in the event of a phase error is a good one. I would set a limit on the maximum number of passes, only to avoid having the assembler get stuck in a loop if the same phase error repeats. In the overwhelming majority of cases, two passes will resolve all forward references.
In the one I was using, the progress report on the screen would let you know if it was stuck, and you could abort it at any time if it was taking unreasonably long.
Quote:
Quote:
One other (very small) point is that many assmeblers use the $ sign to represent a hex number. I prefer the & sign. I know, I know: it's extremely minor - but it's another reason
Again,
$ is used as a hexadecimal radix because it is the MOS Technology standard (also borrowed from 6800 assembly language). The other standard radices are
% for binary and
@ for octal. Going against the grain won't make your assembler any better, but it will make it harder for experienced programmers to use.
Another way that works with all the assemblers I've used is to put "H" after the number, so you could write for example $1A0 or 1A0H. I suppose we all have our personal peeves. I absolutely detest C's "
0x1A0" for example, as "x" in any other context means that either that digit is unknown or it doesn't matter, so it could be $001A0 or 011A0 or $021A0 etc.. And why put a leading 0 on it. I don't put a leading 0 on my age or address or the clock speed of my computer or anything else.
BitWise's assember that he linked to above does seem to be an excellent one, and it's nice that he has built the nestable program structures into it already. I have an article (with accompanying source code for the C32 assembler) on doing them with macros at
http://wilsonminesco.com/StructureMacros/index.html for those who want to do it on other assemblers. Anton Treuenfels (teamtempest here on the forum) also has his
HXA 6502 assembler with the program-structure capability modeled after the article. These give things like FOR...NEXT, IF...ELSE...END_IF, BEGIN...UNTIL, BEGIN...WHILE...REPEAT, CASE statements, etc. with (in most cases) absolutely no penalty in runtime speed or memory, because they assemble exactly the same code you would write out by hand, just from much more readable source code. Looking at the machine-language output, you wouldn't be able to tell which source code it came from, because it's the same.
However you write your assembler though, I would encourage that you consider macros to be a must-have.