Ive read old posts on these forums about arrays in fasm, this is what i gathered;
to declare an array of bytes with say 40 elements:

tmp_var rb 40

now, i originally thought that this would allocate 40 bytes of memory for the array, BUT my program crashes if i try to have 41 number of elements, this leads me to believe that im not understading fully, can some1 correct me?
Posted on 2003-03-24 00:30:47 by osushkov
Post some example of the source.
Posted on 2003-03-24 00:40:23 by JohnFound
Well, I wasnt really asking for help with a certain bug, i was actually asking for some1 to tell me how arrays work and stuff in FASM. Im currently reading the book "Art of Assembler Language Programming", and ive discovered that arrays arent declared like they are in the book. So, basically im asking, how do i declare an array of bytes and how do i access the elements?
My first post is my hypothesis... but i think its wrong.
Posted on 2003-03-24 02:53:17 by osushkov
Hm, if we talk really theoretical, there is no such a concept "array" in assembler. "Array" is high level languages concept. In assembler you have simply "memory". This memory is classifyed by you as "array", "variable" etc. The assembler directive "rd" simply reserves (leave empty) some amount of memory and defines label to it. It's your problem how you will use this memory.
Posted on 2003-03-24 05:29:45 by JohnFound
I just tried using 41 number of elements in a 40 byte variable, and it worked.....
Posted on 2003-03-24 15:16:47 by CyberGuy
maybe your 41st element didn't overwrite anything critical...
Posted on 2003-03-24 16:00:15 by jademtech
Ok, just to get something clear:
var rb 41
will reserve either: a) 41 BYTES of memory, or b) will reserver 41*sizeof(var) which is in this case still 41 bytes but it makes a difference in other examples.
So can someone tell me which one is it?
Posted on 2003-03-24 20:36:54 by osushkov
var rb 41
will reserve 41 bytes and will set "var" label as byte type. I.e. instructions like:
mov ,5
push ,
where is not clear what is the size of the operands will be assembled as byte instructions.

var rw 41
will reserve 41 words (82 bytes) and will set "var" label as word type. I.e. instructions like above will be assembled as word instructions.

The same is about "rd" directive.

Advice: Forget about sizeof() function. This is not native assembler directive nor instruction.
Posted on 2003-03-25 00:48:18 by JohnFound