Author Topic: array length and etc  (Read 8210 times)

Offline zenid

  • Jr. Member
  • *
  • Posts: 2
array length and etc
« on: March 18, 2012, 12:41:06 PM »
Hi.

How can i get length(how many elements) and size of an array?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: array length and etc
« Reply #1 on: March 18, 2012, 08:24:44 PM »
Code: [Select]
msg "Hello Zenid", 10
msg_len equ $ - msg

array dd 5, -1, 10, 42
array_count equ ($ - array) / 4

Something like that?

Best,
Frank


Offline zenid

  • Jr. Member
  • *
  • Posts: 2
Re: array length and etc
« Reply #2 on: March 18, 2012, 09:37:13 PM »
It was what I asked for thanks!!!

Another quick question: can they be used anywhere or only in global variables(arrays)?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: array length and etc
« Reply #3 on: March 18, 2012, 09:46:37 PM »
Mmmm, as opposed to what? Local/stack variables? I don't see how it would work for stack variables. Maybe I don't understand the question. When in doubt, try it!

Best,
Frank