Trying to implement an enum macro :
include enumMacro.inc
; enum macro by mabdelouahab
; https://masm32.com/board/index.php?msg=126825
enum MACRO __vargs:VARARG
LOCAL val__
val__=0
FOR __varg,<__vargs>
__varg EQU val__
val__ = val__ +1
ENDM
ENDM
.data
format db 'test1 = %u',13,10
db 'sample = %u',13,10
db 'experiment = %u',0
.data?
buffer db 64 dup(?)
.code
start:
enum test1,sample,experiment
invoke wsprintf,ADDR buffer,\
ADDR format,test1,sample,experiment
invoke StdOut,ADDR buffer
invoke ExitProcess,0
END start
Running the executable, I receive the following results :
test1 = 3
sample = 3
experiment = 3
The correct version should be :
test1 = 0
sample = 1
experiment = 2
Poasm does not correctly assign the parameters.
Same result after this attempt :
enum MACRO p1,p2,p3,p4,p5,p6,p7,p8
LOCAL val__
val__=0
FOR arg,<p1,p2,p3,p4,p5,p6,p7,p8>
IFNB <arg>
arg EQU val__
val__ = val__ +1
ENDIF
ENDM
ENDM
test1 = 3
sample = 3
experiment = 3
Hello,
Testing the code above with Poasm Version 13.00.1, I am experiencing the same issue. All the three values are equal to 3 :
test1 = 3
sample = 3
experiment = 3
Adding the 4th parameter :
include enumMacro.inc
; enum macro by mabdelouahab
; https://masm32.com/board/index.php?msg=126825
enum MACRO __vargs:VARARG
LOCAL val__
val__=0
FOR __varg,<__vargs>
__varg EQU val__
val__ = val__ +1
ENDM
ENDM
.data
format db 'test1 = %u',13,10
db 'sample = %u',13,10
db 'experiment = %u',13,10
db 'eax = %u',0
.data?
buffer db 64 dup(?)
.code
start:
enum test1,sample,experiment,var
mov eax,var
invoke wsprintf,ADDR buffer,\
ADDR format,test1,sample,experiment,eax
invoke StdOut,ADDR buffer
invoke ExitProcess,0
END start
Output :
test1 = 4
sample = 4
experiment = 4
eax = 4
The correct value set should be :
test1 = 0
sample = 1
experiment = 2
eax = 3
I will look at it later, but I'm not completely convinced this is a bug.
At least weird use of __varg in both FOR param *and* body.
Hi Pelle,
Take your time and no worries. This simple example can be assembled with Poasm V13.00.1 :
.386
.model flat,stdcall
option casemap:none
enum MACRO p1,p2,p3
p1 EQU 0
p2 EQU 1
p3 EQU 2
ENDM
.code
start:
enum false,true,other
.echo true
mov eax,other
ret
END start
So what should the following produce?
num = 1
txt1 equ num
txt2 equ [num]
num = num + 1
.echo num
.echo txt1
.echo txt2
end
2 2 [2] ?
2 1 [2] ?
2 1 [1] ?
something else?
Hi Pelle,
Tested the code below with Masm and the Watcom derivative assembler Uasm :
include \masm32\include\masm32rt.inc
.code
start:
num = 1
txt1 equ num
txt2 equ [num]
num = num + 1
mov eax,num
mov ecx,txt1
mov edx,txt2
ret
end start
Disassembling the object modules :
_start PROC NEAR
mov eax, 2
mov ecx, 1
mov edx, 1
ret
_start ENDP
Selecting the output from your list :
2 1 [1]