Quote
Mike Welch wrote:
> John,
> Would it be too much to ask you to discuss this on the delphi forum in a
> little more detail? From the looks of your example there, you don't
> have PUSH any stack frames or anything before jumping right into Asm? I
> take it then that it must be done for you.
Yes, Delphi sets up the stack frame for you.
Quote
> And what about preservation of register values? Do they need to be restored to > their original value upon exit?
Yes, I forgot to mention that in the example.
You must preserve EDI, ESI, EBP and EBX.
You can freely modify EAX, EDX and ECX.
You can preserve the registers by pushing them on the stack and popping
them off afterwards:
procedure MyASM; assembler;
asm
PUSH EDI; PUSH ESI; PUSH EBP; PUSH EBX
// do your thing...
POP EBX; POP EBP; POP ESI; POP EDI
end;
Of course, registers that you don't use in your code don't need to be
pushed and popped.
You must also remember that if you call another routine in your assembly
code, you cannot assume anything about the values in the registers other
than EDI, ESI, EBP and EBX when the routine returns.
Quote
> I haven't been able to find much on assembler in Delphi and anything you
> may have learned would probably be of benefit to more than just myself.
The assembler in Delphi works like any other assembler, so if you want
do to assembler in Delphi you should get a book on assembler for the
i486.
Of course, Delphi doesn't have fancy features like macro's, etc.
You must only remember that:
* Delphi sets up the stack frame for you (ENTER and LEAVE
instructions),
* You must preserve EDI, ESI, EBP and EBX
* Delphi's calling conventions are different (see Object Pascal
Language Guide, chapter 17)
* You need to use Delphi-style comments, not semicolons
* Multiple assembler statements on a single line must be separated by
semicolons
* Windows 95 will not allow you to do just anything. Interrupts, ports
and the like will not be accessible. You need to write a VxD to do that.
Regards,
John.
--
*** ****** *******
* mailto:joh...@tornado.be *
* http://www.tornado.be/~johnfg/ *
******* ****** ***