Concordia University

Department of Computer Science

COMP520

Assignment #3

Instructor: F. SAID

Due date: Next Week

Question 1.

Write a GAL program that will prompt the user enter a positive integer and print out its Factorial. Recall that F(X)=X*(X-1)*…*3*2*1.

Question 2.

Perform the following addition/subtraction in 2’s complement (not in decimal) using 8-bit binary representation. Identify the occurences of overflow/underflow. The given integers are in decimal:

  1. 122 + 18
  2. –26 + 100
  3. –125 – 15
  4. 24 - 42

Question 3.

Let LRS(x,I) and ARS(x,I) represent the result obtained by performing logical right shift ans arithmetic right shift of (binary) x by I bits respectively. Show the effect of these 2 statements on the following values of x and I:

  1. x = 11001101, I = 5
  2. x = 01010111, I = 4

Question 4.

Give the hexadecimal equivalent of the following GEML instructions (32-bit format):

  1. subtract #1 à reg4
  2. jump:always à locat (assume locat = 2000h)
  1. jump:equal à locat (assume locat = 2000h)
  2. copy locat à reg1 (assume locat = 1010h)
  3. compare reg1 à reg6

Now, consider the execution of (a) that is stored in memory location 1000h. Identify the contents of PC, IR, source_1, source_2, result, and reg4 after each phase of the instruction cycle (similar to Fig. 6.5).

 

 

 

Question 5.

Given the following memory values and one-address machine with a accumulator:

Word 50 contains 30

Word 40 contains 20

Word 30 contains 40

Word 20 contains 50, and

Accumulator contains 60.

What will be the effect of the following sequential instructions:

  1. Load immediate 30
  2. Load indirect 50
  3. Add direct 40
  4. Store indirect 20

Question 6.

A given memory system has the following characteristics:

  1. Show the format of the main memory address, clearly showing the number of bits in the Tab, Line, and Word fields.
  2. How many bits are there in the cache address?