Is there a way to declare a label top-level instead of being a child of the current proc? I tried naming with a @-prefix but that just became part of the name. Feature request :-)
Stephan
I did not expect this result.
ld hl,value ; this line compiles as ld hl,(#0003) value: equ (1+2)
The unnecessary parentheses is due to the fact that its generated source code. I changed the source code generator so it will always prefix the value behind the equ with 0+
Hey inchl, it’s been brought up before… Really it is unfortunate that in Z80 assembly syntax () has a double meaning, both expression grouping and instruction value indirection.
Some assemblers has both types of equates, one (using "equ") for literal string substitution like C's #define and a separate one (using "=" for example) that evaluates the expression to a number first so that you can use whichever fits the situation best.
Good to hear that other assemblers have similar struggles and how they solve it. Though I don’t think there is a need for a separate keyword, if you want to evaluate the expression to a number first the simple solution is as inchl did by prefixing with a +
like equ +(1+2)
.
I don't think its a good idea to let the equ definition determine how the opcode that uses it is compiled. In my opinion all equs should be treated as a numeric value. When the 'ld hl-opcode' uses () its should be an address, otherwise a number (or when explicitly overruled by a + prefix)
I see benefits both the complete substitution type and the evaluated number type for different situations.
A macro instruction would work like the substitution in many cases though, it might depend on if macros are allowed to be put anywhere.
I think that as long as the semantics of the operators is properly and consistently defined in the documentation, both options are fine. Perhaps the problem comes from the fact that different assemblers have different semantics for the "equ" keyword, some of them using string substitution, some using lazy expression evaluation and some using eager expression evaluation. So, porting code/expectations form one assembler to another is tricky...
Small feature requeat for this great z80 compiler...
I managed to implement a lot of custom features by pre-processing the input for glass and parsing the bin-output and symbol-output files. Like:
- z80 mixed with c# (the c# outputs z80 code, very usefull for generating lookup tables, graphics etc, on the fly)
- c#-style namespaces (preventing duplicated labels)
- 24bit label values
- far call/jumps ('unlimited' program code size)
- a lot more.... to be presented at msxgoto40 for those interested
However... one thing is still missing and I need your help on that one.
I need glass to output the current lineNumber on warnings (on errors I managed to resolve it).
Also it would be usefull when label values can be used in the text of a warning/error. I use a lot of macros that generate warning for the developer, sadly the parameters used cannot be parsed in the text of the warning/error.
Hopefully in the next glass version this could be implemented. For now: glass is the best!