Login
Remember
Register
Questions
Hot!
Categories
Ask a Question
Ask a Question
How do we create an array on the stack (AKA, with automatic class)? Ex: int data[20], and set the first element to 0.
0
votes
asked
Sep 25, 2022
in
General Knowledge
by
iskralawrence
(
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.
Facebook
Twitter
LinkedIn
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
1
Answer
0
votes
answered
Sep 25, 2022
by
iskralawrence
(
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)
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Welcome to the Answerine , a great place to find, read and share your favorite questions and answers.
Related questions
0
votes
1
answer
If we made an array on the stack, how do we clean up when we're done?
asked
Sep 25, 2022
in
General Knowledge
by
iskralawrence
(
773k
points)
0
votes
1
answer
Consider the following code: static int array[30] int x = array[25] What is the equivalent in assembler, given array is defined in .data?
asked
Sep 25, 2022
in
General Knowledge
by
iskralawrence
(
773k
points)
0
votes
1
answer
How do I access a specific nested array element?
asked
Sep 25, 2022
in
General Knowledge
by
iskralawrence
(
773k
points)
0
votes
1
answer
Descriptive statistics describe a set of scores. How do the mean, median, and standard deviation help describe a set of numbers? When comparing data sets with the same mean
asked
Nov 29, 2022
in
General Knowledge
by
monikakim
(
557k
points)
0
votes
1
answer
How do you set up the program stack?
asked
Sep 25, 2022
in
General Knowledge
by
iskralawrence
(
773k
points)
...