News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

PROC param typing ?

Started by DC, January 31, 2006, 02:29:16 AM

Previous topic - Next topic

DC

is this:
xCreateFont proc    phFont:ptr HANDLE, pLF:ptr LOGFONT
the same as this:
xCreateFont proc    phFont:DWORD, pLF:DWORD
?
thanx,
DC
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

DC

this is where I'm going with this:
xCreateFont proc  uses edi  phFont:ptr HANDLE, pLF:ptr LOGFONT
    assume  edi:ptr LOGFONT
    mov     edi, pLF
    mov     eax, phFont
    mov     eax, [eax]
    .if eax
        invoke  DeleteObject, eax
    .endif
    invoke  CreateFont, [edi].lfHeight, [edi].lfWidth, [edi].lfEscapement, [edi].lfOrientation, [edi].lfWeight, \
                        [edi].lfItalic, [edi].lfUnderline, [edi].lfStrikeOut, [edi].lfCharSet, [edi].lfOutPrecision, \
                        [edi].lfClipPrecision, [edi].lfQuality, [edi].lfPitchAndFamily, [edi].lfFaceName
    assume  edi:nothing
    mov     edi, phFont
    mov     [edi], eax
    ret
xCreateFont endp

first - this "seems" to be working
is there a better way to use phFont? (<<<<< the question)
(reason for use of 'phFont:ptr HANDLE' is so I don't forget to use 'addr'  :red)
thanx
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

Tedd

It's mostly just for decoration :wink
So yes, you can put them all as DWORD - as long as you use them correctly, it makes little difference.
I don't know if there is something magic that happens if you specify a parameter as being a ptr - e.g. automatically de-referenced variable, but too much automatically generated code will lead to errors unless you know exactly what to expect; so I would avoid it.
No snowflake in an avalanche feels responsible.

zooba

There doesn't appear to be any code generation, but I'd imagine type checking would be performed and expect either a value of type PTR HANDLE or 'ADDR <value of type HANDLE>'

I personally use assembly to escape the inane typing required by most HLLs. A pointer is a pointer is a fr*kin' pointer! :U

DC

thanx guys,
my style is still embreyonic, but beginning to gell, I appreciate all the input you've been giving.
take care,
DC
this isn't daja vu, I'm just learning it for the 37th time
http://www.bmath.net

GregL

DC,

I think the more descriptive typing makes the code self-documenting and makes it easier to see what is going on. For a pointer to a string, for example, I would use PTR BYTE versus DWORD. To each his own. Do what works best for you.