Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General Pointer as a stack parameter...

Status
Not open for further replies.

0x4B47

Programmer
Jun 22, 2003
60
US
If my data was somthing like this:
[c]
.data
ArraySize = 8
Array1 byte ArraySize 1, 2, 4, 8, 16, 32, 64, 128, 255
Array2 word ArraySize 512, 1024, 2048, 4096, 8192, 16384, 32768, 65535
Array3 dword ArraySize 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216
[/c]
and I had a procedure that took a pointer as a stack parameter like this:
[c]
procName proto,
pArray:ptr dword, aNumElems:dword, aType:dword
[/c]
then when I call the procedure like this:
[c]
Invoke procName, addr Array1, lengthof Array1, type Array1
[/c]
I'm gonna get problems bcoz Array1 is a byte array. I guess wot im asking is is there a way to generalize the pointer type when passed as a stack parameter? So that I can pass any type and the proc will accept it?

Any help or suggestions is appreciated.
Kunal.
 
0x4B47

I'm not quite understand what do you want. As I know, it depends on how you want to treat the value pass in the parameter.

I take from your example.

procName proto pArray:ptr dword, aNumElems:dword, aType:dword

.data
Array1 byte 1, 2, 4, 8, 16, 32, 64, 128, 255


If I call the function like this:

Invoke procName, addr Array1, lengthof Array1, 1
; aType = 1 - type of byte
; aType = 2 - type of word
; so on...

Then in the procName:
mov eax, pArray

; do comparison, if (aType == 1) then
mov bl, [eax+0]
mov bl, [eax+1]
mov bl, [eax+2]
; and so on ...

; do comparison, if (aType == 2) then
mov bx, [eax+0]
mov bx, [eax+2]
mov bx, [eax+4]
; and so on ...


Hope you understand what I'm trying to say
Regards

-- AirCon --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top