Posted on

# 1 Write a program in MARIE assembly language to perform following code segment Test your code

1. Write a program in MARIE assembly language to perform the following code segment. Test your code thoroughly using the MARIE simulator with values of X=10, X=20, and X=30. What is the value stored in X and Y by the end of execution? Include comments for each line of instruction in your program (12 points).

X=10
Y=0

while X!=0 do
Y=X
X=X-1
endwhile

while X!=0 do
Y=X
X=X-1
endwhile

2. Consider the following program in MARIE assembly language. Complete the table detailing the RTN for the next 3 instructions only that will be executed including the content of registers PC, IR, MAR, MBR, and AC in hexadecimal. Note the first instruction LOAD X is already filled. Note also that the SKIPCOND instruction has no operands, therefore you can complete Fetch, decode and execute cycles only. Explain in one statement what this program is doing (14 points).

ORG 000
LOAD X ; AC = X
Repeat, ADD One ; AC = X + 1
SKIPCOND 000 ; if AC < 0 then PC = PC + 1 (skip) JUMP End ; Go to End STORE X ; X = AC JUMP Repeat ; Go to Repeat End, STORE X ; Stop (end of program) This program is incrementing the value of X by 1 repeatedly until the value in AC becomes negative. 3. Assume a main memory has the following hex values in the first two bytes: Byte 0: 8F Byte 1: 0F What is the actual decimal value stored in these bytes, assuming they are in 16-bit 2's complement representation and the machine is using: a) Big endian memory b) Little endian memory (4 points) a) In big endian memory, the byte order is reversed. So, the actual decimal value stored in these bytes would be -7. b) In little endian memory, the byte order remains the same. So, the actual decimal value stored in these bytes would be 36655. 4. Consider the assembly program (in MARIE) below and the corresponding memory address for each instruction. Show the symbol table that will be constructed by the assembler after the first pass including the translated program, then fill in the final machine code produced by the assembler after the second pass. Fill in the given tables using HEX numbers for instructions and addresses. (10 points) [Symbol Table] LOAD 0100 ADD 0101 STORE 0110 SUBT 0111 JUMP 1000 Dec1 0001 [First Pass] 0100 LOAD X ; Load value at address X to AC 0101 ADD Y ; Add value at address Y to AC 0110 STORE Z ; Store value in AC to address Z 0111 SUBT X ; Subtract value at address X from AC 1000 JUMP Z ; Jump to address Z [Second Pass] 0100 1005 ; Load X 0101 5006 ; Add Y 0110 210B ; Store Z 0111 1015 ; Subtract X 1000 4010 ; Jump Z

Solved By Verified
Study Co-Pilot

Instant
Download

Student review: