NASM Forum > Programming with NASM
the difference between using times many times and only once
(1/1)
mik3ca:
I noticed something interesting with my code when doing a multidimensional array. In this example, we assume the array is more like a grid.
So the first objective is to initialize the grid with all null values. I'm working in a DOSBOX environment.
I tried the first code and not only did the attempt fail, but the DOSBOX screen froze and I had to close it manually.
--- Code: ---nrows equ 100
ncols equ 100
agrid times nrows times ncols db 0
xor AX,AX
mov CX,nrows*ncols-1
clearram:
mov BX,CX
mov [CS:agrid+BX],AL
loop clearram
--- End code ---
I changed one line. Code is shown below.
--- Code: ---nrows equ 100
ncols equ 100
agrid times (nrows*ncols) db 0
xor AX,AX
mov CX,nrows*ncols-1
clearram:
mov BX,CX
mov [CS:agrid+BX],AL
loop clearram
--- End code ---
Whats interesting is this one works flawlessly.
What does nasm do behind the scenes with space initialization when the keyword "times" is used twice?
Navigation
[0] Message Index
Go to full version