The MASM Forum

General => The Campus => Topic started by: bobl on May 17, 2013, 01:13:23 AM

Title: how does masm know what a "pchar" is?
Post by: bobl on May 17, 2013, 01:13:23 AM
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.
Title: Re: how does masm know what a "pchar" is?
Post by: dedndave on May 17, 2013, 01:23:10 AM
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"
Title: Re: how does masm know what a "pchar" is?
Post by: bobl on May 17, 2013, 01:28:18 AM
That's great. Once again...thank you for the explanation.
Title: Re: how does masm know what a "pchar" is?
Post by: qWord on May 17, 2013, 02:06:22 AM
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
Title: Re: how does masm know what a "pchar" is?
Post by: bobl on May 17, 2013, 03:47:28 AM
Thank you very much for the additional information.
It's very much appreciated.