I am a bit in doubts as to if I should go into more detail with my observations. It's because while the corrected issues could have some practical impact and are improving the comfort for the programmer, the others are rather nitpicking and won't probably bring much effect even if improved...
Well, I give the basic idea, but really, this is nothing that limits the work with lhasm. I don't want to be ungrateful, lhTools are wonderful utilities and these small things cannot spoil the good impression about them.
The matter is there are several contexts in which the assembler expects a value. I've identified these different cases (there can be even more):
- .ORIGIN directive
- .EQU directive
- 8-bit immediate value like in LDA n
- 16-bit immediate value like in LD SP,mn
- displacement like in JR d
- absolute address in JP ab
However it seems the assembler uses different routines to evaluate the value in different contexts. As a result, the same expression is accepted in one context, but refused in another.
Below are several examples.
Example 1: Using decimal value in expression
Code : Tout sélectionner
LD H,[+#10]55 ; compilation error
JR +#10 ; ok
VAR1 .EQU +#160 ; ok
VAR2 .EQU [+#10]4455 ; compiles incorrectly as &440A
Code : Tout sélectionner
LDA 5 ; compilation error, should be '05'
LDA [+5]00 ; ok - in expression '0' not needed
; similarly:
VAR1 .EQU 445 ; error
VAR2 .EQU [+A]4455 ; ok
JR +3 ; error
JR +[+3]00 ; ok
Code : Tout sélectionner
.ORIGIN 4400 ; ok - standard use
.ORIGIN 440 ; ok, even though leading '0' is missing
.ORIGIN &4400 ; ok - new corrected behaviour
.ORIGIN \X4400 ; error (also for \U, \O)
.ORIGIN #10000 ; ok
.ORIGIN @37777 ; error
.ORIGIN VAR1 ; ok
.ORIGIN [+100]VAR1 ; error
I can do more testing if required, but again, I want to stress this is nothing important, and I would not come across these things if it wouldn't be for the previous discussion and the new version's testing. I suppose the observed behaviour has historical reasons and it would be probably difficult - and very likely not worth - to unify it for various context cases...
So thanks again for your work!