flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Strtbl and struct macros

Author
Thread Post new topic Reply to topic
Vortex



Joined: 17 Jun 2003
Posts: 335
Vortex
Hi friends,

Can somebody explain the construction of these two macros with some examples? Thanks.

Code:
    macro strtbl name,[string]
     {
      common
        label name dword
      forward
        local label
        dd label
      forward
        label db string,0
     }
    


Code:
macro struct name
 { virtual at 0
   name name
   sizeof.#name = $ - name
   name equ sizeof.#name
   end virtual }
    

_________________
Code it... That's all...
Post 09 Nov 2003, 14:47
View user's profile Send private message Visit poster's website Reply with quote
kaafe



Joined: 15 Oct 2003
Posts: 18
kaafe
i suppose first one creates a string table Smile

from "win32asmboard",
Quote:

I posted a macro to do this on the book page. You can create an array of items like this:

code:

cbitems db "item1",0,"item2",0,"item3",0,0 <- note the extra zero at the end




use this macro to add the items:

code:

CB_SetContent MACRO hControl, pList
push edi
push esi
mov esi,pList
push esi
@@:
add esi,1
mov al,[esi]
cmp al,0
jne @B
add esi,1
pop edi
invoke SendMessage,hControl,CB_ADDSTRING,0,edi
mov cl,[esi]
cmp cl,0
je @F
push esi
jmp @B
@@:
pop esi
pop edi
ENDM




In your program just include this line

code:

CB_SetContent hCombobox,OFFSET cbitems
when i saw this macro imagined such a table of string. Maybe you may test. Only an opinion Sad (maybe you were)

good luck
Post 10 Nov 2003, 02:02
View user's profile Send private message Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 492
Location: Norway
Tommy
The StrTbl-macro will as you said, kaafe, generate a string table.
Code:
macro strtbl name,[string] 
{ 
  common 
    label name dword 
  forward 
    local label 
    dd label 
  forward 
    label db string,0 
}    
The two first lines will define a label with the name <name>. Onwards, the three next lines will make a list of pointers to the strings. And at last the to last lines will output the strings... By example, it works like this:
Code:
strtbl test_list,"string1","string2","string3"    
will be:
Code:
test_list:
  dd pointer_to_string1
  dd pointer_to_string2
  dd pointer_to_string3
  db "string1",0
  db "string2",0
  db "string3",0    
The other macro, struct, will make a symbol sizeof.<name> where the value equals the size of the structure given by <name>.
Code:
macro struct name 
{ virtual at 0 
   name name 
   sizeof.#name = $ - name 
   name equ sizeof.#name 
   end virtual }     
Example:
Code:
struc a_struc {
   .a dd ?
   .b db ?
   .c dw ?
}
struct a_struc    
will generate the symbol "sizeof.a_struc" with the value 7 which is the size of the structure (in bytes of course).

Do you understand?

Regards,
Tommy
Post 10 Nov 2003, 07:24
View user's profile Send private message Visit poster's website Reply with quote
Guest





Guest
Hi friends,

Thanks for your help.

What I don't understand is that how can the same local "label" can be defined 3 or 5 times?(depending on the parameter number)
Post 10 Nov 2003, 10:30
Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
Anonymous wrote:
What I don't understand is that how can the same local "label" can be defined 3 or 5 times?(depending on the parameter number)

please, rtfm (fasm.txt or fasm.pdf), there you find that local variables gett a uniqe name for every forwrard/reverse.

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 10 Nov 2003, 17:15
View user's profile Send private message Visit poster's website Reply with quote
Guest





Guest
Ok thank you,

But i tested this macro in "dialog.asm"(example in fasm),

strtbl stringTb, "one","two","tree"

thats all, dialog compiled w/o error but crashed on running.
Code:
      topmost_ok:

        strtbl stringTb, "one","two","tree"                ;; <- Here

        invoke  EndDialog,[hwnddlg],1

    
maybe you may try. Did i wrong?

Regards
Post 10 Nov 2003, 22:09
Reply with quote
aaro



Joined: 21 Jun 2003
Posts: 107
Location: hel.fi
aaro
I think you must use StrTbl macro in data section instead of code section
Post 10 Nov 2003, 22:18
View user's profile Send private message Reply with quote
kaafe



Joined: 15 Oct 2003
Posts: 18
kaafe
yeah you were right. Thanks but it was not in code section, in fact. But between the constants and data section.

Thank you
Post 10 Nov 2003, 23:07
View user's profile Send private message 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-2019, Tomasz Grysztar.

Powered by rwasa.