Iwarez
August 20th, 2010, 15:11
Ok, I'm in the process of converting high level code to asm to speed up some operations on binary trees. Now I've come to some situation where the asm code I wrote is so stupid looking that I thought that there MUST be a way to do it better 
What I have is this routine entry code:
Now I want to push a local variable memory location for another function that wants some of it's variables as reference instead of value.
So for example the local variable 'LastIndex' I did this:
The problem with that code is that
a) It doesn't clearly reference my local variable 'LastIndex'
b) It's 3 instructions
This code looks so stupid that I came here to ask for a better solution. I only learned asm from reversing so I hope I'm missing a very obvious instruction here...
I already looked through some dll's to find a similiar situation but I couldn't find one.
HELP!
Thanks in advance, I-Warez

What I have is this routine entry code:
Code:
Delete1ItemByPosition:
%define snNodeData ebp + 8
%define lStartIndex ebp + 12
%define Item ebp + 16
%define RebuildTreeFromIndex ebp - 4
%define CurrentParentIndex ebp - 8
%define bDone ebp - 12
%define ArrayPointer ebp - 16
%define LastIndex ebp - 20
push ebp
mov ebp, esp
sub esp, 20
Now I want to push a local variable memory location for another function that wants some of it's variables as reference instead of value.
So for example the local variable 'LastIndex' I did this:
Code:
mov ebx, ebp
sub ebx, 20
push ebx
The problem with that code is that
a) It doesn't clearly reference my local variable 'LastIndex'
b) It's 3 instructions
This code looks so stupid that I came here to ask for a better solution. I only learned asm from reversing so I hope I'm missing a very obvious instruction here...
I already looked through some dll's to find a similiar situation but I couldn't find one.
HELP!
Thanks in advance, I-Warez