News:

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

Define data table

Started by korte, June 22, 2009, 07:22:55 PM

Previous topic - Next topic

korte


How to define macro?


table macro data_address,data (data is vararg)
  cnt=0
  mov [data_address+cnt],data
endm





    table data_address,1,2,3,4,5,6,7,8,

Jimg

table macro tbladdr,bvals:vararg
    local cnt
    cnt=0
    for dat,<bvals>
        mov byte ptr [tbladdr+cnt],dat
        cnt=cnt+1
    endm       
endm

.data?
mytable db 10 dup (?)
.code

table mytable,1,2,3,4,5,6,7,8


note:  this is only for bytes, modify as desired for other sized values, eg.


table macro tbladdr,dvals:vararg
    local cnt
    cnt=0
    for dat,<dvals>
        mov dword ptr [tbladdr+cnt],dat
        cnt=cnt+4
    endm       
endm

.data?
mytable db 40 dup (?)
.code

table mytable,1111,2222,3333,4444,5555,6666,7777,8888


however, I don't see why you would want to do this when you could just do


.data
mytable dd 1111,2222,3333,4444,5555,6666,7777,8888
.code

and not have to worry about exceeding the space set aside for the table and other things.