Search code examples
armarm64armv8

Making sense of this line of VHDL code that multiplies by 8


Why is line 2 i * 8? I got this code from a book.

MOV X9,XZR // i = 0
loop1: LSL X10,X9,#3 // X10 = i * 8
ADD X11,X0,X10 // X11 = address of array[i]
STUR XZR,[X11,#0] // array[i] = 0
ADDI X9,X9,#1 // i = i + 1
CMP X9,X1 // compare i to size
B.LT loop1 // if (i < size) go to loop1

Solution

  • LSL is logical shift left. Numbers are binary. One shift doubles the number. So three shifts is two to the third power which is 8.