Name: ID: 1.
COMP228 Quiz 2
Mark: Time Allowed:
/10 15 minutes
Identify precisely the consequence in executing each of the following instructions, assuming the given initial register contents. Instruction Initial register content Consequence Skipcond 800 AC = FFF0, PC = 100 PC = 101 AddI 100
AC = FFF0, M[100] = 0000, M[000]= 1000, PC = 200
AC = FFF0 + 1000 = 0FF0 PC = 201
Jns
PC = 200, M[100] = 0000
M[100] = 201, PC = 101
100
2.
Consider executing the following sequence of NASM instructions with initial contents: eax = 00001234, ebx = 0000FFFF mov [edx], bx cmp bx, ax jg done (a) How many bytes of operands are involved in the mov instruction? Answer: 2 (b) How many memory data accesses are performed in the execution of these three instructions? Answer: 1 (c) Will the jump to done be successful? Answer: no
3.
Write a sequence of MARIE instructions that performs X = Y * Z, assuming X, Y, Z are stored in corresponding memory locations X, Y and Z. [Warning: MARIE does not have multiply opcode and you need to use iterative additions to get this done.] Load Z Store T //T buffers Z and decrements iteratively S1, Load T Subt One Skipcond 000 Jump S2 Jump S3 S2, Store T Load X //X initially stores 0 Add Y Store X Jump S1 S3, :::