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
1678 Views

Similar Articles

[PageSpeed] 7

"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:

Copying Excel Screen Shots Into PowerPoint
I am trying to copy screen shots from Excel into PowerPoint and the only paste special options I am given are bitmap and device independent bitmap. Both of these options produce a fuzzy graphic. Is there anyway to copy a screen shot into PowerPoint and be able to paste special as a picture Thanks. Hi Barbara Have you try to select the cells and when you are holding down the Shift key use Edit>Copy Picture in the menubar -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Barbara" <anonymous@discussions.microsoft.com> wrote in message news:8CE...

Go to specific line in numbered list?
Hey all, I have a question that will hopefully save me a lot of time! I'm working on my dissertation, and my data (transcription of speech) is formatted in a very long numbered list. The thing is that there are often more than one actual lines per list item, like so: 1) ____________________________________ _______________________________________ ____________ 2) ____________________________________ ______________________________________ etc. What I have been trying to figure out is a way to jump to a specific *list number*, rather than actual line number. I have a lis...

Register my own messages
I'm trying to understand how to work with my own defined messages. I've readed the essays from http://www.flounder.com/mvp_tips.htm which I'm sure is very complet, is too technical for my level. I found an example at http://www.codersource.net/mfc_user_event.html but doesn't seems to work... I'm getting this error: "int CODERSOURCEMSG" (?CODERSOURCEMSG@@3HA) already defined in PostMessage01.obj Debug/PostMessage01.exe : fatal error LNK1169: one or more multiply defined symbols found I defined int CODERSOURCEMSG in a header file appart. I don't understand why...

Copy Word Doc Bookmarks from One Document to another (VB.net)
I am try to copy bookmark from one word doc to another, find all the bookmark and select them etc. I can create the bookmark in the second word doc, with the correct name. The problem is set the location of the bookmark Any help here would be great WrdDoc is the destination doc WrdTemplate is the source doc ----------------------------------------- If WrdDoc.Bookmarks.Count = 0 Then '# Set Template Document Path Dim strTemplatePath As String = "C:\Temp\test.doc" '# Open Template WrdTemplate...

Unknown error when going offline in SFO
Hi, I had failed going offline in my Outlook after this following scenario: - Click the 'Go Offline' button on CRM toolbar in Outlook. - The 'Offline Configuration' window show, then click the Ok button - The 'downloading status' progress window show. After the progress, My outlook still in online mode(It was still 'Go Offline' button in my CRM toolbar) - Click the 'Go Offline' button again, got the same 'Offline Configuration' window & after that the same 'downloading status' progress window. - After the progress, the 'Go ...

Downloaded transactions balance not equal to registers transaction balance
Using MS Money 2003 and online services to download transactions from my credit card account. I just downloaded the latest transactions from my account today and though 1 particular transaction has posted to the online account, Money didn't download it and put it in the register for my credit card account. It DID, however, change the balance to reflect the correct amount under the "Downloaded" info section in the upper left of the credit card register screen. I have run salvage with no luck?! In microsoft.public.money, Bill Unger wrote: >Using MS Money 2003 and online s...

Let's go
Let's go BBQ ...

Copy same formula to all worksheets in a workbook
Hello guys! I have a table with some formulas saved in workbook "A". Once a month, I receive workbook "B" and it has several worksheets in it (sometimes almost a thousand). I need to copy the table with formulas from workbook "A" and paste it into every-single-worksheet in workbook "B". In the same cell address (C25 for example). As of today, I copy the table and then I go to each worksheet to paste it but I am pretty sure there is a way to do it with a macro or a instruction and save me all that pasting over and over and over again... :S...

shortcut key to go to formula bar
I have looked without success for a shortcut key that will take me from the worksheet area to the formula bar, and vice versa, without having to reach to the mouse and click in the bar. Does such a shortcut(s) exist? Thanks Tonso McCrae F2 will put you into editing mode and if you have edit directly in cell checked under tools>options>edit you will stay in the cell, but if you uncheck it, then it will put you in the formula bar -- Regards, Peo Sjoblom (No private emails please, for everyone's benefit keep the discussion in the newsgroup/forum) "Tonso" <csa@gc...

copying/pasting
when i try to copy paste from one workbook to another, my formatting i not copied, only the data gets copied, how do i copy paste along wit the formattin -- Message posted from http://www.ExcelForum.com try edit>paste special -- Don Guillett SalesAid Software donaldb@281.com "praptisahni >" <<praptisahni.16tebk@excelforum-nospam.com> wrote in message news:praptisahni.16tebk@excelforum-nospam.com... > when i try to copy paste from one workbook to another, my formatting is > not copied, only the data gets copied, how do i copy paste along with > the formatt...

Copy formulas without data.
I have a complex spreadsheet that has many formulas and much data. It was not well designed, but I inherited it. Now I have to start the new fiscal year and I want to delete all the data, but leave the formulas, headers and such intact. Is there a way to do this? Deleting cell by cell is going to be a big project. ---Mike You should be able to hit Edit-->Go to-->Special-->Constants. Then hit your delete key. ******************* ~Anne Troy www.OfficeArticles.com www.MyExpertsOnline.com "Praising Jesus" <1611kjb@earthlink.net> wrote in message news:elOCVp$gFH...

How to copy custom number formats
Hello All I have a custom number format for a Excel Cell A1 which is #,##0.00 "CAD" and in A1 I now have a value 1000 CAD. I have assigned cell B1 as =A1 but an external application when the report is run populated now cell A1 as 20000 MXP and now my cell B1 says 20000 CAD and not 20000 MXP and when I check the format for B1 it still as the format as #,##0.00 "CAD" whereas now the format of my cell A1 is #,##0.00 "MXP" appears only the value and not the format is being copied. Can any of you suggest a workaround to resolve this problem. Many thanks Simon ...

Copying desktop icon info
I'm creating a custom 'Office like' toolbar and using IShellLink to retrieve information about a desktop link. I have an icon for (Microsoft Frontpage 2002) on the desktop. When I copy this icon IShellLink returns a path to the c:\windows\installer\{901.....}\misc.exe which does not launch MS FrontPage (does not do anythng visible to me).. A call to IShellLink->GetArguments() does not return any arguments that might be passed to misc.exe. All of the other icons I copy are working. Anyone have an idea of what is different about this icon? Thanks "mike" <no...

AutoFilters
I have a spreadsheet that I distribute to various people requesting updates. The person receiving the file clicks on the autofilter, selects their name, and updates the spreadsheet. When I receive the updated spreadsheet I would like to be able to copy from the updated spreadsheet and paste into my master spreadsheet but when I do this Excel pastes the information to the unseen rows. Is there a way to copy and paste from the updated spreadsheet to my master spreadsheet? F5 then special... then visible cells only copy and paste >-----Original Message----- >I have a spreadsheet th...

Copy an Excel page
Now that I've created page one on sheet one, and I want to have five duplicate pages, how do I copy page one multiple times? Simple way is to copy and then paste, paste, paste. Do you mean page 1 of worksheet 1 of workbook 1? where page is a part of a worksheet. "Mark" <anonymous@discussions.microsoft.com> wrote in message news:04b101c398e4$1c495800$a301280a@phx.gbl... > Now that I've created page one on sheet one, and I want > to have five duplicate pages, how do I copy page one > multiple times? Hi, Right click the tab, select move or copy, check the c...

two copies of spreadsheet opening
I have one large file with multiple worksheets and every time I open it, Excel opens two copies of it. This can get confusing if I minimize it and come back to it after a while, because the changes only show up on one of them until it is saved. Do you know how to get rid of the duplicate copy of the file? Hi Barbara You have two views of the same workbook See window-New Window in the menubar Close one of the windows by clicking on the X in the Top right corner and save the file http://www.contextures.com/xlfaqApp.html#TwoWindows This page will show you how to do it -- Regards Ron ...

Conditional copy cells from one excel file into current
Hello All, Does a macro (or function or ??) exist to conditionally copy value from a stored spreadsheet into the current (open) spreadsheet? Here's the scenario: Stored spreadsheet is two columnsof text (~200 rows) : Think explici question in column one, then the correct answer in column two of th same row. Then my current (open) spreadsheet has SOME of the same questions i column one. I would like to invoke a [macro?] that, in pseudo code, does somethin similar to the following: for each row (question in column 1) of the current spreadsheet Search in column 1 of *stored* spreadshee...

Copy Charts
I know this is simple, but I cannot remember how. I want to copy a chart into another worksheet, but do not want to keep the links, just the picture and data as it is. Select the chart, hold Shift while clicking on the Edit menu, choose Copy Picture, and use the On Screen and Picture options. Go to the place you want the chart image to appear, and use plain old Paste (Ctrl+V). - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "archsmooth" <archsmooth@discussions.microsoft.com> ...

Problem with autofill incrementing characters when copying
We are trying to copy(drag it horizontally) the following formula so that underlined characters ("C") progress in the alphabetical order. =SUM(INDIRECT("C"& A1)):INDIRECT("C"& A5))) /\ /\ || || We would like the cell in the next position to the right to have "D"s in it. =SUM(INDIRECT("D"& 1)):INDIRECT("D"& 1))) Is there any way to force Excel increment characters inside of INDIRECT function in alphbetical order? Thanks a lot! Leonid, Since the "C"...

copy results of advanced filter to a dynamic range - if only want certain records from the results
Using advanced filter in visual basic I did the following: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Row = 13 And Target.Column = 1 Then 'calculate criteria cell in case calculation mode is manual Worksheets("Print Parts List").Range("Q2").Calculate Worksheets("Print Parts List").Range("PartsDatabase") _ .AdvancedFilter Action:=xlFilterCopy, _ CriteriaRange:=Sheets("Print Parts List").Range("Q1:Q2"), _ CopyToRange:=Range("i8:n8"), Unique:=False End If End Sub .... now the results...

Printing Check Register
Is there anyway to printout the check register in Money 2001? What about later versions? In microsoft.public.money, OhMarty wrote: >Is there anyway to printout the check register in Money 2001? What about >later versions? > 2001 and later versions allow File->Print from the register. You can also Customize the Transaction report to your liking. There you can select the date range and other factors, which may be advantageous. I have Money 2001, but there is no File->Print from the register. Seems like I can only print reports. I would like to print out the register just a...

Question--Payment and Deposit order in advance register
Hi Everyone: I just purchased MS Money 2006 and have a question on the manner transactions are posted in the advanced register. I noticed that when both payment and deposit transaction are entered on a single date, the transactions are sorted so that payments are listed first and deposits are listed last. This means that all of the previous payment transactions for that date are drawn from the account without the benefit of the deposit. So payments made against the deposit make the account appear to have insufficient funds for those transactions. Is there a setting to disable the auto...

Copy worksheets and formats
Hi, I have a worksheet (budget) set up as 31 columns representing days of a month. I also have a worksheet designated as yearly, 12 columns for each month. The first worksheet, Jan, totals numerous rows and sends the data to the Jan column of the monthly WS. I need to copy the Jan worksheet in a way it will change the Jan! to Feb!, then Mar!, etc. If I copy it as is the data will be the same as the month of Jan. Hope you can understand this. I can't ;+) Ken More than one way, but an easy way if each month formulas are the same is to copy Jan sheet, and paste them into the Feb a...

Copy Company Utility for Analytical Accounting
Copy company utility does not provide the option to copy the master records of Analytical Accounting module. Is there any othere utility? Salman, Install Dynamics GP SDK and locate "AnalyticalAccountingTableDesignDocument.doc" document, it has the descriptions for all the setup tables in AA module. Create DTS package to copy the needed tables from the first company to the new one. Regards, -- Mohammad R. Daoud MVP, MCP, MCBMSP, MCTS, MCBMSS Mob: +962 - 79 -999 65 85 Great Package For Business Solutions daoudm@greatpbs.com http://www.greatpbs.com http://moh...

Copying the column heading into all non-empty cells #3
Gord you're a genius! Thanks so much - that works a treat! Sorry I didn't get back to yo last night - I'm in London and it was past my bedtime. The reason I'm copying the headings into the rows by the way, is that have a database which I want users to be able to search, and it's easie if I just have have one column listing all the Amenities for each hotel rather than 120. Incidentally, my next move is to now merge all the cells in each ro into one, with the amenities separated by spaces. I've just downloade a "Merge Cell Wizard", which has accomplished th...