News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

how does masm know what a "pchar" is?

Started by bobl, May 17, 2013, 01:13:23 AM

Previous topic - Next topic

bobl

I was very kindly given this procedure and it works well.

fn1 proc C uses esi edi p:ptr PCHAR, n:DWORD
.
.
   print PCHAR ptr [edi+esi*PCHAR],13,10

I couldn't find any reference to PCHAR which isn't surprising since it does look rather C-like.
I'm therefore bewildered at how masm manages to deal with it.
If this is a stupid question...please forgive me.

dedndave

masm doesn't really deal with it   :P
\masm32\include\windows.inc does

you can look in that file and find
PCHAR                       typedef DWORD

which tells the assembler to treat PCHAR as a DWORD-sized data type
PCHAR is "pointer to char"

bobl

That's great. Once again...thank you for the explanation.

qWord

Quote from: dedndave on May 17, 2013, 01:23:10 AM
masm doesn't really deal with it   :P
MASM does handle types  :t
That PCHAR is defined as DWORD is an issue of the MASM32 SDK, where all pointer types are declared as DWORDs. For correct declared pointer types MASM also offers dereferencing. e.g.:
include \masm32\include\masm32rt.inc

_PCHAR typedef ptr CHAR

.const
    foo CHAR "some text"
.code
main proc
   
    mov esi,OFFSET foo
    assume esi: _PCHAR ; try also PCHAR
   
    xor ecx,ecx
    .while [esi+ecx]  ; [PCAHR] ==> CHAR
        inc ecx
    .endw
   
    assume esi:nothing
   
   
    exit
main endp
end main
MREAL macros - when you need floating point arithmetic while assembling!

bobl

Thank you very much for the additional information.
It's very much appreciated.