flat assembler
Message board for the users of flat assembler.

Index > Main > translating syntax for HLA array?

Author
Thread Post new topic Reply to topic
jdawg



Joined: 26 Jun 2005
Posts: 39
jdawg
I'm looking for a way to translate this array into FASM v 1.43 from HLA
matrix4x4: real32[4,4];
The only way I could get the source to assemble was to use this
matrix4x4: times 4-4 dd ?
Is this a correct translation?
If not how would I translate it and if so would the correct translation for
FASM v 1.62 be this?
matrix4x4: dup 4-4 dd ?
Question
Post 30 Jun 2005, 23:24
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22
A 2d matrix is just an index mapped 1d matrix
4x4
0 1 2 3
4 5 6 7
8 9 1011
12131415
so
matrix4x4 rd 4*4 ; reserve 16 dwords for a 4x4 matrix
to access IE:
MOV ECX, INDEX ; 0 - 15
MOV EAX, dword [matrix4x4 + ECX * 4] ;4 because dword is 4bytes

Using RD (reserve dword should work just fine for you.
Just have to make any indexes 1d instead of 2d
matrix2x3 rd 2*3
matrix3x4 rd 3*4
Post 01 Jul 2005, 01:02
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
Hy jdawg,
if you are sticked to the multi imensional arrays, you can use this kind of approach

Code:
;to access ELEMENTS:

MOV EBX, [xmatrix]; 0 - 3
MOV ECX, [ymatrix]; 0 - 3
SHL ECX, 4
MOV EAX, dword [matrix4x4 + ECX  + EBX * 4]


ymatrix rd ?
xmatrix rd ?

matrix4x4 rd 4*4 ; reserve 16 dwords for a 4x4 matrix
    
Post 01 Jul 2005, 06:35
View user's profile Send private message Visit poster's website Reply with quote
jdawg



Joined: 26 Jun 2005
Posts: 39
jdawg
Thanks for the input I found that r22's post was what I needed to do. But I might try the two single matrix approach as well Very Happy
Post 02 Jul 2005, 19:58
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-2020, Tomasz Grysztar.

Powered by rwasa.