473,378 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

real address of a member function

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
Apr 9 '07 #1
2 1267

"Account1" <no****@hotmail.comwrote in message
news:c5***************************@news.chello.hu. ..
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-lit...o-members.html

-Mike
Apr 10 '07 #2

"Mike Wahler" <mk******@mkwahler.netwrote in message
news:iE******************@newsread1.news.pas.earth link.net...
>
"Account1" <no****@hotmail.comwrote in message
news:c5***************************@news.chello.hu. ..
>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-lit...o-members.html

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

Thanks

Apr 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Roy Yao | last post by:
Hello, I need to pass a pointer to a callback function to the lower level modules. But the function is thought to be a virtual member one. How can I get the real address of the virtual...
7
by: Howard | last post by:
Hi, in one of the recent posts, I saw someone pass two variables of built-in type (int and double), by reference, to a member function of a class. That function then took the addresses of those...
4
by: WittyGuy | last post by:
Hi all, Though I know the concepts of both abstract class & virtual function (like derived class pointer pointing to base class...then calling the function with the pointer...), what is the real...
28
by: marcpirat | last post by:
hi we create a real-time program on a embedded linux system. the program will run a few time by second i would like to know if it's better to create global variable or create the variable in...
8
by: gilad | last post by:
hi, I would like to get the address of a class method in an instance. In the following sample the third like access the method. how can I get the address into a long variable - something like -...
2
by: pascal.zschumme | last post by:
hello folks My problem is that the following code using something very very difficult technique :D fails to compile on MSVC8: <code> // main.cpp // // the error is: // main.cpp(8) : fatal...
11
by: !truth | last post by:
Hi, i feel confused about the following program, and it's works to get a pointer-member's address. #define NETDEV_ALIGN 32 #define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) ...
5
by: Neo | last post by:
hi, I searched in the groups here but didnt find any post answering my question. My question is I need the address of the member function in the same class. Is there anyway to go about it other...
17
by: Ben Bacarisse | last post by:
candide <toto@free.frwrites: These two statements are very different. The first one is just wrong and I am pretty sure you did not mean to suggest that. There is no object in C that is the...
11
by: Gabriel de Dietrich | last post by:
Hi all! Just out of curiosity: Is there any way to get the address of a particular virtual member function given an object? Some code to make things more clear... class A { public: A() { }
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.