J
JR
Hi Folks,
I'm trying to call a C# method from assembler language. Specifically, I'm
trying to persuade the Turbo68k emulator to interface with C#.
This is where the function is called in assembler:
push edx // Contains 'Data' parameter.
push ebx // Contains 'Address' parameter.
call dword [edi+12] // Call function.
add esp, byte 8 // Clean up.
Here is some extracts from the C# code:
public delegate void WriteWordHandler(uint Address, ushort Data);
public void WriteWord(uint Address, ushort Data)
{
}
I've also made a C .dll to help massage the data structures together.
(Essentially a series of functions, callable from C#, that set-up the
internal data structures for the emulator. These all appear to be working
correctly.)
Eg.
Turbo68k.SetWrWordHandler(WriteWord);
[DllImport("M68KEmulator.dll")]
public static extern void SetWrWordHandler(WriteWordHandler Handler);
The problem is when the WriteWord method is called the Address and Data
parameters contain the correct values, but when the WriteWord function
returns an exception is thrown saying ESP has not been saved over a function
call. I know the emulator code is configured and working correctly because
everything is working correctly until I need to call into managed code.
I've also tried the WriteWord method with the the following prototype:
public void WriteWord(uint Address, uint Data)
I tried it because I guess the assembler code is pushing eight bytes onto
the stack, but it results in the same error.
Thanks for your help.
John.
I'm trying to call a C# method from assembler language. Specifically, I'm
trying to persuade the Turbo68k emulator to interface with C#.
This is where the function is called in assembler:
push edx // Contains 'Data' parameter.
push ebx // Contains 'Address' parameter.
call dword [edi+12] // Call function.
add esp, byte 8 // Clean up.
Here is some extracts from the C# code:
public delegate void WriteWordHandler(uint Address, ushort Data);
public void WriteWord(uint Address, ushort Data)
{
}
I've also made a C .dll to help massage the data structures together.
(Essentially a series of functions, callable from C#, that set-up the
internal data structures for the emulator. These all appear to be working
correctly.)
Eg.
Turbo68k.SetWrWordHandler(WriteWord);
[DllImport("M68KEmulator.dll")]
public static extern void SetWrWordHandler(WriteWordHandler Handler);
The problem is when the WriteWord method is called the Address and Data
parameters contain the correct values, but when the WriteWord function
returns an exception is thrown saying ESP has not been saved over a function
call. I know the emulator code is configured and working correctly because
everything is working correctly until I need to call into managed code.
I've also tried the WriteWord method with the the following prototype:
public void WriteWord(uint Address, uint Data)
I tried it because I guess the assembler code is pushing eight bytes onto
the stack, but it results in the same error.
Thanks for your help.
John.