real address of a member function

A

Account1

Im working a compiler/simulator environment which generates asm code also
( I generate it runtime ). The scheduler run in C++ which calls generated
assembly code in the following way:

fn_asm = ( void(*)() )p_process->asm_code->memory; // the generated asm
code stored in p_process->asm_code->memory, this is a memory area
fn_asm(); // calling the generated asm routine

In the asm code there are calling of CBuilder routines (routines of my
project ) which I call in the following way

// calling new_transaction()
a[0] = '\xB8'; w = 1; val = (int)&function_array[_NEW_TRANSACTION];
p = get_symbol_value( val );
p2 = conc_opcode( a, p, w, 4 );
add_opcode( p2, w+4, asm_code ); add_dis( "mov EAX,
&new_transaction", "", 5 );
add_opcode( "\xFF\x10", 2, asm_code ); add_dis( "call
[EAX]", "", 2 );
free_params( d1, ";}" );
//

Previously I prepared "function_array"
function_array[_NEW_TRANSACTION] = (int)&new_transaction;
....


"function_array" contains addresses of CBuilder routines (routines of my
project ). Now I decided to convert my project to really OOP ( only C++
classes ) but I cant resolve the "function_array" situation.
"new_transaction" would be a method now.


Thanks
 
M

Mike Wahler

Account1 said:
Im working a compiler/simulator environment which generates asm code also
( I generate it runtime ). The scheduler run in C++ which calls generated
assembly code in the following way:

fn_asm = ( void(*)() )p_process->asm_code->memory; // the generated asm
code stored in p_process->asm_code->memory, this is a memory area
fn_asm(); // calling the generated asm routine

In the asm code there are calling of CBuilder routines (routines of my
project ) which I call in the following way

// calling new_transaction()
a[0] = '\xB8'; w = 1; val = (int)&function_array[_NEW_TRANSACTION];
p = get_symbol_value( val );
p2 = conc_opcode( a, p, w, 4 );
add_opcode( p2, w+4, asm_code ); add_dis( "mov EAX,
&new_transaction", "", 5 );
add_opcode( "\xFF\x10", 2, asm_code ); add_dis( "call
[EAX]", "", 2 );
free_params( d1, ";}" );
//

Previously I prepared "function_array"
function_array[_NEW_TRANSACTION] = (int)&new_transaction;
...


"function_array" contains addresses of CBuilder routines (routines of my
project ). Now I decided to convert my project to really OOP ( only C++
classes ) but I cant resolve the "function_array" situation.
"new_transaction" would be a method now.

http://www.parashift.com/c++-faq-lite/pointers-to-members.html

-Mike
 
A

Account1

Mike Wahler said:
Account1 said:
Im working a compiler/simulator environment which generates asm code also
( I generate it runtime ). The scheduler run in C++ which calls generated
assembly code in the following way:

fn_asm = ( void(*)() )p_process->asm_code->memory; // the generated
asm
code stored in p_process->asm_code->memory, this is a memory area
fn_asm(); // calling the generated asm routine

In the asm code there are calling of CBuilder routines (routines of my
project ) which I call in the following way

// calling new_transaction()
a[0] = '\xB8'; w = 1; val = (int)&function_array[_NEW_TRANSACTION];
p = get_symbol_value( val );
p2 = conc_opcode( a, p, w, 4 );
add_opcode( p2, w+4, asm_code ); add_dis( "mov EAX,
&new_transaction", "", 5 );
add_opcode( "\xFF\x10", 2, asm_code ); add_dis( "call
[EAX]", "", 2 );
free_params( d1, ";}" );
//

Previously I prepared "function_array"
function_array[_NEW_TRANSACTION] = (int)&new_transaction;
...


"function_array" contains addresses of CBuilder routines (routines of my
project ). Now I decided to convert my project to really OOP ( only C++
classes ) but I cant resolve the "function_array" situation.
"new_transaction" would be a method now.

http://www.parashift.com/c++-faq-lite/pointers-to-members.html

-Mike

As far I know pointers to members is not a 32-bit address. I need the code
ptr.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,297
Messages
2,571,536
Members
48,284
Latest member
alphabetsalphabets

Latest Threads

Top