Assembly language > Assembly discussions

Poasm macros in the Masm32 package

(1/2) > >>

Vortex:
Hello,

This file coming with the Masm32 package :


--- Code: ---\masm32\macros\pomacros.asm
--- End code ---

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: ---.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

--- End code ---

jj2007:
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: ---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
--- End code ---

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?

Vortex:
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)
--- End quote ---

/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
--- End quote ---

jj2007:
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.

Vortex:
Hi Jochen,

Could post your batch file building the executable or your IDE options? Maybe, I can try them.

Navigation

[0] Message Index

[#] Next page

Go to full version