11.3.5.2 LOCAL


. . SUB ESP, ENTER.

:

LOCAL 1, 2, =

, , .. , , , . , . .

.

int Fun (int x){

int a, b[2];

a=x; b[0]=b[1] = 2 *x;

return a+ b[0] + b[1];

}

;

;Int Fun (int x){

; Int a, b[2];

; a=x; b[0]=b[1] = 2 *x;

; return a+ b[0] + b[1];

;}

ideal

p686

model flat

extrn ExitProcess:proc

extrn Fun:proc

dataseg

x dd 5

y dd ?

codeseg

begin:

push [x]

call Fun

mov [y], eax

call ExitProcess

end begin

;

;Int Fun (int x){

; Int a, b[2];

; a=x; b[0]=b[1] = 2 *x;

; return a+ b[0] + b[1];

;}

ideal

p686

model flat

codeseg

begin:

proc Fun

public Fun

arg x:dword = z1

local a:dword, b:dword:2=z2

push ebp

mov ebp, esp

sub esp, z2

mov eax, [x]

mov [a], eax

mov [b], eax

add [b], eax

mov [b+4], eax

add [b+4], eax

mov esp, ebp

pop ebp

ret z1

endp

end