SCMP 391 – Homework 12

Instruction Sets

  1. Design an expanding opcode to allow all the following to be encoded in a 32-bit instruction:
    • 15 instructions with two 12-bit addresses and one 4-bit register number
    • 650 instructions with one 12-bit address and one 4-bit register number
    • 80 instructions with no addresses or registers
  2. Given the memory values below and a one-address machine with an accumulator, what values do the following instructions load into the accumulator?
    • word 20 contains 40
    • word 30 contains 50
    • word 40 contains 60
    • word 50 contains 70
    • LOAD IMMEDIATE 20
    • LOAD DIRECT 20
    • LOAD INDIRECT 20
    • LOAD IMMEDIATE 30
    • LOAD DIRECT 30
    • LOAD INDIRECT 30
  3. Compare 0-, 1-, 2-, and 3-address machines by writing programs to compute
    X = (A + B × C) / (D − E × F)
    for each of the four machines. The instructions available for use are in table 1.

    M is a 16-bit memory address, and X, Y , and Z are either 16-bit addresses or 4-bit registers. The 0-address machine uses a stack, the 1-address machine uses an accumulator, and the other two have 16 registers and instructions operating on all combinations of memory locations and registers. SUB X,Y subtracts Y from X and SUB X,Y,Z subtracts Z from Y and puts the result in X. With 8-bit opcodes and instruction lengths that are multiples of 4 bits, how many bits does each machine need to compute X?
  4. Compute the Boolean expression ( A AND B) OR C for
    1. A = 1101 0000 1010 0011
    2. B = 1111 1111 0000 1111
    3. C = 0000 0000 0010 0000
  5. Why do I/O devices place the interrupt vector on the bus? Would it be possible to store that information in a table in memory instead?
0 Address1 Address2 Address3 Address
PUSH MLOAD MMOV X,Y (X = Y)MOV X,Y (X = Y)
POP MSTORE MADD X,Y (X = X+Y)ADD X,Y,Z (X = Y+Z)
ADDADD MSUB X,Y (X = X−Y)SUB X,Y,Z (X = Y−Z)
SUBSUB MMUL X,Y (X = X∗Y)MUL X,Y,Z (X = Y∗Z)
MULMUL MDIV X,Y (X = X/Y)DIV X,Y,Z (X = Y/Z)
DIVDIV M
Table 1

Scroll to Top