4190.308 Computer Architecture
Name:
Due Date:
Wednesday, September 11, 2014, 23:59
Student-Number:
Submission:
in paper form.
There will be a drop off box in class and in front of the CSAP Lab in building 301, room 419.
Assignment
Update your information on eTL. (your picture, e-mail address and mobile phone number)
Question 1
Memory operations
Explain the difference of “reg to mem”, “mem to reg” and “mem to mem” ISAs.
Text
ans:
They all make reference to a movement of data from one place to another.
REG to REG is the movement of data from one register into another. In contrast MEM to REG is the movement of data from memory to a register. Finally, MEM to MEM represent
data transfer from one place in memory into another.
Question 2
Operand Specifiers
Assume the following values are stored at the indicated memory addresses and registers:
Address
Value
Register
Value
0x100
0xFF
%eax
0x104
0x104
0xAB
%ecx
0x1
0x108
0x13
%edx
0x3
0x10C
0x11
0x110
0xB5
0x114
0x3B
0x118
0x1A
0x11C
0x03
Fill in the following table showing the values for the indicated operands:
Operand
Value
%edx
0x3
0x114
0x3B
$0x11C
0x11C
(%eax)
0xAB
8(%eax)
0x11
0xD(%eax,%edx)
0x3B
264(%ecx,%edx)
0x11
0xFC(,%ecx,8)
0xAB
(%eax,%edx,8)
0x03
Question 3
Data movement instructions
You are given the following information. A function with prototype void decode(int *xp, int *yp, int *zp); is compiled into assembly code. The body of the code is as follows: xp at %ebp+0x8, yp at %ebp+0xc, zp at %ebp+0x10 mov mov mov mov mov mov mov mov mov 0x8(%ebp),%edx
0xc(%ebp),%eax
0x10(%ebp),%ecx
(%eax),%esi
(%ecx),%ebx
(%edx),%edi
%edi,(%ecx)
%esi,(%edx)
%ebx,(%eax)
Parameters xp, yp, and zp are stored at memory locations with offsets 0x8, 0xc, and 0x10, respectively, relative to the address in register %ebp.
Write C code for decode that will have an effect equivalent to the assembly code above.
void decode(int *xp, int *yp, int *zp)
{
int a, b, c; a = xp; //(%edx),%edi b = yp; //(%eax),%esi c = zp; //(%ecx),%ebx xp = b; //%esi,(%edx) yp = a; //%ebx,(%eax) zp = c; //%edi,(%ecx)
//…
}