datapath.circ
,
control.circ
,
cpu32.circ
,
misc32.circ
,
and
loop.mem
.datapath.circ
,
loop.mem
, and first table of control settings. The file datapath.circ
contains an incomplete
implementation of the MIPS instruction set architecture (ISA). This
circuit is similar to
Figure 5.17 on page 307
in the textbook.
This datapath can execute the following instructions:
add, sub, and, or, nor, slt, addi, lw, sw,
and
beq
.
loop.mem
.
loop: addi $t0, $zero, 17 sw $t0, 0($zero) beq $zero, $zero, loop
loop.mem
into the instruction
memory.Next complete the control to implement our subset of instructions.
slti
instruction is not discussed in the textbook, but can be
executed on this datapath with appropriate control settings.control.circ
. Do not make any changes to the circuits in datapath.circ
.nop
is a pseudo-instruction that does nothing. It is
encoded as 0x00000000 and is equivalent to an R-type instruction with
register $zero as its operands and its destination. Because the
contents of register $zero cannot be altered, this instruction has no
effect. Fill program memory with several nop
instructions. The program counter should increase by 4 as each nop
instruction is executed.
nop # sll $zero, $zero, 0
halt
is a pseudo-instruction that halts the CPU. It
is equivalent to a branch with an address offset of -1.
Replace one of the nop
instructions with a halt
instruction. The program counter should increase by
4 as each nop
instruction is executed. The program
counter should stop changing when the halt
instruction is
reached.
halt # beq $zero, $zero, -1
nop
instruction ensures that the first important
instruction of the program will always be executed.)
Enter a hexadecimal value into the first data memory location before
executing this program.
nop lw $t0, 0($zero) # n = mem[0] sw $t0, 4($zero) # mem[4] = n halt
nop lw $t0, 0($zero) # n = mem[0] addi $t0, $t0, 1 # n++ sw $t0, 4($zero) # mem[4] = n halt
n
from the first location
in data memory and then fills the first n
memory
locations with the values from 0 to n-1
. Enter a
hexadecimal value into the first data memory location before executing
this program.
Translate the program to an equivalent assembly language program
that uses only instructions supported directly by the hardware. Save
the resulting assembly language program in a file named loop.s
and save the corresponding machine language
program (in hexadecimal) in a file named loop.mem
. You
may want to use the file loop.mem
from the previous
lab as a template.
nop li $t0, 0 # n = 0 lw $t2, 0($t0) # limit = mem[0] j test # test at end of loop loop: add $t1, $t0, $t0 # t1 = 2n add $t1, $t1, $t1 # t1 = 4n sw $t0, 0($t1) # mem[4n] = n addi $t0, $t0, 1 # n++ test: blt $t0, $t2, loop # while(n < limit) halt
slti
instruction. Save your assembly language program in
a file named slti.s
and the corresponding machine
language program (in hexadecimal) in a file named slti.mem
.