News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

error A2006: undefined symbol : FpuDiv

Started by sjums, January 21, 2012, 05:57:25 PM

Previous topic - Next topic

sjums

Good evening Masm forum!

So far I've managed to find an answer for everything i needed in here or on SO.

Now, I get these errors and i can't really see how to fix'em  :eek

I'm trying, in the nxtRnd proc, to convert this: http://www.codeproject.com/Articles/25172/Simple-Random-Number-Generation into assembly

I use fpu because I have to divide 1 by (32^2 + 2), which gives me a 0,00097 something

My two problems are:


  • Where can i store a number as (32^2 + 2) aka 4294967298
  • Why does i get an error when making saying: error A2006: undefined symbol : FpuDiv (same for FpuMul)

I've attached the code so you can see what I'm doing  :U

And please! Be gentle, I'm new  :boohoo:


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include \masm32\include\masm32rt.inc
    ;include \masm32\include\fpu.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\fpu.lib
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

comment * -----------------------------------------------------
                     Build this console app with
                  "MAKEIT.BAT" on the PROJECT menu.
        ----------------------------------------------------- *

    .data?
       
    .data
       
    .code

nxtRnd PROTO ;Gets next random number
mpl PROTO, :DWORD, :DWORD ;Multiplies two numbers
pow PROTO, :DWORD, :DWORD ;Puts a number in the power of another

start:
   
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    CALL main
    inkey
    exit

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

main proc

    invoke nxtRnd ;ret to ebx
    ;print str$(ebx),10,0
   
    ret

main endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

nxtRnd PROC

    local m_z :DWORD
    local m_z1 :DWORD
   
    local m_w :DWORD
    local m_w1 :DWORD
   
    local m_r :DWORD
   
    local time :SYSTEMTIME

    invoke Sleep,20
    invoke GetLocalTime,addr time
    xor eax,eax
    xor ebx,ebx
    mov ax,time.wMilliseconds
    mov bx,time.wMinute
    sal eax,19
    sal ebx,22

    mov m_z,eax
    mov m_w,ebx
   
    mov m_z1,eax
    mov m_w1,ebx

    sar m_z,16 ;shift right 16 bits
    and m_z1,65535
    invoke mpl, m_z1,36969   
    mov m_z1,edx
    mov ebx,m_z
    add ebx,m_z1
    mov m_z,ebx
    ; m_z oven over
   
    sar m_w,16
    and m_w1,65535
    invoke mpl, m_w1, 18000
    mov m_w1,edx
    mov ebx,m_w
    add ebx,m_w1
    mov m_w1,ebx
    ; m_w oven over
   
    sal m_z,16
    mov ebx,m_z
    add ebx,m_w
    ;læg m_z og m_w sammen
    ;bliver gemt i ebx
   
    inc ebx
    mov eax,1
    mov ecx,4294967298 ;(2^32 + 2)...f*ck

    invoke FpuDiv,eax,ecx,addr m_r,SRC1_DIMM or SRC2_DIMM
    invoke FpuMul,ebx,addr m_r,addr m_r,SRC1_DIMM or SRC2_REAL
^... Bad things start to happend in the above three lines!
    mov ebx,m_r
   
    ret
   
nxtRnd endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

mpl PROC num:DWORD, times:DWORD

....

mpl endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

pow PROC num:DWORD, power:DWORD

...

pow endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

end start

jj2007

Quote from: sjums on January 21, 2012, 05:57:25 PM
And please! Be gentle, I'm new  :boohoo:
:toothy

Quote
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include \masm32\include\masm32rt.inc
    :naughty:
    ;include \masm32\include\fpu.inc

    inc ebx
    mov edx,1
    mov ecx, 2 ;4294967298 ;(2^32 + 2)...f*ck
    invoke FpuDiv,edx,ecx,addr m_r,SRC1_DIMM or SRC2_DIMM

> Where can i store a number as (32^2 + 2) aka 4294967298
On the FPU:

;    mov ecx, 2 ;4294967298 ;(2^32 + 2)...f*ck
.data
MyFatNumber dq 4294967298
.code
  fild MyFatNumber
    invoke FpuDiv,edx,0,addr m_r,SRC1_DIMM or SRC2_FPU

Should work now ;-)

sjums

#2
ohh dear god how could i miss that semi colon  :red

the Visual Studio debugger says that MyFatNum is a __int64 with a value of 4 after the division (which should've been 0,000something)


EDIT:

I'm figuring it out :D

Super many thanks for the reply :)