News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

How can I use @ProcName ?

Started by mineiro, February 19, 2023, 10:35:28 PM

Previous topic - Next topic

jj2007

Quote from: mineiro on March 10, 2023, 04:01:56 AMsource code will look ugly.

That's a matter of taste, of course.

Print "We are in ", ProcName$()

Vortex

@ProcName during assembly time :

include     \masm32\include\masm32rt.inc

sum PROTO :DWORD,:DWORD,:DWORD


PROCX MACRO procname:REQ,args:VARARG

    procname PROC args

    @ProcName TEXTEQU <procname>

ENDM


.data

f1  db '10 + 20 + 30 = %u',13,10,0

.data?

.code

start:

    invoke  sum,10,20,30
    invoke  crt_printf,ADDR f1,eax

    invoke  ExitProcess,0


PROCX sum,x:DWORD,y:DWORD,z:DWORD

% echo @ProcName

    mov     eax,x
    add     eax,y
    add     eax,z
    ret
   
sum ENDP

END start

mineiro

I'd rather be this ambulant metamorphosis than to have that old opinion about everything

LiaoMi

Quote from: HSE on March 09, 2023, 06:44:10 AM
Quote from: LiaoMi on March 07, 2023, 11:08:59 AM

ChatGPT  :biggrin:  :biggrin:  :biggrin:

In Microsoft Macro Assembler (MASM), @ProcName is a predefined symbol


Hello LiaoGPT!

What version you used to test that?

(I hope you don't believe what bot say  :biggrin: :biggrin:)

Hi HSE,

so many creative ideas we found in the wrong words  :biggrin:

UASM Reference 2.56
2.17) Additional Built-In Variables
@ProcLine, indicates the current source code line number relative to the start of the current
procedure.
@ProcName returns the name of the current procedure.
@Platform <0|1|2|3|4> indicating the currently platform target as WIN32, WIN64, ELF32, ELF64,
OSX MACHO64 to support improved cross platform assembly.
IF @Platform EQ 0
xor eax,eax
echo 'im 32bit windows'
ELSEIF @Platform EQ 1
xor rax,rax
echo 'im 64bit windows'
ELSEIF @Platform EQ 2
xor ebx,ebx
echo 'im 32bit linux'
ELSEIF @Platform EQ 3
xor rbx,rbx
echo 'im 64bit linux'
ELSEIF @Platform EQ 4
xor rbx,rbx
echo 'im 64bit OSX'
ENDIF
@LastReturnType, indicates the last function return type following an invoke call. Values are:
enum returntype {
RT_SIGNED = 0x40,
RT_FLOAT = 0x20,
RT_BYTE = 0,
RT_SBYTE = RT_BYTE | RT_SIGNED,
RT_WORD = 1,
RT_SWORD = RT_WORD | RT_SIGNED,
RT_DWORD = 2,
RT_SDWORD = RT_DWORD | RT_SIGNED,
RT_QWORD = 3,
RT_SQWORD = RT_QWORD | RT_SIGNED,
RT_REAL4 = RT_DWORD | RT_FLOAT,
RT_REAL8 = RT_QWORD | RT_FLOAT,
RT_XMM = 6,
RT_YMM = 7,
RT_ZMM = 8,
RT_PTR = 0xc3,
RT_NONE = 0x100
};

jj2007

Quote from: LiaoMi on March 12, 2023, 03:24:55 AMUASM Reference 2.56
2.17) Additional Built-In Variables
@ProcLine, indicates the current source code line number relative to the start of the current
procedure.
@ProcName returns the name of the current procedure.

Hi LiaoMi,

Can you give us a short but complete working example of @ProcName usage?

HSE

Hi LiaoMi!

Quote from: LiaoMi on March 12, 2023, 03:24:55 AM
UASM Reference 2.56
@ProcName returns the name of the current procedure.

:thumbsup: mineiro mention that.

After that I found that reserved word is in source code, apparently there is an offset storage, but I don't know how that can work   :biggrin:

HSE
Equations in Assembly: SmplMath

LiaoMi

Quote from: jj2007 on March 12, 2023, 03:35:47 AM
Quote from: LiaoMi on March 12, 2023, 03:24:55 AMUASM Reference 2.56
2.17) Additional Built-In Variables
@ProcLine, indicates the current source code line number relative to the start of the current
procedure.
@ProcName returns the name of the current procedure.

Hi LiaoMi,

Can you give us a short but complete working example of @ProcName usage?

Hi jj2007,

for me, like for others, constants do not work  :undecided: ..

http://masm32.com/board/index.php?topic=6821.msg73189#msg73189
johnsa
« Reply #6 on: January 08, 2018, 03:20:23 AM »
Quote
@ProcName is in,  the stack alignment issue is sorted and a bunch of other pending changes. 2.46.6 packages are up :)

dannycoh

Hi,
I'm using the latest UASM but am unable to figure out how to use @ProcName.
Is it a known bug?
Is it a const, a variable, or a pointer?
Please provide a short example of how to use it.
Please don't use C/C++ libraries.
Use only WinAPI console calls.

Vortex


jj2007

Hi danny,

As Vortex wrote, it's a macro. Or rather, it should be a macro, but it doesn't work:

somealgo proc args
tmp$ CATSTR <Myarg=>, <@ProcName>  ; echoes Myarg=@ProcName
% echo tmp$

somealgo proc args
tmp$ CATSTR <Myarg=>, @ProcName  ; chokes: Error A2144: Text item required
% echo tmp$

somealgo proc args
tmp$ CATSTR <Myarg=>, %@ProcName  ; echoes Myarg=0
% echo tmp$

In short: it is not working as it should :cool:

In case this is really important for you: it can be done with a tailored PROLOG macro. For example, in a MasmBasic program:

MbProbe=0    ; default is 1 (no warning)
WndProc proc hWnd, uMsg, wParam:WPARAM, lParam:LPARAM
Local buffer[4444]:BYTE

This will echo the following: *** warning: with 4444 local bytes in WndProc, you might run into guard page problems. Use StackBuffer instead ***

So technically, it's obviously possible. The question is why do you want this feature? How do you want to use it?

NoCforMe

Assembly language programming should be fun. That's why I do it.

jj2007

Quote from: NoCforMe on January 25, 2024, 08:43:33 PMDebugging would be my guess.

WndProc proc hWnd, uMsg, wParam:WPARAM, lParam:LPARAM
  print str$(@Line), 13, 10

dannycoh

Quote from: jj2007 on January 25, 2024, 08:13:26 PMHi danny,

As Vortex wrote, it's a macro. Or rather, it should be a macro, but it doesn't work:

somealgo proc args
tmp$ CATSTR <Myarg=>, <@ProcName>  ; echoes Myarg=@ProcName
% echo tmp$

somealgo proc args
tmp$ CATSTR <Myarg=>, @ProcName  ; chokes: Error A2144: Text item required
% echo tmp$

somealgo proc args
tmp$ CATSTR <Myarg=>, %@ProcName  ; echoes Myarg=0
% echo tmp$

In short: it is not working as it should :cool:

In case this is really important for you: it can be done with a tailored PROLOG macro. For example, in a MasmBasic program:

MbProbe=0    ; default is 1 (no warning)
WndProc proc hWnd, uMsg, wParam:WPARAM, lParam:LPARAM
Local buffer[4444]:BYTE

This will echo the following: *** warning: with 4444 local bytes in WndProc, you might run into guard page problems. Use StackBuffer instead ***

So technically, it's obviously possible. The question is why do you want this feature? How do you want to use it?
Yes, I need it for debugging.
If any procedure in my code fails, I want to log it with the @ProcName to know where to look for bugs.
I don't use MASM Basic, only pure UASM with WinAPI.
So, is it a formal bug and is being worked on to be fixed in the next UASM release?

jj2007

> I don't use MASM Basic
Your choice :biggrin:

> So, is it a formal bug and is being worked on to be fixed in the next UASM release?

The developers have not been very active recently.

Quote from: jj2007 on January 25, 2024, 09:59:18 PMWndProc proc hWnd, uMsg, wParam:WPARAM, lParam:LPARAM
  print str$(@Line), 13, 10
Pure UAsm.

Btw it would be very easy to write a preprocessor that checks for procs and inserts its name:

MyAlgo proc args
Local stuff
  ProcDebug "#insert_the_proc_name_here@"

ProcDebug MACRO arg
  if usePD  ; no code generation for usePD=0
    print arg, 13, 10
  endif
ENDM

I don't need it because I use MasmBasic, but maybe somebody of the bare metal purists volunteers to code it. Shouldn't take longer than 10 minutes (well, with MasmBasic :biggrin: ).

dannycoh

Quote from: jj2007 on January 26, 2024, 08:36:08 PM> So, is it a formal bug and is being worked on to be fixed in the next UASM release?

The developers have not been very active recently.

Oh no, this is very bad news.
Does it mean development has stopped and it's time to ditch and find some other assembler?