0 votes
in General Knowledge by (773k points)
How do we create an array on the stack (AKA, with automatic class)?

Ex: int data[20], and set the first element to 0.

1 Answer

0 votes
by (773k points)
Best answer
pushq %rbp #stack housekeeping
movq %rsp, %rbp
subq $80, %rsp #Allocate space for array (20*sizeof(int))
leaq (%rsp), %rax #or movq %rsp, %rax (Now, rax is pointing at the beginning of the array.)
mov1 $0, (%rax)
Welcome to the Answerine , a great place to find, read and share your favorite questions and answers.