News:

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

Filling a struct with float values

Started by normcook, May 18, 2009, 12:23:12 PM

Previous topic - Next topic

normcook

Hi all, long time lurker, first time poster.  Trying to fill in the struct shown below (from the .inc file)

BASS_DX8_PARAMEQ struct
  fCenter    float ?
  fBandwidth float ?
  fGain      float ?
BASS_DX8_PARAMEQ ends

I started with code like this
LOCAL pEQ:BASS_DX8_PARAMEQ
mov pEQ.fCenter, <someval>
and likewise for the other two params.

It assembles fine but the ensuing invoke fails, with an error indicating invalid
parameters in the struct.  I think I need some way to get
float values into the structure before calling the invoke.

Any ideas?

ToutEnMasm

Float must be translate  before you can load them anywhere
Quote
sample REAL4  1.0
DeuxPI REAL8  6.283185

This two works,because ml translate it.
There is some functions in masm32 who translate ascii to float

Some macros can help you doing this

Quote
   RETR4 MACRO src
      local reel
      .const
      reel REAL4 src
      .code
      mov eax,reel
      EXITM <eax>
   ENDM

raymond

It looks like your struct requires 32-bit floats, i.e. REAL4. You cannot specify a float as an ascii string in assembly , except when initializing variables. Once a float is in float format in memory or on the FPU (either initialized or from other floating point computations), only then can you move it around. For example:

.data
   float1 dd 1.2345

.code
   push float1
   pop  pEQ.fCenter
   fld1
   fdiv float1
   fstp pEQ.fGain

When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

Farabi

You can also put the float by doing something like this.

Quote
fld value
fstp BASS_DX8_PARAME.fCenter
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Biterider

Hi
I have 2 macros i frequently use in my projects


; Macro:     fpush
; Purpose:   Pushes a series of real4 values diretly onto stack.
; Arguments: real4 values.

fpush macro r4Values:vararg
    ??@ArgList textequ $ArgRev(r4Values)
%   for ??@Arg, <??@ArgList>
      db 68h                            ;;push opcode
      real4 ??@Arg                      ;;push argument = real4
    endm
endm



; Macro:     fmov
; Purpose:   Performs a mov with a real4 value.
; Arguments: Arg1: move destination
;            Arg2: real4 value.

fmov macro Destination:req, r4Value:req
    mov Destination, 0FFFFFFFFh                ;;Compile this
    org $-4                                    ;;Replace 0FFFFFFFFh with
    real4 r4Value                              ;;  the real4 value
endm


Biterider