Pelles C forum

Pelles C => Bug reports => Topic started by: Vortex on May 06, 2023, 10:00:52 PM

Title: Invalid syntax in macro definition
Post by: Vortex on May 06, 2023, 10:00:52 PM
Hi Pelle,

I coded a Poasm macro to easily handle rip-relative addressing on Windows 64-bit programming. The purpose is to replace the following syntax :

Code: [Select]
        mov     rip+hBrush,rax
with

Code: [Select]
        mov     hBrush,rax
The second hBrush statement is an equate defined as rip+_hBrush where _hBrush is declared in the .data? section by the macro.

Code: [Select]
ripVar MACRO var,type

    @CatStr( <_>,<var>,< >,<type>,< >,<?>)

    .echo @CatStr( <_>,<var>,< >,<type>,< >,<?>)

    var CATSTR <rip>,<+>,<_>,var

    .echo var

ENDM

Usage of the macro :

Code: [Select]
.data?

ripVar  hBrush,QWORD

The .echo statements are for debugging purpose.

Poasm Version 11.00.0 reports the following correct outputs and the source code is assembled without any issues:

Code: [Select]
"_hBrush QWORD ?"
"rip+_hBrush"
"_hModule QWORD ?"
"rip+_hModule"

Poasm Version 12.00.0 reports the following error messages :

Code: [Select]
ColorDlg.asm(26): error: Invalid use of '_hBrush'.
"_hBrush "
"rip"

ColorDlg.asm(27): error: Invalid use of '_hModule'.
"_hModule "
"rip"

Attached is the source code assembled with Poasm V11. Kindly, could you try the code with Poasm V12? Thanks.
Title: Re: Invalid syntax in macro definition
Post by: Pelle on May 07, 2023, 03:03:18 PM
I think it's the same problem that was also recently reported through email:
new Unicode handling counted terminator in the length for literal strings, so from "aa\0" and "bb\0" concat produced "aa\0bb\0\0" rather than "aabb\0".

Should be fixed by this version:
http://www.smorgasbordet.com/pellesc/1200/poasm_12_00_1.zip
Title: Re: Invalid syntax in macro definition
Post by: Vortex on May 07, 2023, 07:38:17 PM
Hi Pelle,

Thanks for the attachment. Poasm Version 12.00.1 solved the problem.
Title: Re: Invalid syntax in macro definition
Post by: Pelle on May 07, 2023, 09:13:10 PM
Great news, thanks. This version of POASM will be in the next Setup (either final or RC3, depending on events...)
Title: Re: Invalid syntax in macro definition
Post by: Vortex on May 20, 2023, 12:53:29 PM
Hi Pelle,

I wrote a second macro to handle structures :

Code: [Select]
ripSt MACRO var,type

;   .echo command for debugging purpose

LOCAL t

t TEXTEQU <{}>

    @CatStr( <_>,var,< >,type,< >,t )

;  .echo  @CatStr( <_>,var,< >,type,< >,t )

    var CATSTR <rip+_>,var

   .echo var

ENDM

The test of this new macro reports an error message :

Code: [Select]
.data?
.
.
ripSt       pnt,POINT

error: Symbol 'pnt' is undefined :

Code: [Select]
    mov     pnt.y,10
The POINT structure :

Code: [Select]
POINT STRUCT
  x  DWORD ?
  y  DWORD ?
POINT ENDS
Title: Re: Invalid syntax in macro definition
Post by: Pelle on May 20, 2023, 02:34:32 PM
Version 12.00 is done. I will see if this can be improved in any possible future version...

EDIT: In this case pnt.y is expanded to rip+_pnt.y, and it's unclear how to get a type from rip+_pnt...