z00m128 / sjasmplus

Command-line cross-compiler of assembly language for Z80 CPU.
http://z00m128.github.io/sjasmplus/
BSD 3-Clause "New" or "Revised" License
374 stars 52 forks source link

DW with trailing comma on a line fails syntax check and adds a DWord 0 to ouput #148

Closed TinfoilAsteroid closed 2 years ago

TinfoilAsteroid commented 3 years ago
Version Platform Topic
v1.18.2 Windows Parsing

With an assembly target as ZX Spectrum Next, DW 1, 0, 0, 0 assembles to $01,$00, $00, $00, $00, $00, $00, $00

DW 1, 0, 0, 0, assembles to $01,$00, $00, $00, $00, $00, $00, $00, $00, $00

Given the trailing comma should that fail syntax?

ped7g commented 3 years ago

sorry, I'm unable to reproduce, can you share your other switches or check if you are really calling zoom's 1.18.2 sjasmplus binary and not some other variant/version?

My check.asm:

    DW 1, 0, 0, 0
    DW 1, 0, 0, 0,
    scf     ; just to emit something else

Leads to this when I try to assemble it:

$ sjasmplus-1.18.2 --version
SjASMPlus Z80 Cross-Assembler v1.18.2 (https://github.com/z00m128/sjasmplus)
$ sjasmplus-1.18.2 --msg=lst check.asm 
# file opened: check.asm
1     0000 01 00 00 00      DW 1, 0, 0, 0
1     0004 00 00 00 00
check.asm(2): error: Expression expected
2     0008 01 00 00 00      DW 1, 0, 0, 0,
2     000C 00 00 00 00
3     0010 37               scf     ; just to emit something else
4     0011
# file closed: check.asm

(or try to produce some small example and post the source, maybe it's particular way how you produce that line, that escapes the error message, although I can't think of any further modifications, I tried to add few types of end-of-line comments after that comma to see if something triggers extra word 0 in output, but haven't find anything)

ped7g commented 3 years ago

tried also ZXSPECTRUMNEXT device variant, with pre-filled memory with $FF to see if there's silent damage to the virtual device memory, and nope, still only eight bytes are modified by that DW, and trailing comma reported as "expression expected".

the device test variant:

    DEVICE ZXSPECTRUMNEXT
    ORG $8000 : DS 16,$FF
    ORG $8002 : DW 1, 0, 0, 0x4567,
    SAVEBIN "check.bin", $8000, 16

output:

$ hd check.bin 
00000000  ff ff 01 00 00 00 00 00  67 45 ff ff ff ff ff ff  |........gE......|
00000010

The 0x4567 is the last word written into the device memory.

TinfoilAsteroid commented 3 years ago

Hi, tried it again on a new set of code. this time it failed assembly giving "dbtest.asm(3): error: Expression expected" so looks like its no longer reproducable The example I used was:

                        org $4000
ShipEquipmentList       DB  0, 1, 2, 3
                        DB  4, 5, 6,
                        DB  8, 9, 10,11

Assembled with

sjasmplus --zxnext=cspect --msg=all --lst=dbtest.txt dbtest.asm

ped7g commented 3 years ago

hm, any chance you can try to reproduce in the original way how you encountered it?

Otherwise I'm afraid this will be difficult to catch. If you can recall anything non-standard about that failing case, it may help to track it down. Thank you.

ped7g commented 2 years ago

Closing this for now. If you or somebody will hit this issue again, please archive the project state so I can try to reproduce it on my machine.

(I have some suspicion this may happen in some more complex include/macro scenario, or if you had some older sjasmplus version somewhere in project folder, etc... so it is possible you will encounter this bug again in future - feel free to reopen then or report new issue, thank you).