asMSX icon indicating copy to clipboard operation
asMSX copied to clipboard

[BUG] Code processed despite IF condition is not met

Open mvac7 opened this issue 1 year ago • 1 comments

Hello asMSX team!

Describe the bug I don't know if it is a pending issue or it is not working. I have tested the attached code and when assembling it processes everything as if the condition was not interpreted.

Current output

-------------------------------------------------------------------------------
 asMSX v1.1.0 MSX cross-assembler. asMSX Team. [2023-11-04]
-------------------------------------------------------------------------------

Parsing file TestIFDEF.asm
Expanding Macros
DONE Expanding Macros
Expanding REPT
Assembling source file TestIFDEF.asm
Parsing error: syntax error
TestIFDEF.asm, line 11: syntax error

Code

.BIOS
.BIOSVARS

.FILENAME "TESTIFD.ROM"

;--------------------------------------------------------------------
LABELEXIST:

;Case 1: The Label does not exist. The ELSE must be processed.
IFDEF THISLABELNOTEXIST
    CONSTANT1:	EQU $01
    CONSTANT2:	EQU $02
ELSE
CONSTANT1	EQU $01
CONSTANT2	EQU $02
ENDIF

;Case 2: The Label exist. The ELSE does not have to be processed.
IFDEF LABELEXIST
CONSTANT3	EQU $03
CONSTANT4	EQU $04
ELSE
    CONSTANT3:	EQU $03
    CONSTANT4:	EQU $04
ENDIF
;--------------------------------------------------------------------

.PAGE	1
.ROM

MAIN:
  DI
  LD    SP,[HIMEM]	;($FC4A) Stack at the top of memory
  EI

LOOP:		
  halt
    
  ld     A,7         
  call    SNSMAT
  sub     A,11111011B    ;ESC
  JR      Z,EXIT_HELP
	
  jp  LOOP

EXIT_HELP:
  call 0

TestIFDEF.asm.TXT

mvac7 avatar May 02 '24 11:05 mvac7

Failure to run is due to syntax error (unexpected : as is invalid), although I see your point of "should not be processed" as the condition is not met in both cases.

In this case, the error is generated during "preprocessing" phase 1, so it will check that all the code is valid and can be included.

duhow avatar Sep 04 '24 10:09 duhow