HW4

.docx

School

New Jersey Institute Of Technology *

*We aren’t endorsed by this school

Course

350

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

6

Uploaded by BarristerMetal13349 on coursehero.com

1. Following the style of Practice Problem 3.1 (page.182), assume the following values are stored at the indicated memory addresses and registers: Addres s Valu e - - Registe r Value 0x1000 0xAA - - %rdi 0x100 0 0x1004 0xBB - - %rsi 0x1 0x1008 0xCC - - %rdx 0x2 0x100C 0xD D - - %rcx 0x4 Fill in the following table showing the values for the indicated operands: Operand Value %rdi 0x100 0 0x1004 0xBB $0x1008 0x100 8 (%rdi) 0xAA 4(%rdi) 0xBB 8(%rdi,%rcx) 0xDD 0x1002(%rdx, %rcx) 0xCC -4(%rdi,%rsi,4) 0xAA (%rdi,%rdx,4) 0xCC
2 .Using the Address and Register table in Problem 1, fill in the table below showing the values for the indicated operands (similar to Practice Problem 3.8 of page 194): Instruction Destinatio n Value addq (%rdi),%rsi %rsi 0x100 1 andq %rsi,%rdi %rdi 0x00 subq %rsi,(%rdi) 0x1000 0xA9 incq %rsi %rsi 0x2 decq %rdx %rdx 0x1 xorq (%rdi,%rdx,4),%rcx %rcx 0x100 C orq 0x1002(%rdx,%rcx), %rsi %rsi 0xCE 3 For the unknown assembly shown below, fill in the missing return statement in the C function unknown. unknown: imulq %rdx, %rsi leaq (%rsi,%rdi), %rax 8. ret long unknown(long x, long y, long z) { return __ (x+y) + z __________________________; } unknown: movq %rdi, %rax salq $3, %rax addq %rdi, %rax ret long unknown(long x) { return ___8x+x_________________________; }
4 Do problem 3.58 which says "Write C code for the assembly shown in the problem." #include <stdio.h> long decode2 (long, long, long); int main(){ long x,y,z,n; printf("\nEnter the value of x:"); scanf("%1ld",&x); printf(" "); printf(" \nEnter the value of y:"); scanf("%1ld",&y); printf ("\nEnter the value of z:"); scanf("%1ld",&z); n=decode2(x,y,z);
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help