Having a go with assembly... how do I copy a double into a register??


I'm trying to speed up a maths routine which consists of much
iterative multiplication (and adding and subtraction of ) doubles.

Now if I declare my doubles as floats 

float f
double d

_asm
{

	mov edx, f   //ok
	mov edx, d  //error operand size conflict


Can someone show me the error of my ways??? 

Thanks
	
0
me8904 (18)
9/15/2004 9:09:52 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
1576 Views

Similar Articles

[PageSpeed] 48

"Si" <me@you.twang> wrote in message
news:sm1gk0l60ng23gilu9b68hkcqi3ub9horn@4ax.com...
>
>
> I'm trying to speed up a maths routine which consists of much
> iterative multiplication (and adding and subtraction of ) doubles.
>
> Now if I declare my doubles as floats
>
> float f
> double d
>
> _asm
> {
>
> mov edx, f   //ok
> mov edx, d  //error operand size conflict
>
>
> Can someone show me the error of my ways???
>
> Thanks
>



0
billt61 (145)
9/15/2004 11:08:19 AM
"Si" <me@you.twang> wrote in message
news:sm1gk0l60ng23gilu9b68hkcqi3ub9horn@4ax.com...
>
>
> I'm trying to speed up a maths routine which consists of much
> iterative multiplication (and adding and subtraction of ) doubles.
>
> Now if I declare my doubles as floats
>
> float f
> double d
>
> _asm
> {
>
> mov edx, f   //ok
> mov edx, d  //error operand size conflict
>
>
> Can someone show me the error of my ways???
>
> Thanks
>

You can use the dissambly window to view sample assembly language code:
53:       float a = 4.0;
0042513A   mov         dword ptr [ebp-14h],40800000h
54:       float b = 2.1942;
00425141   mov         dword ptr [ebp-18h],400C6DC6h
55:       float result = a * b;
00425148   fld         dword ptr [ebp-14h]
0042514B   fmul        dword ptr [ebp-18h]
0042514E   fstp        dword ptr [ebp-1Ch]
56:


The next question is.. why?  the generally accepted wisdom is to exhaust all
other optimization pathways before coding in assembly language.  It takes an
expert in assembly language to get improvements over what the compiler
produces.  If you feel you have no choice but to work with assembly
language, I would first spend a day searching the internet for combinations
of keywords like "assembly language" optimizations "floating point".  You
may want to purchase a book on the subject.


0
billt61 (145)
9/15/2004 11:12:06 AM
You have a couple of problems there.

1.    Registers like edx are only capable of integer operations.
2.    a double (64 bits, 8 bytes) won't fit into edx (32 bits).

You need to use the maths coprocessor, which the C/C++ code is already
doing, probably.

All the best
Julian N.

"Si" <me@you.twang> wrote in message
news:sm1gk0l60ng23gilu9b68hkcqi3ub9horn@4ax.com...
>
>
> I'm trying to speed up a maths routine which consists of much
> iterative multiplication (and adding and subtraction of ) doubles.
>
> Now if I declare my doubles as floats
>
> float f
> double d
>
> _asm
> {
>
> mov edx, f   //ok
> mov edx, d  //error operand size conflict
>
>
> Can someone show me the error of my ways???
>
> Thanks
>


0
9/15/2004 12:37:13 PM
fld qword ptr x
fstp qword ptr x
will transfer double values through the fp registers.
You can't manipulate them directly in the general CPU registers because, as
the other poster said, ecx et al are 32 bits wide.
In most practical cases there's very little reason to be using doubles
anyway.

"Si" <me@you.twang> wrote in message
news:sm1gk0l60ng23gilu9b68hkcqi3ub9horn@4ax.com...
>
>
> I'm trying to speed up a maths routine which consists of much
> iterative multiplication (and adding and subtraction of ) doubles.
>
> Now if I declare my doubles as floats
>
> float f
> double d
>
> _asm
> {
>
> mov edx, f   //ok
> mov edx, d  //error operand size conflict
>
>
> Can someone show me the error of my ways???
>
> Thanks
>


0
GuitarBill
9/15/2004 7:29:10 PM
Reply:

Similar Artilces:

Where Do Messages Go??
If there isn't a kink in my program and it's behaving as it should, I hope someone can answer my questions. Messages disappear. Example: I e-mailed a friend, who e-mailed me back. When I answered that response, I could find no trace of it in "sent mail" or anywhere else, and the item in my inbox maintained its appearance as unread mail. If I click "mark read" it disappears altogether. I've lost several messages this way. Also I seem to be unable to drag a message from one folder to another. It gets lost in the transporter, never to be seen agai...

Copy Inbound Messages Based on Content
Hello All, We are in the planning stages of an Exchange 2003 deployment for a client. They have a request/requirement that messages containing designated content/keywords in the Subject or Body be copied to another mailbox. As far as I know this cannot be done natively in Exchange, or can it?? Is there anyone who can point me to a potential 3rd party vendor that would offer this functionality? Can something like this be done at all? :-) Thank you in advance for your opinions and advice Paul You may be able to use your A/V - SPAM program to feret out and fwd what you are looking for...

Copying locked cells
I have a ss with formula in locked columns and the whole thing protected to stop the formula being altered. When the user comes to the last row in which there is a formula she needs to copy this last row and paste into however many rows she needs to complete her figures. However the protection is not allowing the paste function to work. I know this is probably quite basic but your forum has taught me that I know very little about Excel. Maybe you could give the user a macro that would copy the row above (including any formulas). If you want to try, start at David McRitch...

Copying conditional formats
I can't find anything in help about copying conditional formats to other cells - very frustrated. Help infers that the Format Painter can be used, but that copies all formatting (color, lines, etcetera). How do we just copy the conditional format and none of the other formatting attributes? Why can't we simply apply one of the existing conditional formatting rules from the conditional format menu? copy the cell | go to edit | paste special | format | ok On Nov 23, 3:55=A0pm, "Blue Max" <mailrich...@msn.com> wrote: > I can't find anything in help about ...

Double Click Field Conflicts
I am using the following double click event to open another form to the record that matches the product id to the item number. The problem is that the item number sometimes has characters that confuse the double click event. How do I preserve the event and isolate the item number so it doesn't hurt the code of the event? Private Sub PartNumber_DblClick(Cancel As Integer) If IsNull(Me.PartNumber) Then DoCmd.OpenForm "FRM_Inventory", , , , acFormAdd Else DoCmd.OpenForm "FRM_Inventory", , , "ItemNumber=" & Me.PartNumber End If End Sub &qu...

Where do the Archives Go?
I cannot find the information Outlook claims to have archived for me. Yes I know how to display the archived calendar, but it's blank. Any ideas? Thanks! I use XP, and Office 2007. "6Sigma 5s No Clue" <6Sigma5sNoClue@discussions.microsoft.com> wrote in message news:B239B721-DCF1-4337-947D-B325D4BF0E4A@microsoft.com... >I cannot find the information Outlook claims to have archived for me. Yes I > know how to display the archived calendar, but it's blank. Any ideas? > Thanks! > > I use XP, and Office 2007. Why do you think Outook is arch...

unable to register publisher '02
anyone have any idea why the registration window advises of an error and shuts down pub 2002 each time registration is attempted on win2000pro? happens on both internet reg and telephone reg options. Hi mark h (anonymous@discussions.microsoft.com), in the Microsoft� newsgroups you posted: || anyone have any idea why the registration window advises || of an error and shuts down pub 2002 each time registration || is attempted on win2000pro? happens on both internet reg || and telephone reg options. What is the error message? -- Brian Kvalheim Microsoft Office Publisher MVP Official Publ...

Copying Publisher Files
Hi If this problem is old - or better fixed elswhere please advise. I am using publisher 2000 for a local magazine. To backup I like to copy across the local network (Peer to Peer - no domain). If the file exceeds about 9 Mbytes the copy will fail. I can copy 50 + mytes between the same machines in any other format. Any advice welcome. Keith waterwy.1.webfoot@spamgourmet.com <waterwy.1.webfoot@spamgourmet.com> was very recently heard to utter: > I am using publisher 2000 for a local magazine. To backup I like to > copy across the local network (Peer to Peer - no domain). &g...

Multiple calendars, how to choose which one meetings go into
Hi I have 3 calendars setup in outlook XP , when someone sends me a meeting request how can i change which calendar the meeting goes into, at the moment they all go into what i guess is the default calendar which i want to change to a different one any ideas? thanks Chris You really can't change it. Outlook treats certain folders special. "Chris S" <fred@fred.com> wrote in message news:43cf7167$0$23294$db0fefd9@news.zen.co.uk... > Hi > > I have 3 calendars setup in outlook XP , when someone sends me a meeting > request how can i change which calend...

move/copy sheet function too small
When I use the move/copy sheet function the box that comes up is to small to read my entire file name. Is there any way to make this bo larger -- Message posted from http://www.ExcelForum.com Not that I know (irritating, huh?) "alabamabubba <" wrote: > > When I use the move/copy sheet function the box that comes up is too > small to read my entire file name. Is there any way to make this box > larger? > > --- > Message posted from http://www.ExcelForum.com/ -- Dave Peterson ec35720@msn.com ...

Can't open files by double clicking on them
Recently I have not been able to launch Excel files by double clicking on them, Excel launches but I receive an error that the file cannot be found. However, if I launch Excel first then open the file it works fine. Any ideas? Try the fixes here: http://www.jkp-ads.com/Articles/StartupProblems.asp -- Steve "Don Powell" <DonPowell@discussions.microsoft.com> wrote in message news:060E6E1C-D3A0-4AB3-BE26-E8D02713FCF3@microsoft.com... > Recently I have not been able to launch Excel files by double clicking on > them, Excel launches but I receive an error that the file...

Price/cost fields need to be able to go beyond 5 decimals.
When we receive product it comes in $ per metric ton, which we convert to $ per lb.. We sometimes receive product in millions of lbs. in one line item, when we convert from $/MT to lb./MT the limit of 5 decimal places in a currency field causes pretty lare rounding errors to occur in our extended cost. This causes our posted cost in GP to be different than what we actually pay our vendors. The ability to extend beyond 5 decimals in the currency field would solve the problem, but for now it is not possible in GP. ---------------- This post is a suggestion for Microsoft, and Microsof...

Printing Multiple Copies
Hi All, (Running Office 2003 on XP Pro workstations, SBS 2003 server). I've noticed that if you tell Excel to print multiple copies of a workbook, it sends the same document to the printer multiple times - i.e., for 3 copies of "MyWorkbook1.xls", I get 3 entries in the print queue for that same document. If I do the same in MS Word, it just sends the document once with a copy count of 3. This makes printing Excel documents frustratingly slow, as the printer goes through initialisation routines each time a new document is sent to it. Why did MS do it this way? Is it a ...

How do I get text to copy from one cell to another ?
Type = in the target cell. MouseClick the cell containing text. Pres Enter key -- Brian ----------------------------------------------------------------------- BrianB's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=5 View this thread: http://www.excelforum.com/showthread.php?threadid=27034 ...

Go to page
I have a long document and need to go the certain pages without having to scroll down. How do I go to a particular page? Thanks This is a multi-part message in MIME format. ------=_NextPart_000_0040_01CAEE07.56832EE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Press Ctrl+G to open the GoTo dialog, and enter the page number. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "richard" <rmk@wo...

Copy Text from Pictures Disabled permanently ?
This feature worked beautifully the first time. Since then, no luck. I cannot uncheck the disable box in " Make Text in Picture " searchable. Do you have Service Pack 2 for Office 2007 installed? (http://www.microsoft.com/downloads/details.aspx?FamilyId=B444BF18-79EA-46C6-8A81-9DB49B4AB6E5&displaylang=en) -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.html Author: The Lawyer's Guide to Microsoft Outlook 2007: http://tinyurl.com/ol4law-amazon "Steve8rox" <Steve8...

copying charts in excel 2007
i create a chart by copying another one (i.e. Chart 2) and chage only Y-series. next, both charts are copied and pasted special (as link to excel) into powerpoint, but when i update both links, something strange happens - copied chart (in powerpoint) becomes first chart. i noticed that copied chart in excel is also named Chart 2. wtf? i compared situation to copying charts in excel 2003 and worked normal - how can i fix this in 2007. rgs ...

Here we go again
Well, once again CashEdge is not connecting/syncing with Money and MSN Money. I guess I won't run right out to buy Money 2007. Even if the software were an improvement over M06, it cannot be any better than the weakest link in the sync chain. A known problem, David -- and not unique to the version of Money. Look at http://moneycentral.msn.com/common/networkstatus.asp -- Michael Gordon MVP "David Haynes" <nospam@nowhere.com> wrote in message news:eNopg0UzGHA.1252@TK2MSFTNGP04.phx.gbl... > Well, once again CashEdge is not connecting/syncing with Money and MSN ...

Copy ranges into email
Hi, How do i add more than one item to the body of a outlook mail using vba. I am using named range to select the items. i want to add Text, the leave two lines HTMLBody then leave two lines and add another HTMLBody and leace two lines and add Text I have a function that does the RangetoHTML after passing myRange to it. I am getting confused here. With OutMail .To = s .CC = "SH-DI-List" .BCC = "" .Subject = n & " - Trades in Pending Queue in SW " & Format(Now, "dd-Mmm-yyyy") & _ "...

Not all emails going out??
For the last week or so, send few, my emails have not been going out, or not going out to all parties I access from my address book. Just tested by sending one to myself...went fine. Sent second to a single party and cc myself. Did not receive my cc in outlook, but it did show up in my iphone. Tried a third to a group of people...through a single address book contact, and nothing happened. I am strictkly novice, but have not had this problem before. Any ideas??? -- Thanx! Wilson Kobel;110315 Wrote: > For the last week or so, send few, my emails have not been going...

If Public Folders are going away..
What would be the best/simplest solution for a user requesting a group calendar to be used within Outlook. Ordinarily i would advise them to create a calendar within the Public Folders hierarchy and then assign access rights to anyone who needs it. I understand though that Public Folders will be history with the next release of Exchange. The only thing i can think of is to create a new mailbox, share the calendar, and then walk users through adding it to their Outlook folder list. I suspect this isn't the best way though. Any recommendations out there? All clients are running ...

Multiple Contacts Folders: can I sync them so I can go back to use
I got the bright idea of making 2 more Contacts folders so that I could be better organized. I decided not to use the old Contacts folder and instead was putting changes in the two news one, which would be used for different purposes. The reason I came up with this is so that I could get around using categories (temporarily) because a lot of them disappeared for some unknown reason. Any, now the problem is that in order for me to set up Contacts to be tracked in the Journal, I have to use the Contacts folder I initially had (the default folder), and Windows Mobile (for my Motorola Q)...

Pivot Table
Hi all. I have a question that seems like it would have an easy solution, but several hours of searching through the message boards hasn't solved it yet - so here it is: I have a pivot table which is updated monthly from a database. I use this pivot table to create a report based on the totals and subtotals. One of the subtotals is based on a product ID, from which there are thousands of possible options. The table itself typically looks like: A B C D Group Type ID Count MC D 123 12 MC D 124 15 MC N 167 2 MC N 198 9 SW D 109 3 SW N 108 5 SW N 105 9 So that the pivot table looks lik...

If stmt
I would like to create an 'if' statement which includes the condition if the statement is true, then 'go to' a new location. Is this possible??? How about a worksheet function: =IF(A1="asdf",HYPERLINK("#"&CELL("address",'sheet 1'!A4),"go1"), HYPERLINK("#"&CELL("address",'sheet 2'!C9),"go2")) (One cell) (I used two sheet names with spaces--just to show the apostrophes.) You may want to modify the cell's style to be hyperlink. (Format|Cells|Style) MM wrote: >...

Computer does not go into hibernation
In Power Options I enabled hibernation and asked the computer to go into = hibernation after 30 minutes. Well, it doesn't.=20 The complete settings are as follows: Turn off monitor: after 5 min. Turn off hard disks: after 15 minutes. System standby: after 25 minutes. System hibernates: after 30 minutes. What may be the reason of the computer not going into hibernation? TIA Humpty Usually something running in the background. Are you running a virus program that starts when the computer is idle? "Humpty Dumpty" <sorry@antispam.net> wrote in messa...