flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Problem constucting list within 'repeat' loop

Author
Thread Post new topic Reply to topic
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld
Suppose we have such BITMAP macro:
Code:
; size = 14 bytes
struc BITMAPFILEHEADER {
  .bfType      dw ? ; WORD
  .bfSize      dd ? ; DWORD
  .bfReserved1 dw ? ; WORD
  .bfReserved2 dw ? ; WORD
  .bfOffBits   dd ? ; DWORD
}

; size = 40 bytes
struc BITMAPINFOHEADER {
  .biSize          dd ? ; DWORD
  .biWidth         dd ? ; LONG
  .biHeight        dd ? ; LONG
  .biPlanes        dw ? ; WORD
  .biBitCount      dw ? ; WORD
  .biCompression   dd ? ; DWORD
  .biSizeImage     dd ? ; DWORD
  .biXPelsPerMeter dd ? ; LONG
  .biYPelsPerMeter dd ? ; LONG
  .biClrUsed       dd ? ; DWORD
  .biClrImportant  dd ? ; DWORD
}

struc _bmp {
  .h BITMAPFILEHEADER
  .i BITMAPINFOHEADER
}
virtual at 0
  _bmp _bmp
end virtual

macro BITMAP _name*,_fname*
{
  local list,w,h,a,r,g,b
  list equ
  virtual at 0
    file _fname
    load w dword from _bmp.i.biWidth
    load h dword from _bmp.i.biHeight
    a=54
    repeat h
      repeat w
        load r from a+0
        load g from a+1
        load b from a+2
        match any,list \{ list equ list,r,g,b \}
        match    ,list \{ list equ r,g,b \}
        a=a+3
      end repeat
      a=a+(w mod 4)
    end repeat
  end virtual
  dw w,h
  match _list,list \{ db _list \}
}    

Its purpose is to extract color data from 24-bit BMP file. It's not finished yet (scanlines should be looped in down-up order), but even now it doesn't work... The idea is to construct a list of colors' bytes, like 'list equ 1,5,63,6,54,231,23,42,255' (for 1x3 bitmap) etc.
What is wrong here? Looks like standard example won't work here Sad Maybe even some other way to do this?
Post 06 Jan 2006, 23:20
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
You are mixing preprocessor with assembler here.
Shall I point another person to section 2.3.7. Hmmm, forgive me if I'm too lazy to say something new.
Post 06 Jan 2006, 23:51
View user's profile Send private message Visit poster's website Reply with quote
mike.dld



Joined: 03 Oct 2003
Posts: 235
Location: Belarus, Minsk
mike.dld
I know I'm doing sth wrong, but... ok, I'll read it again...
Don't know if I may point you to that, but if so many people ask the same (or similar) questions then maybe there's sth with documentation...
Post 07 Jan 2006, 00:03
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
Yes, there's sth with it - it was quite extended recently, but for people that read it before it may be harder to find out what's new and read it.
Post 07 Jan 2006, 00:07
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.