Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 4 (ao points. Suggested time: 15 mins) Part a (6 points): Name three ins

ID: 3705155 • Letter: P

Question

Problem 4 (ao points. Suggested time: 15 mins) Part a (6 points): Name three instructions that have zero operand, one operand, and two operands, respectively (2 points) zero-operand instruction: (2 points) one-operand instruction: (2 points) two-operand instruction: Part b (5 points): Consider the following C declaration of an array of struet, assuming that the address of variable A is ox8oo0 and that this program is executed on a 64-bit machine. struct S ( int i; double v char j; What is the address of Al2113)j? Part e (9 points): The following assembly program adds the absolute value of a signed integer stored in memory location ox4000 to the absolute value of another signed integer stored in memory location 0x4004, and stores the sum to memory location ox4008. Complete the three missing instructions Hint: This problem might test you on the following things: Register saving convention Control transfer Data movement .

Explanation / Answer

Part a:-

zero-operand instruction :- ret

one-operand instruction :- inc <destination>

two-operand instruction :- add <destination>,<source>


Part b:-

given:-
struct which consists of int,double and char .So,total bytes for one structure = 4 + 8 + 1 = 13 bytes

So,
A[2][3] starts after passing 23 stuctures worth size.So,as each structure = 13 bytes.
23 structures = 23 * 13 bytes = 299 bytes = 0x12B bytes

So,address of A[2][3] when starting address is 0x8000 then the adddress of A[2][3] = 0x8000 + 0x12B = 0x812B

Part c:-
.func
movq $0x4000,%rbx
movq (%rbx),%rdi
call .abs

movq %rax,%rdx

movq $0x4004,%rbx
movq (%rbx),%rdi

pushq %rdx

call .abs
popq %rdx
addq %rdx,%rax
movq $0x4008,%rbx
movq %rax,%(rbx)
halt

.abs
movq $0x0,%rdx
addq %rdx,%rdi

jns done

.skip
negq %rdi
.done
movq %rdi,%rax
ret

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote