EdouardBERGE / rasm

RASM powerful Z80 assembler
132 stars 16 forks source link

All macro examples in RASM manual generate preprocess errors on v1.4 win64 #10

Closed BitFracture closed 3 years ago

BitFracture commented 3 years ago

I've experimented with several forms of syntax for macros (it seems there are a few in the RASM manual) and have been unsuccessful getting any of them to work.

For the sake of this discussion let's analyze this example:

        ; Define macro (from RASM manual)
        macro LDIXREG register,dep
            if dep<-128 || dep>127
                push BC
                ld BC,dep
                add IX,BC
                ld (IX+0),register
                pop BC
            else
                ld (IX+dep),register
            endif
        mend

        ; Minimal program to repro error
        org 0000h
        ld sp,FFFFh
        LDIXREG H,200
        LDIXREG L,32

I am using this command line from Windows, working directory includes the RASM binary.

rasm_win64 "error_repro.z80asm" -ob "error_repro.bin"

And the following error occurs:

Pre-processing [error_repro.z80asm]
Assembling
Error: [error_repro.z80asm:18] expression [DEP<-128||DEP>127] keyword [DEP] not found in variables, labels or aliases
Error: [error_repro.z80asm:18] expression [DEP<-128||DEP>127] keyword [DEP] not found in variables, labels or aliases
Error: [error_repro.z80asm:19] expression [DEP<-128||DEP>127] keyword [DEP] not found in variables, labels or aliases
Error: [error_repro.z80asm:19] expression [DEP<-128||DEP>127] keyword [DEP] not found in variables, labels or aliases
Error: [error_repro.z80asm:18] expression [((0)+DEP)] keyword [DEP] not found in variables, labels or aliases
Error: [error_repro.z80asm:18] expression [REGISTER] keyword [REGISTER] not found in variables, labels or aliases
Error: [error_repro.z80asm:19] expression [((0)+DEP)] keyword [DEP] not found in variables, labels or aliases
Error: [error_repro.z80asm:19] expression [REGISTER] keyword [REGISTER] not found in variables, labels or aliases
Error: 8 errors

If I bracket the arguments or params it makes no difference. Changing tabbing of the macro or invocation thereof does not alter error behavior. If I replace the parameter comma with a space it concatenates them and I get:

Pre-processing [error_repro.z80asm]
Assembling
Error: [error_repro.z80asm:18] MACRO [LDIXREG] was defined with 1 parameter {REGISTERDEP}
Error: [error_repro.z80asm:19] MACRO [LDIXREG] was defined with 1 parameter {REGISTERDEP}
Error: 2 errors

I've been successful in assembling several binaries with no macros, even those with the repeat directive. Great tool! I would love to sort out this issue with macros, whether it's in better communicating an error I'm making, or if there's an error with the assembler. Thank you!

OS: Windows 10 x64 10.0.19041.928 RASM: v1.4, v1.3, v1.2, v1.1 win64; further errors with v1.0

EdouardBERGE commented 3 years ago

I advise you to carefully read the documentation (how to use macro and macro itself) because you miss the "curly bracket" point and you did not copy all char of the macro for your example which is NOT in the documentation.

The only macro in the documentation who may not worked may be the register.low example as there is no curly brackets, i will advice the documentation writer

EdouardBERGE commented 3 years ago

Here is a temporary fix for low/high macro example which will assemble ld a,e

macro getlow16 reg
ld a,{reg}.low
mend
getlow16 DE
BitFracture commented 3 years ago

Thank you, I see "Arguments inside the macro are referenced using curly brackets" and now that I know what this looks like, this is very helpful! But my original confusion came from the example I copied above, which does not have curly brackets on the parameters in the PDF. I am using the Firefox internal PDF reader.

BitFracture commented 3 years ago

@EdouardBERGE I have identified the issue, the English version of the manual is incorrect (as I copied above) but the French version is as you described, showing the curly brackets.

EdouardBERGE commented 3 years ago

ok, i will open an issue for the documentation!

BitFracture commented 3 years ago

Thanks for the help! The brackets have solved all of my original issues