Newbie Help Needed: Do Multiplication from 1 to 12 on user input

Started by FreChel, October 03, 2010, 05:10:27 PM

Previous topic - Next topic

FreChel

I have a class assignment to write an algorithm that takes a number input into an edit control by the user and then multiplies that input starting with 1 all the way up to 12 and show the result of each multiplication in a messagebox. The instructor said we must use the FPU for this asignment. I figured out how to take the user input and convert it for use in the FPU. In the code below I just show a messagebox to verify I got the data from the edit control correctly. What I cannot figure out is how to multiply the user input by 1, show the answer, then multiply the same user input by 2, show the answer... etc using the FPU.  All hints and advice will be greatly appreciated.

;Main program module
.Data?
hEdit1 DWord ? ;Edit control in which user types input data.

.Code

Window1Procedure Proc Private hWnd:HWND, uMsg:ULONG, wParam:WPARAM, lParam:LPARAM
Local szBuffer1[20]:Byte


Select uMsg,Eax
   Case WM_COMMAND
   Select wParam,Eax
      Case IDC_WINDOW1_BUTTON1
         Invoke GetWindowText,hEdit1,Addr szBuffer1,3
            Invoke Value,Addr szBuffer1
               Mov Edx,Eax

      Select Edx,Edx
      Case 1
      DoMultiply 1

      Case 2
      DoMultiply 2

      Case 3
      DoMultiply 3
      
      Case 4
      DoMultiply 4

      EndSw

   EndSw


   Case WM_CREATE

   Mov hStatic1,FUNC(GetWindowItem,App.Main,IDC_WINDOW1_STATIC1)
   Mov hEdit1,FUNC(GetWindowItem,App.Main,IDC_WINDOW1_EDIT1)

   Case WM_CLOSE
      Invoke IsModal, hWnd
      .If Eax
         Invoke EndModal, hWnd, IDCANCEL
         Return TRUE
      .EndIf
   EndSw
   Return FALSE
Window1Procedure EndP

--------------------------------------------------------------------------------

;Macro program module

.Data?
r10Multiplicand Real10 ?
r10Multiplier Real10 ?
Product DWord ?

.Data
multiplicandBuffer Byte 24 Dup(?)
outBuffer Byte 24 Dup(?)
multiplierBuffer Byte 24 Dup(?)


.Code


DoMultiply Macro Number
Local lcnt
lcnt = Number

.Code
Invoke lstrcpy,Addr multiplierBuffer,CTXT("1.0")
Invoke FpuAtoFL,Addr multiplierBuffer,Addr r10Multiplier,DEST_MEM

Invoke dwtoa,Number,Addr multiplicandBuffer
Invoke lstrcat,Addr multiplicandBuffer,CTXT(".0")
Invoke FpuAtoFL,Addr multiplicandBuffer,Addr r10Multiplicand,DEST_MEM

   Repeat lcnt
   Finit
      Fld r10Multiplier      ;load r10Multiplier
      Fld r10Multiplicand   ;load r10Multiplicand
      Fmul            ;compute r10Multiplicand * r10Multiplier
      Fst Product         ;store away resuly in product

      Invoke FpuFLtoA, Addr Product, 0, Addr outBuffer, SRC1_FPU Or SRC2_DIMM

      Invoke MessageBox,NULL,CTXT("Product"),Addr outBuffer,MB_OK

   EndM

EndM