NASM how to define and later reference an array of strucs?

Viewed 72

Let's say that I have a struc in NASM defined like this:

struc tcb_t
  .a resb 1
  .b resb 1
endstruc

I want to have an array of instances of the above type. Let's say that I have at most 64 threads running and each of them should store some information in such a struct. Each thread knows it's id, so in C we would do it similarly to this:

tcb_t tcbs[64] = {0};
[...]
tcbs[task_id].a += 1

But what's the syntax like for NASM? I wasn't able to find it in their documentation, i.e.:

  • how to define an array of strucs?
  • how to find the size of a struc?
  • knowing the size of a struct, we can't do much better than mov rax, [tcbs + rcx * sizeof_tcb_t], can we?
0 Answers
Related