assignment 3 - comp228

Page 1

CONCORDIA UNIVERSITY

COMP 228

DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING

Fall 2009

ASSIGNMENT 3

Due: November 3, 2009 ___________________________________________________________________________________ 1. MARIE architecture [28%] (a) The registers PC, AC, InREG, OutREG are relevant to the state of a program in the MARIE ISP. Identify which of these registers are modified when each of the following instructions are executed: (i) Load X, (ii) Subt X, (iii) Input, (iv) Halt, (v) Skipcond, (vi) Jump X, (vii) Jns X, (viii) AddI X. (b) Suppose initially PC = 100, AC = 1234, M[200] = 234 , trace the fetch-execute (instruction) cycle of the following sequence of MARIE instructions using RTN (similar to Figure 4.14 of your text). Add

200

Store 200 (c) MARIE uses 12-bit address, 16-bit data registers, and 16-bit instructions. What is the maximum memory size in MARIE? Program size? Largest 2’s complement integer? Maximum number of instructions? (d) The following is an incomplete assembler output listing of a MARIE program: 000 001 002 003 004 005 006 007 008 009 00A 00B 00C

5000 0003 9000 0000 200C 400B ____ C003 6000 7000 000A 0000

| | | | | | | | | | | | |

S1 R

X Y

INPUT JNS R JUMP S1 DEC 0 STORE Y SUBT X SKIPCOND 400 JUMPI R LOAD Y OUTPUT HALT Dec 10 Dec 0

| | SYMBOL TABLE -------------------------------------------------Symbol | Defined | References --------+--------+-----------------------------R | 003 | 001, 007 S1 | 000 | 002 | _____ X | Y | 00C | 004, 008 -------------------------------------------------

(i)

What does the first line <Y, 00C, 004, 008> in the symbol table convey to you?


COMP 228 (System Hardware), Fall 2007 ⎯ Assignment 3

Page 2

(ii)

Identify all memory locations containing program data.

(iii)

Using the instruction set format of MARIE (refer to table 4.2 of your text), fill in the missing (underlined) entries in the assembler output.

(iv)

By tracing the execution of the given program (by hand), answer the following questions: •

What will cause the program terminate?

How many times will the instruction at S1 be executed?

What would the program have done upon termination?

2. MARIE programming [27%] (a) Do problem 17 (page 240) of your text. (b) Do problem 18 (page 240) of your text. (c) Do problem 20 (page 240) of your text. 3. Fetch-Decode-Execute Cycle [15%] Suppose we add a stack-add (SADD) instruction in MARIE where memory location 0 (hex) is reserved to store the stack pointer (address of the top of the stack). When executed, SADD pops the two top elements of the stack and stores their sum in register AC. For example, if M[0] = 200, upon execution, AC = M[200] + M[1FF] and M[0] = M[1FE]. (a) Represent the fetch-decode-exceute cycle of this instruction in RTN. Assume a register can be incremented/decremented (by 1) without going through the ALU. (b) Write a sequence of MARIE instructions that will do the same function as SADD. Programming Problem 4. Input/Output in MARIE [30%] Write a MARIE program that repeatedly receives a sequence of decimal digits (one digit at a time), computes their sum and stores it in memory location SUM. The program terminates when a non-digit is received. Assemble and run your program using the MARIE simulator [at http://computerscience.jbpub.com/ecoa/2e/student_resources.cfm]. Debug the program until it works correctly. Submit a correctly working version of your MARIE program along with sample input and output of two simulated runs illustrating its correctness.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.