NO

Author Topic: Poasm macros in the Masm32 package  (Read 3985 times)

Offline Vortex

  • Member
  • *
  • Posts: 871
    • http://www.vortex.masmcode.com
Poasm macros in the Masm32 package
« on: January 28, 2024, 06:32:54 PM »
Hello,

This file coming with the Masm32 package :

Code: [Select]
\masm32\macros\pomacros.asm
contains a lot of useful macros for Poasm. Remembering and thanking to Steve Hutcheson, the maintainer of the Masm32\64 projects.

Here is a quick example, pomacros.asm defines the print and str$ macros :

Code: [Select]
.386
.model flat,stdcall
option casemap:none

include     MacroTest.inc
include     pomacros.asm

.code

start:

    print   str$(2024)
           
    invoke  ExitProcess,0

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

StdOut PROC _string:DWORD

    sub     esp,2*4
   
    invoke  GetStdHandle,STD_OUTPUT_HANDLE
    mov     DWORD PTR [esp+4],eax
   
    invoke  lstrlen,DWORD PTR [esp+12]
    mov     edx,esp
   
    invoke  WriteFile,DWORD PTR [esp+20],\
            DWORD PTR [esp+24],\
            eax,edx,0
           
    add     esp,2*4
    retn    4

StdOut ENDP

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

END start
Code it... That's all...

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Poasm macros in the Masm32 package
« Reply #1 on: February 03, 2024, 10:57:48 AM »
Very interesting, and it shows how close PoAsm remains to MASM. However, I get a weird error at the point where print attempts to WriteFile.

Code: [Select]
CPU Disasm
Address   Hex dump          Command                                  Comments
00401090  /$  55            push ebp                                 ; MacroTest.00401090(guessed Arg1)
00401091  |.  89E5          mov ebp, esp
00401093  |.  83EC 08       sub esp, 8
00401096  |.  6A F5         push -0B                                 ; /StdHandle = STD_OUTPUT_HANDLE
00401098  |.  E8 2C000000   call <jmp.&KERNEL32.GetStdHandle>        ; \KERNEL32.GetStdHandle
0040109D  |.  894424 04     mov [esp+4], eax
004010A1  |.  FF7424 0C     push dword ptr [esp+0C]                  ; /String
004010A5  |.  E8 25000000   call <jmp.&KERNEL32.lstrlenA>            ; \KERNEL32.lstrlen
004010AA  |.  89E2          mov edx, esp
004010AC  |.  6A 00         push 0                                   ; /pOverlapped = NULL
004010AE  |.  52            push edx                                 ; |pBytesWritten
004010AF  |.  50            push eax                                 ; |Size
004010B0  |.  FF7424 18     push dword ptr [esp+18]                  ; |Buffer
004010B4  |.  FF7424 14     push dword ptr [esp+14]                  ; |hFile
004010B8  |.  E8 18000000   call <jmp.&KERNEL32.WriteFile>           ; \KERNEL32.WriteFile
004010BD  |.  83C4 08       add esp, 8
004010C0  \.  C2 0400       retn 4

Buffer and Size are wrong. Plus, warnings No support for: 'PROLOGUE' and EPILOGUE 8)

No such problems when using your build.bat, though. So it may have to do with wrong options passed by my IDE. What does option /AIA32 mean?
« Last Edit: February 03, 2024, 11:11:16 AM by jj2007 »

Offline Vortex

  • Member
  • *
  • Posts: 871
    • http://www.vortex.masmcode.com
Re: Poasm macros in the Masm32 package
« Reply #2 on: February 03, 2024, 11:16:48 AM »
Hi Jochen,

I am using the latest version of Poasm :

Quote
Pelles Macro Assembler, Version 12.00.1
Copyright (c) Pelle Orinius 2005-2023

Syntax:
POASM [options] srcfile[.asm]

Options:
/A<name>            Select architecture: AMD64 (default) or IA32
/D<name>[=<value>]  Define a symbol (with optional value)

/AIA32 means Intel Architecture 32-bit.

Poasm supports the prologue and epilogue macros. Reading the manual :

Quote
User-defined prologue and epilogue macro (IA32) [8.00]
 
Purpose:
Macros for user-defined prologue and epilogue code for a PROC.

Syntax prologue macro:
name MACRO procname , flags , parambytes , localbytes , <reglist> [ , prologue-arg : VARARG ]

    [ body ]

    EXITM <localbytes>
ENDM

Syntax epilogue macro:
name MACRO procname , flags , parambytes , localbytes , <reglist> [ , prologue-arg : VARARG ]

    [ body ]

ENDM

Code it... That's all...

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Poasm macros in the Masm32 package
« Reply #3 on: February 03, 2024, 11:27:59 AM »
Thanks, Erol.

"Poasm supports the prologue and epilogue macros." - yes it does, but why then the warnings when using my standard MASM options? Not a problem, just a bit weird.

Offline Vortex

  • Member
  • *
  • Posts: 871
    • http://www.vortex.masmcode.com
Re: Poasm macros in the Masm32 package
« Reply #4 on: February 03, 2024, 11:33:14 AM »
Hi Jochen,

Could post your batch file building the executable or your IDE options? Maybe, I can try them.
Code it... That's all...

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Poasm macros in the Masm32 package
« Reply #5 on: February 03, 2024, 12:18:08 PM »
Hi Erol,

My batch file is an 11kB monster, but the one line that interests is
\masm32\bin\PoAsm /c /coff /AIA32 tmp_file.asm

Looks pretty harmless, right? No idea where the prologue & epilogue warnings come from 8)
Especially since I use the same identical line directly from the console, I only get the /c and /coff warnings...

Offline Vortex

  • Member
  • *
  • Posts: 871
    • http://www.vortex.masmcode.com
Re: Poasm macros in the Masm32 package
« Reply #6 on: February 03, 2024, 07:13:38 PM »
Hi Jochen,

Code: [Select]
\masm32\bin\PoAsm /c /coff /AIA32 tmp_file.asm
You are receiving those warnings because your version of Poasm located in \masm32\bin\ is probably old. You should download and use the latest version supplied with Pelles C :

Quote
For 64-bit Windows 7/8/10 host, targeting 32-bit or 64-bit Windows Vista/7/8/10. New
( Should work on Windows 11 too, but I have no means to verify that... )   12.00   May 19, 2023
http://www.smorgasbordet.com/pellesc/download.htm

No need of the options /c and /coff. Poasm can produce only MS COFF object modules and it does not pass the execution flow to any linker.

I can reproduce the problem :

Code: [Select]
G:\masm32\bin\poasm.exe /AIA32 MacroTest.asm
MacroTest.asm(16): warning: No support for: 'PROLOGUE'.
MacroTest.asm(17): warning: No support for: 'EPILOGUE'.
MacroTest.asm(38): warning: No support for: 'PROLOGUE'.
MacroTest.asm(39): warning: No support for: 'EPILOGUE'.

Switching to the latest version, Poasm V12 :

Code: [Select]
\PellesC\bin\poasm.exe /AIA32 MacroTest.asm
Poasm assembles the source code without any problem.

Two different versions of Poasm, this one supplied with the Masm32 package :

Code: [Select]
G:\masm32\bin\poasm.exe
Pelles Macro Assembler, Version 6.50.0
Copyright (c) Pelle Orinius 2005-2011

The latest release :

Code: [Select]
\PellesC\bin\poasm.exe
Pelles Macro Assembler, Version 12.00.1
Copyright (c) Pelle Orinius 2005-2023
Code it... That's all...

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Poasm macros in the Masm32 package
« Reply #7 on: February 04, 2024, 01:23:47 AM »
You are receiving those warnings because your version of Poasm located in \masm32\bin\ is probably old.

Hi Erol,

Thanks, that was my suspicion, too. I vaguely remember that I kept the older version because the latest polink no longer produced the symbol format needed for debugging with Olly.