473,624 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C++ optimization for emulators

Hello folks,

Does anyone have any information about good books about C/C++ optiimization?
I am developing my emulator by using C++ language. I compared generated
assembly sources between two
operator functions. To add a pair of 18-bit values by two different
operators below.

inline Word10& operator += (register const Word10 &val)
{
if ((rh += val.rh) & ~H10_MASK)
( rh &= H10_MASK, lh++ );
lh = (lh + val.lh) & H10_MASK;
return *this;
}

inline Word10& operator + (register const Word10& x, register const Word10&
y)
{
return Word10 (x) += y;
}

vs.

#define op_add3(z, x, y) \
if ((z.rh = x.rh + y.rh) & ~H10_MASK) \
( z.rh &= H10_MASK, z.lh++ ); \
z.lh = (x.lh + y.lh) & H10_MASK;

I compared two generated assembly lines and noticed that operator + function
has a few more
instructions than op_add3 macro function because it uses an extra temp pair
for returning
results. Their results are 23 instructions (operator +) vs. 18 instructions
(op_add3) However, I noticed that one instruction is wasted in middle of
operator + function in assembly line.
Does anyone have any segguestions about C/C++ optimization for writing
emulators?

Thank you!
Tim Stark
Jul 19 '05 #1
1 1672
Timothy Stark escribió:
inline Word10& operator += (register const Word10 &val)
{
if ((rh += val.rh) & ~H10_MASK)
( rh &= H10_MASK, lh++ );
lh = (lh + val.lh) & H10_MASK;
return *this;
}

inline Word10& operator + (register const Word10& x, register const Word10&
y)
{
return Word10 (x) += y;
}

vs.

#define op_add3(z, x, y) \
if ((z.rh = x.rh + y.rh) & ~H10_MASK) \
( z.rh &= H10_MASK, z.lh++ ); \
z.lh = (x.lh + y.lh) & H10_MASK;

I compared two generated assembly lines and noticed that operator + function
has a few more instructions than op_add3 macro function because it usesan
extra temp pair for returning results. Their results are 23 instructions


You can write something like:

inline void add_assign (Word10 & z, const Word10 & x, const Word10 & y)
{
if ((z.rh = x.rh + y.rh) & ~H10_MASK)
( z.rh &= H10_MASK, z.lh++ );
z.lh = (x.lh + y.lh) & H10_MASK;
}

By the way, is this code correct? You are incrementing the destination
lh and then assigning it a value in both versions.

Regards.
Jul 19 '05 #2

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

Similar topics

9
2390
by: Rune | last post by:
Is it best to use double quotes and let PHP expand variables inside strings, or is it faster to do the string manipulation yourself manually? Which is quicker? 1) $insert = 'To Be'; $sentence = "$insert or not $insert. That is the question."; or
0
1080
by: Aisha | last post by:
Hi all, this is my first message here.. I use visual studio .NET 2002 with MMIT , and i developed some webpages for mobile devices. i tested them on my cell phone, and they are working fine. however i want to use emulators. i installed openwave simulator but when i try to access the web page (which has the extension .aspx) it says: unsupported content type. i also downloaded visual embedded tools 3.0 to test on Pocket Pc, but i couldn't....
1
6400
by: Chumley Walrus | last post by:
I want to use an emulator to test some mobilewebform stuff (via visual studio.net IDE) , but I can't find anything for the Blackberry 6210, or compatible . I would also need some resources on how to use emulators to test coding. Thanks in advance Chumley
5
2384
by: wkaras | last post by:
I've compiled this code: const int x0 = 10; const int x1 = 20; const int x2 = 30; int x = { x2, x0, x1 }; struct Y {
5
2368
by: John | last post by:
Was curious if anyone codes C on a mainframe in TSO/ISPF and, if so, what they've done to get brackets ( ) recognized by both their terminal emulator and ISPF itself. I'm using Attachmate Extra & even though I've mapped my keyboard for brackets, they end up translated to strange characters in ISPF. I'm able to type a bracket & it shows up as such on the screen, but once I hit enter, it gets translated into some strange character. I...
1
1566
by: nitinpatel1117 | last post by:
i have a website, which as flash elements on the screen. I've tested it on all the major broswers, IE 6 & 7, firefox v1 & 2, opera, safari. Works perfect on all these broswers, However, i tested on windows XP, and now just found out that a part of the flash element does not work on firefox v2 when the user has windows vista OS. All other broswer on vista are fine, just Firefox seems to be affected. Same vesion of firefox on Vista and...
1
1862
by: saurabhamiable | last post by:
Can anyone please tell me that how emulators are used in C?
2
1353
by: refugeedeveloper | last post by:
Hello, Does anyone know how to debug applications using emulators?
20
2334
by: Ravikiran | last post by:
Hi Friends, I wanted know about whatt is ment by zero optimization and sign optimization and its differences.... Thank you...
0
8680
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...
1
8336
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
8482
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
7168
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
6111
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
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
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...
1
2610
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1487
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.