I'm still new at this, but how would I go about creating an array like this:

char map[10][10] = {
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 1, 0, 1, 1, 0, 1, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 1, 0, 0, 0, 1},
{1, 0, 0, 0, 1, 1, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 1, 0, 1, 1, 0, 1, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
};

thx.
Posted on 2002-11-01 23:38:31 by sMiLeY-jOnEs


.data?
map DB 10 dup (10 dup (?) )

.data
mat DB 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
DB 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
DB 1, 0, 1, 0, 1, 1, 0, 1, 0, 1
DB 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
DB 1, 0, 0, 0, 1, 1, 0, 0, 0, 1
DB 1, 0, 0, 0, 1, 1, 0, 0, 0, 1
DB 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
DB 1, 0, 1, 0, 1, 1, 0, 1, 0, 1
DB 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
DB 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

.code
lea edi, map
lea esi, mat
mov ecx, 10*10
rep movsb
Posted on 2002-11-02 00:03:20 by n u M I T_o r
thx alot
Posted on 2002-11-02 00:10:23 by sMiLeY-jOnEs
why does he have to declare a uninitialized 10x10-array and then copy the initialized into the uninitialized? cant he simply use the initialized one?

may i add another string-array-question?


char *strings[5] =
{ "string1",
"string2",
"string3",
"string4",
"string5" };

becomes in masm


string db "string1",0
db "string2",0
db "string3",0
db "string4",0
db "string5",0,0

but how can i quickly access the 3rd string? (maybe without knowing how long each one is and with individual length)
or do i have to declare a byte ptr-array which points on my strings? hmm... maybe better...
Posted on 2002-11-02 08:42:00 by hartyl
Originally posted by hartyl why does he have to declare a uninitialized 10x10-array and then copy the initialized into the uninitialized? cant he simply use the initialized one?

Yes.

may i add another string-array-question?


char *strings[5] =
{ "string1",
"string2",
"string3",
"string4",
"string5" };

becomes in masm


string db "string1",0
db "string2",0
db "string3",0
db "string4",0
db "string5",0,0


Actually that's not how the C program would compile, it's an array of string pointers, not a sequence of strings. The C code compiles to:


_tmp1 db "string1",0
_tmp2 db "string2",0
...
_tmp5 db "string5",0
string dd offset _tmp1, offset _tmp2, ..., offset _tmp5


but how can i quickly access the 3rd string? (maybe without knowing how long each one is and with individual length)
or do i have to declare a byte ptr-array which points on my strings? hmm... maybe better...

That's what C does too..

Thomas
Posted on 2002-11-02 08:48:02 by Thomas