Question: 4 . 4 5 4 . 4 5 In Section 3 . 4 . 2 the x 8 6 - 6 4 pushq instruction was
In Section the x pushq instruction was described as decrementing the stack pointer and then
storing the register at the stack pointer location. So if we had an instruction of the form pushq REG, for some
register REG, it would be equivalent to the code sequence
subq $rsp Decrement stack pointer
movq REG, rsp Store REG on stack
A In light of analysis done in Practice Problem does this code sequence correctly describe
the behavior of the instruction pushq rsp Explain.
B How could you rewrite the code sequence so that it correctly describes both the cases where
REG is rsp as well as any other register? A Write and test a version that references the array elements with pointers, rather than using
array indexing.
B Write and test a Y program consisting of the function and test code. You may find it useful
to pattern your implementation after code generated by compiling your C code. Although
pointer comparisons are normally done using unsigned arithmetic, you can use signed arithmetic
for this exercise.
For this problem reflect back to your analysis done in Practice Problem does
this code sequence correctly describe the behavior of the instruction pushq rsp
Explain. This will be done in a word document and then submitted to the
assignment.
For this problem you will perform the following steps:
For Part A you will write a Y program that sorts an array of data using
Bubble Sort. The user should be allowed to input numbers from the
keyboard. You will sort the array in place ie no need to allocate
additional memory for the sorted array Follow the register usage
conventions outlined in the text. Your program should be a complete one.
Upload your cpp source file to the assignment area.
For Part B Write and test a Y program consisting of the function
and test code. You may find it useful to pattern your implementation after
code generated by compiling your C code. Although pointer
comparisons are normally done using unsigned arithmetic, you can use
signed arithmetic for this exercise.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
