Author Topic: the difference between using times many times and only once  (Read 181 times)

Offline mik3ca

  • Jr. Member
  • *
  • Posts: 30
the difference between using times many times and only once
« on: February 27, 2021, 06:04:09 AM »
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: [Select]
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

I changed one line. Code is shown below.

Code: [Select]
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

Whats interesting is this one works flawlessly.

What does nasm do behind the scenes with space initialization when the keyword "times" is used twice?