Skip to content

IFCONST doesn't seem to work for string constants #156

@lharsfalvi

Description

@lharsfalvi

I was attempting to pass data to the assembly job using dasm's -D option, and deal with the externally supplied parameters in the asm source code in a more or less conditional manner.

I noticed something interesting - in the asm source, IFCONST did indeed fire to the existence of numeric string constants, but missed any string constants.

First I had thought that was related to defining symbols on the command line (the way I defined these string symbols), but it seems it was not. Finally I put together a test asm file (see below).

So at this point (considering the results) I have to think that the string constant is being created (correctly) in any case. OTOH, IFCONST and IFNCONST don't seem to work for string constants.

dasm in question is 2.20.14.1 , OS is Linux.

Command: dasm const.asm -lconst.lst -oconst.prg -DP_NUM=1234 -DP_STR="\"Foo\""

Asm source:

	PROCESSOR 6502

	SEG text
	ORG $1000

; Defined externally
; Numeric constant

	IFNCONST P_NUM
	ECHO "P_NUM is not a constant"
	ENDIF

	IFCONST P_NUM
	ECHO "P_NUM is a constant"
	ENDIF

; String constant

	IFNCONST P_STR
	ECHO "P_STR is not a constant"
	ENDIF

	IFCONST P_STR
	ECHO "P_STR is a constant"
	ENDIF

; Let's see what dasm really thinks they exist

	ECHO "P_NUM is", P_NUM
	ECHO "P_STR is", P_STR

	DC.L P_NUM
	DC P_STR

; Now defined inline

NUM	EQU	1234
STR	EQU	"Foo"

; Numeric constant

	IFNCONST NUM
	ECHO "NUM is not a constant"
	ENDIF

	IFCONST NUM
	ECHO "NUM is a constant"
	ENDIF

; String constant

	IFNCONST STR
	ECHO "STR is not a constant"
	ENDIF

	IFCONST STR
	ECHO "STR is a constant"
	ENDIF

	ECHO "NUM is", NUM
	ECHO "STR is", STR

Output:

 P_NUM is a constant
 P_STR is not a constant
 P_NUM is $4d2
 P_STR is Foo
 NUM is a constant
 STR is not a constant
 NUM is $4d2
 STR is Foo

Complete. (0)

List file:

------- FILE const.asm LEVEL 1 PASS 1
      1  0000					      PROCESSOR	6502
      2  0000 ????
      3  0000 ????				      SEG	text
      4  1000					      ORG	$1000
      5  1000
      6  1000							; Defined externally
      7  1000							; Numeric constant
      8  1000
      9  1000				  -	      IFNCONST	P_NUM
     10  1000				  -	      ECHO	"P_NUM is not a constant"
     11  1000					      ENDIF
     12  1000
     13  1000					      IFCONST	P_NUM
 P_NUM is a constant
     14  1000					      ECHO	"P_NUM is a constant"
     15  1000					      ENDIF
     16  1000
     17  1000							; String constant
     18  1000
     19  1000					      IFNCONST	P_STR
 P_STR is not a constant
     20  1000					      ECHO	"P_STR is not a constant"
     21  1000					      ENDIF
     22  1000
     23  1000				  -	      IFCONST	P_STR
     24  1000				  -	      ECHO	"P_STR is a constant"
     25  1000					      ENDIF
     26  1000
     27  1000							; Let's see what dasm really thinks they exist
     28  1000
 P_NUM is $4d2
     29  1000					      ECHO	"P_NUM is", P_NUM
 P_STR is Foo
     30  1000					      ECHO	"P_STR is", P_STR
     31  1000
     32  1000		       d2 04 00 00	      DC.L	P_NUM
     33  1004		       46 6f 6f 	      DC	P_STR
     34  1007
     35  1007							; Now defined inline
     36  1007
     37  1007		       04 d2	   NUM	      EQU	1234
     38  1007		       00 46 6f 6f STR	      EQU	"Foo"
     39  1007
     40  1007							; Numeric constant
     41  1007
     42  1007				  -	      IFNCONST	NUM
     43  1007				  -	      ECHO	"NUM is not a constant"
     44  1007					      ENDIF
     45  1007
     46  1007					      IFCONST	NUM
 NUM is a constant
     47  1007					      ECHO	"NUM is a constant"
     48  1007					      ENDIF
     49  1007
     50  1007							; String constant
     51  1007
     52  1007					      IFNCONST	STR
 STR is not a constant
     53  1007					      ECHO	"STR is not a constant"
     54  1007					      ENDIF
     55  1007
     56  1007				  -	      IFCONST	STR
     57  1007				  -	      ECHO	"STR is a constant"
     58  1007					      ENDIF
     59  1007
 NUM is $4d2
     60  1007					      ECHO	"NUM is", NUM
 STR is Foo
     61  1007					      ECHO	"STR is", STR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions