- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to call a function by aCC inline assembly
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2011 10:54 PM
12-22-2011 10:54 PM
Hi,
I want to call a function by aCC inline assembly, but can't find a pseudo-function which can let me to make a call (some thing like _Asm_call).
any suggestions will be great help!
thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2011 10:57 PM
12-22-2011 10:57 PM
Re: how to call a function by aCC inline assembly
if any one can give out a sample code of call a function by aCC inline assembly of IA64, it will be more better: include push parameters, call, and return.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2011 12:02 AM - edited 12-23-2011 12:12 AM
12-23-2011 12:02 AM - edited 12-23-2011 12:12 AM
Re: how to call a function by aCC inline assembly
>I want to call a function by aCC inline assembly,
You can't and there is no need to do so. You do a normal call and intersperse your inline assembly _Asm_ calls.
You might want to explain what you are trying to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2011 12:23 AM
12-23-2011 12:23 AM
Re: how to call a function by aCC inline assembly
Hi Dennis,
thanks for your reply. I need to implement a call function interface. the method define is:
void* callfunction(int *data, int* type, int count, void* function_address). data: this array contains the parameters which will be passed to called function with the address: function_address, count: is the len of data, type: indicate the return type, can be int, float, double, long.
so I need to implement by assembley, can't use some thing like: function_address(.....) to call directly.
seems no inline asssembly can reach arm, but assembly can. can you give me an example of how to implement callfunction?
so thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2011 02:35 AM - edited 12-23-2011 02:37 AM
12-23-2011 02:35 AM - edited 12-23-2011 02:37 AM
Re: how to call a function by aCC inline assembly
>I need to implement a call function interface.
Are you writing some kind of interpreter?
>void* callfunction(int *data, int *type, int count, void* function_address).
What is this function returning in the void*?
The proper declaration for a generic function is: void (*function_address)(void)
>data: this array contains the parameters which will be passed to
Are there count int parms by value?
>so I need to implement by assembly,
You can't do this in assembly either.
>can't use some thing like: function_address(.....) to call directly.
You can but you need a doubly nested switch, one for the return type and one for the data parms.
For each return type and parms, you'll need to cast function_address to that function.
switch (*type) {
case T_int:
int ii = ((int (*)(int))function_address)(data(0));
I'm not sure how you are encoding your data array and count?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 07:17 PM
12-27-2011 07:17 PM
Re: how to call a function by aCC inline assembly
> switch (*type) {
> case T_int:
> int ii = ((int (*)(int))function_address)(data(0));
this is exactly the usage of this function, not the implementation. it needs return void* because it can return int, long, double, float, or a pointer. void* can be cast to any type.
"type" array indicates the type of data element, which can be int, float, long, double, pointer.
"count" indicates the length of type array.
"data" is an int array, but it is only a memory block, which will hold data format: int, float, long, double, pointer, according to the relative type.
the aim of data, type, and count is that: we can get input parameters for function whose address is function_address. the design of callfunction is to call any functions with differenet number & type of paramters.
because IA-64 use registers from r32 as in/local/out registers, and pass parameters by out registers, it is hard to let callfunction to call any number parameters functions. so I limit the called funtions' params' number to 4. that means called function at most has 4 parameters.
thanks for your reply.
I have implemented callfunction by asm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 07:21 PM
12-27-2011 07:21 PM
Re: how to call a function by aCC inline assembly
oh,
> switch (*type) {
> case T_int:
> int ii = ((int (*)(int))function_address)(data(0));
it is calling the function whose address is function_address. but the calling function's params' number is not fixed, it can have no param, or many. so I get no idea that I can directly call in this way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2011 10:50 PM
12-27-2011 10:50 PM
Re: how to call a function by aCC inline assembly
>It needs return void* because it can return int, long, double, float, or a pointer. void* can be cast to any type.
A void* can only be cast to a pointer to objects, not double/float, etc.
And if cast to a pointer, where is it going to point, if the function really returns an int?
>the aim of data, type and count is that: we can get input parameters for function whose address is function_address. the design of callfunction is to call any functions with different number & type of parameters.
Unless you have a more complex description of this, you can't do it with just those three.
>because IA-64 use registers from r32 as in/local/out registers, and pass parameters by out registers, it is hard to let callfunction to call any number parameters functions. So I limit the called functions' parms' number to 4. That means called function at most has 4 parameters.
The max is 8. The rest are on the stack.
>but the calling function's parm number is not fixed, it can have no parm or many.
You must have a switch for each possible case. Or always pass 8 parms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2012 09:15 PM
01-08-2012 09:15 PM
Re: how to call a function by aCC inline assembly
> A void* can only be cast to a pointer to objects, not double/float, etc.
it is not true. void* is a pointer, and a pointer can be cast by forcely to any other types. only need they have the same bytes. for example:
void* p = ...;
int ip = (int)(long)p; // for 64bit, pointer is 8 bytes, but int only 4 bytes, so first cast to long, then to int. but will lose 0x60000000000000000000
> if cast to a pointer, where is it going to point, if the function really returns an int?
it will truely cause an error under 64bit, but is okie under 32bit. when call a function, accroding to the return type, it will use the different return value funtion. if return type is float, float returning function will be called, e.g.
> The max is 8. The rest are on the stack.
this is useful. thanks. :-)
> You must have a switch for each possible case. Or always pass 8 parms.
correctly. that is the reason why I need assembly. because directly call as you suggested can't reach this aim. because of different number of params.
thanks for your great help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2012 09:18 PM
01-08-2012 09:18 PM