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?
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?
Post some example of the source.
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.
My first post is my hypothesis... but i think its wrong.
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.
I just tried using 41 number of elements in a 40 byte variable, and it worked.....
maybe your 41st element didn't overwrite anything critical...
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?
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?
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.
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.