473,799 Members | 3,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help I need to call a member from assembler code (WIN32)

Hi to all!
I have something like this:

class FWrap {
public:
virtual void READ (void) = 0;
}

class Optimized {
private:
FWrap* FFile;

public:
void Calc (void);
}

I need to optimize Calc routine as much as I can because it is called
billion of times. In Calc function I must call FFile->READ () within
assembler code.

I have something like this now ...

void Calc (void)
{
__asm {
MOV EAX, &this // I get cell address which contain
'this' address
MOV EBX, [EAX] // Now I have 'this' address in EBX
MOV ECX, [EBX].FFile // Cell address which contain 'FFile'
address
MOV EBX, [ECX] // Now EBX contain 'FFile' address (EBX
= PIC)
...
???
}
}

Now I must call READ with something like "CALL DWORD PTR [EBX + ADDRESS
OF READ]" but I have no Idea how I can get the right offset READ
function.
I've tried FWrap::READ, FFile.READ and so on ... but I can't figure out
how I can call the right function address.

Is vital for me to create a function made of asm at 100%

Anyone can help me?

Sep 7 '05 #1
3 1580

<en************ ***@gmail.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
Hi to all!
I have something like this:

class FWrap {
public:
virtual void READ (void) = 0;
}

class Optimized {
private:
FWrap* FFile;

public:
void Calc (void);
}

I need to optimize Calc routine as much as I can because it is called
billion of times. In Calc function I must call FFile->READ () within
assembler code.

I have something like this now ...

void Calc (void)
{
__asm {
MOV EAX, &this // I get cell address which contain
'this' address
MOV EBX, [EAX] // Now I have 'this' address in EBX
MOV ECX, [EBX].FFile // Cell address which contain 'FFile'
address
MOV EBX, [ECX] // Now EBX contain 'FFile' address (EBX
= PIC)
...
???
}
}

Now I must call READ with something like "CALL DWORD PTR [EBX + ADDRESS
OF READ]" but I have no Idea how I can get the right offset READ
function.
I've tried FWrap::READ, FFile.READ and so on ... but I can't figure out
how I can call the right function address.

Is vital for me to create a function made of asm at 100%

Anyone can help me?

You can use a global, extern "C" wrapper function to call the member
function. Then your assembly can simple call the global function.

ben
Sep 7 '05 #2
en************* **@gmail.com wrote:


I need to optimize Calc routine as much as I can because it is called
billion of times. In Calc function I must call FFile->READ () within
assembler code.
Is vital for me to create a function made of asm at 100%

Anyone can help me?


Not here. comp.lang.c++ is for platform independent C++.
Your question obivously deals with very platform specific things.
You need to ask in a newsgroup dealing with your particular compiler.

--
Karl Heinz Buchegger
kb******@gascad .at
Sep 7 '05 #3

en************* **@gmail.com wrote:
Hi to all!
I have something like this:

class FWrap {
public:
virtual void READ (void) = 0;
Do not use all uppercase names for functions. READ screams MACRO
according to established (and good!) conventions.
}

class Optimized {
private:
FWrap* FFile;

public:
void Calc (void);
}

I need to optimize Calc routine as much as I can because it is called
billion of times. In Calc function I must call FFile->READ () within
assembler code.
This reminds me about an example assemlber program, Borland sent out
many, many years ago. Written in wonderful Borland assembler and
awfully slow because all time was spent inside an inefficient
IO-routine.
I have something like this now ...

[snip]

Is vital for me to create a function made of asm at 100%
Are you sure? Did you profile your program. To me it looks as if the
time is spent in the read function.
Anyone can help me?


Your code would be most fragile. Surely not portable - not to other
compilers, not to the next release of the same compiler and not from
one compiler setting to another. Much better would be to delegate to
some function where the function-call is not virtual - e.g.
extern "C" void Read(FWrap* fw)
{
return fw->READ();
}

This would probably improve portability regardless of compilersetting s
(esp. if you decorate Read with __cdecl or whatever it is called), and
perhaps even from one compiler version to the next.
Still I recommend you not use my solution. Instead find out what takes
so much time.

/Peter

Sep 7 '05 #4

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

Similar topics

0
303
by: Dale McGorman | last post by:
The following is some code that I am trying to bring over from VB 6.0, that I have working there. I am trying to get to where I can talk to a USB device. I am stuck on how to correctly pass params to the API call SetupDiGetDeviceInterfaceDetail() I can get it to actully not fail, and it actully tells me that it returned 87 bytes which is correct, but it never fills my structure of DeviceInterfaceDetail, and of course return value is a failure...
3
2208
by: fischerjd | last post by:
Is Microsoft still producing/releasing the Microsoft Macro Assembler (MASM)? I just installed Visual Studio .NET 2003 (p/o an MSDN/AA subscription) and apparently MASM is not provided/installed with that product. Jim
12
2093
by: Anthony Jones | last post by:
Just a bit of background: I'm one of a group of FORTRAN programmers, looking to switch to C++. We are trying to write a few simple examples to demonstrate the power of the language to our manager, so he will send us all on a conversion course. One of many reasons is that our code is littered with examples of: SUBROUTINE PRINT_ITEM(ITEM, ITEM_TYPE) IF (ITEM_TYPE .EQ. SQUARE) THEN CALL PRINT_SQUARE(ITEM)
8
5483
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
2
3404
by: Tank | last post by:
How do I call OpenFileName Win32 API from C# ? Can someone show me a sample code ?
5
3718
by: trint | last post by:
I know that this function IS in this dll that comes with windows xp that allows bidirectional printing (you can search "bidispl.dll" on MSDN). However, I keep getting the same error all day, go to bed, get up, get the same error over and over. PLEASE Help! Here is the code and I'm just trying to get the FIRST function to work and there are three more: IBidiRequest Methods Method - Description SetSchema Sets the bidi schema string....
22
9262
by: SQACSharp | last post by:
I'm trying to get the control name of an editbox in another window. The following code set the value "MyPassword" in the password EditBox but it fail to return the control name of the EditBox. I'm sure the problem is the way i'm using the sendmessage API, the return string and the lParam return 0....is anybody have a clue? any sendmessage api expert here? public static extern Int32 FindWindow(String lpClassName,String
4
1783
by: smp9737 | last post by:
Hello. I'm developing a Win32 Console Application for a Smart Device (MotoQ). All i need to do is delete a file with a known name and path. I'm under the impression that I have to use File::Delete( path ) based on what MSDN is telling me. Thus I need to include mscorlib.dll ... I #using this and the method cannot be found. I have tried almost everything and am completely confused.
10
2118
by: CuTe_Engineer | last post by:
hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes #these are the operations + = , - = , * = , 1/ = only if 0 not in .
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.