

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The assembly instructions for saving stack space for local variables and an array, as well as storing values into these variables in the cs30 course, fall 2001. It covers saving space for short, char, long, unsigned short, and int variables, as well as an array of char, and performing assignments using pointers.
Typology: Quizzes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


a) Write the appropriate save instruction to allocate stack space for the following local variables and any padding. short a; char b; long c; unsigned short d; int e; save _________ , ______________________________ , _________ (Use the formula, not an absolute value) b) Write the appropriate instructions to store the value -4200 in local variable e as defined above (hint: you cannot assign an immediate constant value directly to memory — you can only store from a register to memory). ________________________! -4200 -> %l ________________________! %l0 -> local variable e
c) Write the appropriate instructions to store the value 0x911 in local variable c as defined above (same hint as above). ________________________! 0x911 -> %l ________________________! %l0 -> local variable c
d) Write the appropriate instruction to place the value in local variable d into register %l. ________________________! d -> %l
e) Write the appropriate instruction to place the value in local variable a into register %l. ________________________! a -> %l
(OVER)
a) Write the appropriate save instruction to allocate stack space for the following local variable declara- tion. char a[9]; save _________ , ______________________________ , _________ (Use the formula, not an absolute value) b) Write the appropriate instructions to perform the following assignment statements, assuming variable i is mapped to %l0 and ptr is mapped to %l. char i; /* i mapped to %l0 */ i = a[4]; ________________________! a[4] -> %l a[2] = i; ________________________! %l0 -> a[2] char ptr; / ptr mapped to %l1 / ptr = &a[1]; ________________________! &a[1] -> %l ++ptr; / ptr mapped to %l1 */ ________________________! ++ptr ptr = i; / i mapped to %l0; ptr to %l1 */ ________________________! %l0 -> *ptr i = ptr; / i mapped to %l0; ptr to %l1 */ ________________________! *ptr -> %l