Pelles C forum
Assembly language => Assembly discussions => Topic started by: Vortex on January 28, 2024, 06:32:54 PM
-
Hello,
This file coming with the Masm32 package :
\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 :
.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
-
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.
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?
-
Hi Jochen,
I am using the latest version of Poasm :
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 :
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
-
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.
-
Hi Jochen,
Could post your batch file building the executable or your IDE options? Maybe, I can try them.
-
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...
-
Hi Jochen,
\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 :
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 :
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 :
\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 :
G:\masm32\bin\poasm.exe
Pelles Macro Assembler, Version 6.50.0
Copyright (c) Pelle Orinius 2005-2011
The latest release :
\PellesC\bin\poasm.exe
Pelles Macro Assembler, Version 12.00.1
Copyright (c) Pelle Orinius 2005-2023
-
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.