What does [4*4] is used for in the code below?
OPTION PROLOGUE:NONE ; turn off the stack frame
OPTION EPILOGUE:NONE
align 8
Base64Encode proc pInputData:DWORD,dwDataLen:DWORD,pOutputStr:DWORD
;
push ebp
push esi
push edi
push ebx
mov esi,[esp+1*4][4*4] ;pInputData
mov ebp,[esp+2*4][4*4] ;dwDataLen
mov edi,[esp+3*4][4*4] ;pOutputStr
Downloaded from http://www.geocities.com/asmsoft3264/src.html
Also has this line:
sub eax,[esp+3*4][1*4] ;pOutputStr
Dunno what's [1*4] is for!!!
I wrote it, so I think I can explain it :green2
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
this turns off automatic stack frame generation by masm
push ebp
push esi
push edi
push ebx
I preserve all non-volatile registers by stdcall convention, this makes esp decrease by 4*4 bytes
mov esi,[esp+1*4][4*4];pInputData
mov ebp,[esp+2*4][4*4];dwDataLen
I access first dword argument (1*4) and second (2*4) through esp and I also account for the "4*4" change
pop ebx
mov [eax],bp
pop edi
pop esi
sub eax,[esp+3*4][1*4];pOutputStr
pop ebp
ret 3*4
at the end esp is increased by 3*4 bytes because of the three "pop reg" instructions
hence, by accessing third argument (3*4) I only add 1*4 bytes.
finally function returns with 3*4 bytes popped by stdcall convention.
HTH
Wow!
Trying to understand the code, I'd been reading this:
http://www.asmcommunity.net/board/index.php?action=printpage;topic=29275.0
and:
http://blogs.msdn.com/larryosterman/archive/2007/03/12/fpo.aspx
But your explanation, drizz, was terrific! :U
.
.
.
I'd been playing:
mov esi,[esp+1*4][2*4][1*4][1*4];pInputData
That's cool!