What's most important for you to understand is that NASM does not support the idea of an 'array'. Technically, at the machine level it's all just byte addressable RAM.
If you wish, you may think of the routine of indexing into an array (take it to be a pointer, or a symbol address) as simply adding the offset to the original pointer. You understand this already, based on your example.
Code: Select all
;; 'array': Symbol giving the start addr of a contiguous 256 byte RAM sequence.
array:
resb 0x100
print_chars:
;; etc.
ret
main:
mov esi, array
mov ecx, 0x0
.continue:
push byte [esi + ecx]
call print_chars
add esp, 4
inc ecx
cmp ecx, 255
jb .continue
Is roughly equivalent to:
Code: Select all
static unsigned char[256];
void print_char(unsigned char ch) {
// etc.
};
int main(void)
{
int i=0;
for (; i<256; i++)
{
print_char(array[i]);
};
};
Except that a compiler will find some way to optimize the assembly language instructions more efficiently.
You may also check the NASM manuals to supplement any information given here.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.