$24
(Q1. 12 points + 2 bonus points) The following values are stored at the indicated memory addresses and registers:
Address Value Register Value
0x210 0xAB %rax 0x210
0x218 0xBC %rcx 0x220
0x220 0x09 %rdx 0x1
0x228 0x42 %rsi 0x8
0x230 0x54 %rdi 0x100
Assume that the Values occupy eight bytes of storage, but the endianness of storage is not specified. Each part of this question concerns one item in the following list of operands. For the operands, give the Value of the operand, and the addressing Mode used (copying from the “Name” column of Figure 3.3 in the textbook). If the facts given here don’t provide sufficient information to answer the question unambiguously, for Value say “unknown”, and for Mode give an explanation of what information is missing, without which there isn’t an unambiguous answer. Give all Values in hex (unsigned), starting with “0x”.
Part
Operand
Value
Mode
e.g.
%rax
0x210
Register
(%rcx)
560
(%rax,%rsi)
0x108(%rdi,%rdx,0x20)
$251
(,%rsi,0x45)
(Bonus) G. 0x14(%rax)
see https://classes.cs.uchicago.edu/current/15400-1/svn.html
(Q2. 20 points) Assume the same information about addresses, registers, and values as in the previous question. The table is reprinted here for convenience:
Address
Value
Register
Value
0x210
0xAB
%rax
0x210
0x218
0xBC
%rcx
0x220
0x220
0x09
%rdx
0x1
0x228
0x42
%rsi
0x8
0x230
0x54
%rdi
0x100
Each part of this question concerns a single instruction. Each instruction is to be considered in isolation (the answer for one instruction does not affect any other instruction). The argument ordering for the instructions is the same ATT format (not Intel format) as used in the book. Negative values are represented with two’s complement.
For each part, give the Destination for the instruction (as either “0xADDR” for address ADDR or as ‘%reg” for register reg), and the (unsigned) Value (in hex, starting with “0x”) stored in the Destination. If the facts given don’t provide sufficient information to answer the question unambiguously, give “unknown” for Destination, and a terse explanation why for Value.
Part
Instruction
Destination
Value
e.g.
addq %rdx,(%rax)
0x210
0xAC
incq %rsi
decq (%rax)
notq %rdx
shlq %rsi,(%rcx)
subq $0x100,%rcx
imulq %rdi,(%rax,%rsi)
orq (%rcx),%rax
shrq %rdx,(%rdi,%rsi,37)
xorq %rbx,%rbx
subq 0x220,%rdi
Note: For this homework, it is fine to use a calculator or some other program to aid with arithmetic.
2