Author Topic: Confused by some ASM in the MiniFMod source  (Read 4147 times)

0 Members and 2 Guests are viewing this topic.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Confused by some ASM in the MiniFMod source
« on: February 04, 2012 »
I've been playing around with the MiniFMod source and I'm confused by the line highlighted below.

FSOUND_SAMPLE is a struct with a 'length' property. I'm trying to work out how the line below actually works. I would expect a reference to an instance of FSOUND_SAMPLE to be there as that doesn't look right to me at all. Am I missing something?

If I try to compile the code as C++ (instead of C), I get the following error against that line:

Error   8   error C2420: 'FSOUND_SAMPLE' : illegal symbol in second operand


Thanks

Raizor

Snippet:

   CalculateLoopCount:
      mov      mix_count, eax
      mov      esi, [ecx].mixpos
      mov      ebp, FSOUND_OUTPUTBUFF_END   
      mov      mix_endflag, ebp         // set a flag to say mixing will end when end of output buffer is reached

      cmp      [ecx].speeddir, FSOUND_MIXDIR_FORWARDS
      jne      samplesleftbackwards

      // work out how many samples left from mixpos to loop end   
      mov      edx, [ebx].loopstart
      add      edx, [ebx].looplen
        cmp     esi, edx
        jle     subtractmixpos
        mov     edx, [ebx+FSOUND_SAMPLE.length]
raizor

Challenge Trophies Won:

Offline Stonemonkey

  • Pentium
  • *****
  • Posts: 1315
  • Karma: 96
    • View Profile
Re: Confused by some ASM in the MiniFMod source
« Reply #1 on: February 04, 2012 »
I don't know but I would hazard a guess that it's the offset of the field and in c++ maybe something like:

offsetof(FSOUND_SAMPLE,length)

giving

mov edx,[ebx+offsetof(FSOUND_SAMPLE,length)]

That really is just a guess though.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Confused by some ASM in the MiniFMod source
« Reply #2 on: February 04, 2012 »
Thanks Stonemonkey. From what I've managed to find so far, I think you may well be right :) K++
raizor

Challenge Trophies Won:

Offline energy

  • Amiga 1200
  • ****
  • Posts: 280
  • Karma: 25
    • View Profile
Re: Confused by some ASM in the MiniFMod source
« Reply #3 on: February 04, 2012 »
Quote
mov     edx, [ebx+FSOUND_SAMPLE.length]

ebx should be a pointer to a structure of FSOUND_SAMPLE
the whole line  mov  edx, [ebx+FSOUND_SAMPLE.length]
transfers the data from the FSOUND_SAMPLE.lenght structure variable to edx.

small example:

Font2D struct                  <-Structure Font2D
  FontList dd ?
  NrChars dd ?
Font2D ends

.data?
BigFont Font2D <?>   <-Declare a Structurevariable of Font2D

.code

mov esi,offset BigFont    <- mov the startadress of BigFont into esi-Register
mov eax,dword ptr[esi+Font2D.FontList]   <- Now yu have access to structure variable:
                                                                       startadress of big font + offset from the
                                                                       structure Font2D.FontList [Byte 0]
                                                                       This line transfers the data from
                                                                       BigFont.FontList to eax.

mov ebx,dword ptr[esi+Font2D.NrChars]  <- Now yu have access to structure variable:
                                                                       startadress of big font + offset from the
                                                                       structure Font2D.NrChars[Byte 4]
                                                                       This line transfers the data from
                                                                       BigFont.NrChars to ebx.


           







coding: jwasm,masm
hobby: www.scd2003.de

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Confused by some ASM in the MiniFMod source
« Reply #4 on: February 04, 2012 »
Wonderful Energy, thanks very much! K++
raizor

Challenge Trophies Won: