NO

Author Topic: Invalid syntax in macro definition  (Read 2546 times)

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Invalid syntax in macro definition
« 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.
« Last Edit: May 07, 2023, 11:53:31 AM by Vortex »
Code it... That's all...

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Invalid syntax in macro definition
« Reply #1 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
/Pelle

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: Invalid syntax in macro definition
« Reply #2 on: May 07, 2023, 07:38:17 PM »
Hi Pelle,

Thanks for the attachment. Poasm Version 12.00.1 solved the problem.
Code it... That's all...

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Invalid syntax in macro definition
« Reply #3 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...)
/Pelle

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: Invalid syntax in macro definition
« Reply #4 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
« Last Edit: May 20, 2023, 01:14:50 PM by Vortex »
Code it... That's all...

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Invalid syntax in macro definition
« Reply #5 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...
« Last Edit: May 20, 2023, 03:00:23 PM by Pelle »
/Pelle