News:

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

question about the activation record

Started by jaysicks, December 06, 2011, 04:15:47 PM

Previous topic - Next topic

jaysicks

Hi,
my question is: how exactly the parameters stored in the activation record?

I've read about the topic a lot, but
the problem is, when the parameters are any of "smaller-than-4-bytes" datatypes.

For example:
Procedure proc(VAL i:int32; VAL j:int16; VAL k:int16);@nodisplay;

since it isn't mentioned anywhere, that all parameters allocate (at least) a 4-bytes blocks,
I would expect k to be on EBP+8, j on EBP+10 and i on EBP+12.

But according to a few stdout.puts, it's not the case.
k is on EBP+8, j is on EBP+12, and i is on EBP+16.

Is it really the case? Has it always been this way?

sidenote: I wouldn't be surprised, if I had used VAR instead of VAL, but I didn't :/

Thanks in advance

Sevag.K

var and val both need the same amount of storage, the only difference being in how they are treated for the purpose of data access.

all the parameters are stored in the stack, and they are done in a specific way given that you are using high level procedure declarations, i can't remember exactly where, but i believe it is mentioned that 4-bytes are used.  the way hla does it is typical to the way it's done by high level languages, but in hla, you have full control and you can build your own activation record if you add the @noframe switch.


MichaelW

Per Agner Fog's calling_conventions.pdf, available here:
Quote
The stack pointer must be aligned by the stack word size at all times.
In 32-bit code the stack word size is 32 bits. I don't know about HLA, but for MASM when the invoke directive is presented with a word (2-byte) argument, it maintains the stack pointer alignment by pushing a word with the value of zero before it pushes the argument.

eschew obfuscation