Assignment : Computer Organization & Architecture

867 Words Sep 25th, 2015 4 Pages
Assignment IV – Computer Organization & Architecture

Prepared By
Rubin William
11562401

For
Malka Halgamuge

15/05/2015
Answer 1
a) Hexadecimal code for each instruction

b) Symbol Table

c) Accumulator Value: 0108

Answer 2
Assuming that the numbers to be multiplied are positive numbers.

ORG 100

INPUT
// store the first input number at 40 & 41 location
STORE 40
STORE 41

INPUT
// Check if the second input value is zero; if yes then terminate program else continue
SKIPCOND 400
JUMP FOR_INIT
OUTPUT 0
HALT

FOR_INIT, SKIPCOND 800 // If the second number is not positive then the program will be terminated
HALT
SUBT ONE // Subtract 1 so that the loop loops for (second number – 1) times
STORE 42

FOR_COND, LOAD 42 // Load second number (starting of for loop)
SKIPCOND 400 //Check if the second value is equal to 0; terminate the loop and go to END_FOR
JUMP FOR_BODY
JUMP END_FOR

FOR_BODY, LOAD 42 // Load second number
SUBT ONE // Subtract one
STORE 42 // Store the second number
LOAD 40 // Load the first number
ADD 41 // Add the value in 41 to 40 (40 & 41 have the same)
STORE 40 // Store the result of addition
JUMP FOR_COND // Go to FOR_COND (starting of loop)

END_FOR, LOAD 40 // End for loop
OUTPUT 40 // Output the sum (multiplication result)
HALT
ONE, DEC 1

Answer 3
a) Since 1 to 7 addresses need to be identified for the mode, 3 bits will be required (23 = 8)
b) 1 to 60 registers need to identified so 6 bits will be required (26 = 64)…
Open Document