etollerson
November 26th, 2004, 12:30 PM
I've written a couple of procedures in assembly and assembled them outside of VC6. I've linked them in with a simple console project. In the console app, I call the procedure in __asm block. Everything is OK. Works like a charm. But what I'm worried about is if I just stick the block anywhere will it affect registers that VC compiler is assuming unchanged. MSDN just has information on writing functions and prolog and epilog code. It claims that you can use EAX,EBX,ECX,EDX,EDI,and ESI, But then it says if you use EBX,ESI,or EDI then you force the compiler to prodece prolog/epilog code to preserve them. So if I just stick an __asm block anywhere can I assume I can use EAX,ECX,EDX at will and only preserve the others that I use.
__uint64 board = 0x10;
int firstBitSet;
__asm{
lea edx,board
call find_bit
mov firstBitSet,EAX
}
The above block along with find_bit modifies EAX,ECX,EDX without preserving them.Do I need to preserve them? Is there any documentation on this type of stuff? I preserve and use other registers and then restore them.
I'm writing asm procs to speed up getting the answer and I don't want to preserve something that VC doesn't mind me changing.
Also will board always be in data segment or stack segment in VC.
I think the DS and SS is the same.But I don't know if it is always true.
I used flat memory model in assembling
.MODEL C,FLAT
__uint64 board = 0x10;
int firstBitSet;
__asm{
lea edx,board
call find_bit
mov firstBitSet,EAX
}
The above block along with find_bit modifies EAX,ECX,EDX without preserving them.Do I need to preserve them? Is there any documentation on this type of stuff? I preserve and use other registers and then restore them.
I'm writing asm procs to speed up getting the answer and I don't want to preserve something that VC doesn't mind me changing.
Also will board always be in data segment or stack segment in VC.
I think the DS and SS is the same.But I don't know if it is always true.
I used flat memory model in assembling
.MODEL C,FLAT