Review M: The MINIAC machine: Questions

M.1.

CPUs contain a specially designated register called a program counter. Explain what the program counter does.

M.2.

What distinguishes the Harvard architecture (which the MINIAC uses) from the von Neumann architecture (used by ARM processors)?

M.3.

Distinguish between the terms machine language and assembly language.

M.4.

Translate the below five-instruction MINIAC program to machine language.

loop LI -1
     ST 5
     AD 5
     BN loop
halt BZ halt
M.5.

Write MINIAC assembly code that places into data memory at address 4 the negation of the value found in data memory at address 7.

M.6.

Write MINIAC assembly code that looks at data memory at address 8 and places a 0 into data memory at address 6 if the number is even and 1 if it is odd.

Review M: The MINIAC machine: Solutions

M.1.

The program counter holds the memory address indicating where to load the next instruction to be executed. It essentially keeps track of where the computer is currently located within the program it is executing.

M.2.

In a Harvard architecture computer, the program instructions and the program data are stored in two separate memories, with different address spaces; by contrast, a von Neumann architecture stores both instructions and data alongside each other in the same memory.

M.3.

Machine language specifies how a machine decodes binary data as instructions for it to execute. Assembly language specifies a textual representation easier for humans to read and write, that translates to machine language in a transparent manner.

M.4.
loopLI -110011111
ST 501000101
AD 511000101
BN loop00111101
haltBZ halt00000000
M.5.
    LI 0    # to negate RAM[7], compute 0 - RAM[7] and store at RAM[4]
    SB 7
    ST 4
M.6.
    LM 8    # load input, rotate 7 spots so 1 bit is in -128's bit
    RL 7
    BN odd  # if top bit is 1, then original number was odd
    LI 0    # otherwise, store 0 at address 8 and halt
    ST 8
    BZ 0
odd LI 1    # sore 1 at address 8 and halt
    ST 8
    LI 0
    BZ 0