SlideShare una empresa de Scribd logo
1 de 58
cs47_proj_source/CS47_proj_alu_normal.asm
.include "./cs47_proj_macro.asm"
.text
.globl au_normal
# TBD: Complete your project procedures
# Needed skeleton is given
#####################################################
################
# Implement au_normal
# Argument:
# $a0: First number
# $a1: Second number
# $a2: operation code ('+':add, '-':sub, '*':mul, '/':div)
# Return:
# $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1)
# $v1: ($a0 * $a1):HI | ($a0 % $a1)
# Notes:
#####################################################
################
au_normal:
# TBD: Complete it
addi $sp, $sp, -16
sw $fp, 16($sp)
sw $ra, 12($sp)
sw $s0, 8($sp)
addi $fp, $sp, 16
beq $a2, '+', add_normal
beq $a2, '-', sub_normal
beq $a2, '*', mult_normal
beq $a2, '/', div_normal
add_normal:
add $s0, $a0, $a1
move $v0, $s0
j normal_end
sub_normal:
sub $s0, $a0, $a1
la $v0, 0($s0)
move $v0, $s0
j normal_end
mult_normal:
mult $a0, $a1
mfhi $v1
mflo $v0
j normal_end
div_normal:
div $a0, $a1
mfhi $v1
mflo $v0
j normal_end
normal_end:
lw $fp, 16($sp)
lw $ra, 12($sp)
lw $s0, 8($sp)
addi $sp, $sp, 16
jr $ra
__MACOSX/cs47_proj_source/._CS47_proj_alu_normal.asm
cs47_proj_source/.DS_Store
__MACOSX/cs47_proj_source/._.DS_Store
cs47_proj_source/cs47_proj_macro.asm
# Add you macro definition here - do not touch
cs47_common_macro.asm"
#<------------------ MACRO DEFINITIONS ----------------------
>#
# Macro to take away the nth bit for operations
.macro take_nth_bit ($regD, $regS, $regT)
# right shift by $regT
srlv $regD, $regS, $regT
and $regD, $regD, 0x1
.end_macro
# Macro to put value to nth bit
.macro put_value_to_nth_bit($regD, $regS, $regT, $maskReg)
# shift 0x1 for $regS
li $t9, 0x1
sllv $maskReg, $t9, $regS
# inverse
nor $maskReg, $maskReg, $0
and $regD, $regD, $maskReg
# shift left $regT by the amount of it
sllv $regT, $regT, $regS
or $regD, $regD, $regT
.end_macro
__MACOSX/cs47_proj_source/._cs47_proj_macro.asm
cs47_proj_source/CS47_proj_alu_logical.asm
.include "./cs47_proj_macro.asm"
.text
.globl au_logical
# TBD: Complete your project procedures
# Needed skeleton is given
#####################################################
################
# Implement au_logical
# Argument:
# $a0: First number
# $a1: Second number
# $a2: operation code ('+':add, '-':sub, '*':mul, '/':div)
# Return:
# $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1)
# $v1: ($a0 * $a1):HI | ($a0 % $a1)
# Notes:
#####################################################
################
au_logical:
# TBD: Complete it
# store frame
addi $sp, $sp, -16
sw $fp, 16($sp)
sw $ra, 12($sp)
sw $a2, 8($sp)
addi $fp, $sp, 16
operation_check:
beq $a2, '+', add_logical
beq $a2, '-', sub_logical
beq $a2, '*', mult_logical
beq $a2, '/', div_logical
j logical_end
add_logical:
li $a2, 0x0
jal add_sub_logical
j logical_end
sub_logical:
li $a2, 0xFFFFFFFF
jal add_sub_logical
j logical_end
mult_logical:
jal mult_signed
j logical_end
div_logical:
jal div_signed
logical_end:
lw $fp, 16($sp)
lw $ra, 12($sp)
lw $a2, 8($sp)
addi $sp, $sp, 16
jr $ra
add_sub_logical:
addi $sp, $sp, -20
sw $fp, 20($sp)
sw $ra, 16($sp)
sw $s0, 12($sp)
sw $a1, 8($sp)
addi $fp, $sp, 20
# start from
li $t0, 0x0
li $s0, 0x0
take_nth_bit($t1, $a2, $t0)
beq $t1, 0x0, add_steps
nor $a1, $a1, $0
add_steps:
# if I = 32, jump to the end
beq $t0, 0x20, add_sub_logical_end
take_nth_bit($t2, $a0, $t0)
take_nth_bit($t3, $a1, $t0)
xor $t4, $t2, $t3
xor $t5, $t1, $t4
and $t6, $t1, $t4
and $t7, $t2, $t3
or $t1, $t6, $t7 # change C to CO
put_value_to_nth_bit($s0, $t0, $t5, $t8)
# I = I + 1
addi $t0, $t0, 0x1
j add_steps
add_sub_logical_end:
move $v0, $s0
move $v1, $t1
lw $fp, 20($sp)
lw $ra, 16($sp)
lw $s0, 12($sp)
lw $a1, 8($sp)
addi $sp, $sp, 20
jr $ra
mult_unsigned:
addi $sp, $sp, -40
sw $fp, 40($sp)
sw $ra, 36($sp)
sw $s0, 32($sp)
sw $s1, 28($sp)
sw $s2, 24($sp)
sw $s3, 20($sp)
sw $a0, 16($sp)
sw $a1, 12($sp)
sw $a2, 8($sp)
addi $fp, $sp, 40
li $s0, 0x0
li $s1, 0x0
la $s2, 0($a1)
la $s3, 0($a0)
add_loop:
take_nth_bit($t4, $s2, $zero)
la $t5, 0($a0)
la $a0, 0($t4)
jal bit_repeat
la $t4, 0($v0)
and $t7, $s3, $t4
la $a0, 0($s1)
la $a1, 0($t7)
li $a2, '+'
jal au_logical
la $s1, 0($v0)
li $t6, 0x1
li $t4, 0x1f
srlv $s2, $s2, $t6
take_nth_bit($t8, $s1, $zero)
put_value_to_nth_bit($s2, $t4, $t8, $t9)
srlv $s1, $s1, $t6
addi $s0, $s0, 0x1
beq $s0, 0x20, mult_unsigned_end
j add_loop
mult_unsigned_end:
move $v0, $s2
move $v1, $s1
lw $fp, 40($sp)
lw $ra, 36($sp)
lw $s0, 32($sp)
lw $s1, 28($sp)
lw $s2, 24($sp)
lw $s3, 20($sp)
lw $a0, 16($sp)
lw $a1, 12($sp)
lw $a2, 8($sp)
addi $sp, $sp, 40
jr $ra
mult_signed:
addi $sp, $sp, -44
sw $s1, 44($sp)
sw $s0, 40($sp)
sw $s7, 36($sp)
sw $fp, 32($sp)
sw $ra, 28($sp)
sw $s4, 24($sp)
sw $s5, 20($sp)
sw $s6, 16($sp)
sw $a0, 12($sp)
sw $a1, 8($sp)
addi $fp, $sp, 44
# start from
la $s4, 0($a0) # begin with N1
la $s5, 0($a1) # begin with N2
jal twos_complement_add
la $s7, 0($v0)
la $a0, 0($a1)
jal twos_complement_add
la $a1, 0($v0)
la $a0, 0($s7)
jal mult_unsigned
addi $t7, $zero, 31
take_nth_bit($s1, $s4, $t7)
take_nth_bit($s0, $s5, $t7)
xor $s6, $s1, $s0
bne $s6, 1, mult_signed_end
move $a0, $v0
move $a1, $v1
jal twos_complement_64bit
mult_signed_end:
lw $s1, 44($sp)
lw $s0, 40($sp)
lw $s7, 36($sp)
lw $fp, 32($sp)
lw $ra, 28($sp)
lw $s4, 24($sp)
lw $s5, 20($sp)
lw $s6, 16($sp)
lw $a0, 12($sp)
lw $a1, 8($sp)
addi $sp, $sp, 44
jr $ra
twos_complement_add:
# store frame
addi $sp, $sp, -16
sw $fp, 16($sp)
sw $ra, 12($sp)
sw $a0, 8($sp)
addi $fp, $sp, 16
# start from
move $v0 , $a0
bge $a0, 0x0, twos_complement_end
jal twos_complement
twos_complement_end:
# restore frame
lw $fp, 16($sp)
lw $ra, 12($sp)
lw $a0, 8($sp)
addi $sp, $sp, 16
jr $ra
twos_complement:
# store frame
addi $sp, $sp, -24
sw $fp, 24($sp)
sw $ra, 20($sp)
sw $a0, 16($sp)
sw $a1, 12($sp)
sw $a2, 8($sp)
addi $fp, $sp, 24
# begin
nor $a0, $a0, $zero # $a0 = ~$a0
addi $a1, $zero, 1 # $a1 = 1
li $a2, '+'
jal au_logical # adding ~$a0 and 1
# restore frame
lw $fp, 24($sp)
lw $ra, 20($sp)
lw $a0, 16($sp)
lw $a1, 12($sp)
lw $a2, 8($sp)
addi $sp, $sp, 24
jr $ra
bit_repeat:
# store frame
addi $sp, $sp, -16
sw $fp, 16($sp)
sw $ra, 12($sp)
sw $a0, 8($sp)
addi $fp, $sp, 16
# begin
beq $a0, 0x0, repeat_zero
li $t0, 0xFFFFFFFF # if !zero
j bit_repeat_end
repeat_zero:
li $t0, 0x0
bit_repeat_end:
move $v0, $t0 # return value
# restore frame
lw $fp, 16($sp)
lw $ra, 12($sp)
lw $a0, 8($sp)
addi $sp, $sp, 16
jr $ra
twos_complement_64bit:
# store frame
addi $sp, $sp, -28
sw $s0, 28($sp)
sw $fp, 24($sp)
sw $ra, 20($sp)
sw $a0, 16($sp)
sw $a1, 12($sp)
sw $a2, 8($sp)
addi $fp, $sp, 28
# begin
nor $a0, $a0, $zero
nor $a1, $a1, $zero
la $s0, 0($a1)
addi $a1, $zero, 1
li $a2, '+'
jal au_logical
la $a1, 0($s0) # move s0 back to a1
la $s0, 0($v0)
la $a0, 0($v1)
li $a2, '+'
jal au_logical
move $v1, $v0 # high
move $v0, $s0 # low
twos_complement_64bit_end:
# restore frame
lw $s0, 28($sp)
lw $fp, 24($sp)
lw $ra, 20($sp)
lw $a0, 16($sp)
lw $a1, 12($sp)
lw $a2, 8($sp)
addi $sp, $sp, 28
jr $ra
div_unsigned:
# store the frame
addi $sp, $sp, -40
sw $s5, 40($sp)
sw $s2, 36($sp)
sw $s7, 32($sp)
sw $fp, 28($sp)
sw $ra, 24($sp)
sw $a0, 20($sp)
sw $a2, 16($sp)
sw $s0, 12($sp)
sw $s1, 8($sp)
addi $fp, $sp, 40
# start from
li $s7, 0x0 # s7 = I = 0
li $s2, 0x0
la $s0, 0($a0) # original values
la $s1, 0($a1)
div_loop:
li $t3, 0x1
sllv $s2, $s2, $t3
li $t3, 0x1f
take_nth_bit($t4, $s0, $t3)
put_value_to_nth_bit($s2, $zero, $t4, $t5)
li $t3, 0x1
sllv $s0, $s0, $t3
la $t6, 0($a0)
la $a0, 0($s2) # move R to a0
li $a2, '-'
jal au_logical
la $s2, 0($a0)
la $a0, 0($t6)
la $s5, 0($v0) # S = R - D
bge $s5, $zero, intermediate_label
div_loop_part2:
addi $s7, $s7, 0x1
addi $t3, $zero, 32
beq $s7, 32, div_unsigned_end
j div_loop
intermediate_label:
move $s2, $s5 # R = S
addi $t3, $zero, 1 # t3 = 1
put_value_to_nth_bit($s0, $zero, $t3, $t6) # Q[0] = 1
j div_loop_part2
div_unsigned_end:
move $v0, $s0
move $v1, $s2 #remainder
# restore the frame
lw $s5, 40($sp)
lw $s2, 36($sp)
lw $s7, 32($sp)
lw $fp, 28($sp)
lw $ra, 24($sp)
lw $a0, 20($sp)
lw $a2, 16($sp)
lw $s0, 12($sp)
lw $s1, 8($sp)
addi $sp, $sp, 40
jr $ra
div_signed:
# store frame
addi $sp, $sp, -48
sw $s5, 48($sp)
sw $s6, 44($sp)
sw $s7, 40($sp)
sw $s3, 36($sp)
sw $s2, 32($sp)
sw $s1, 28($sp)
sw $s0, 24($sp)
sw $fp, 20($sp)
sw $ra, 16($sp)
sw $a0, 12($sp)
sw $a1, 8($sp)
addi $fp, $sp, 48
la $s0, 0($a0) # a0 begin
la $s1, 0($a1) # a1 begin
jal twos_complement_add
la $s2, 0($v0)
la $a0, 0($s1)
jal twos_complement_add
la $a1, 0($v0)
la $a0, 0($s2)
jal div_unsigned
la $s2, 0($v0)
la $s3, 0($v1)
li $t4, 0x1f
take_nth_bit($s5, $s0, $t4)
take_nth_bit($s6, $s1, $t4)
xor $s7, $s5, $s6
bne $s7, 1, find_sign_to_R
la $a0, 0($s2)
jal twos_complement
la $s2, 0($v0)
find_sign_to_R:
la $s7, 0($s5)
bne $s7, 1, div_signed_end
la $a0, 0($s3)
jal twos_complement
la $s3, 0($v0)
div_signed_end:
move $v0, $s2
move $v1, $s3
lw $s5, 48($sp)
lw $s6, 44($sp)
lw $s7, 40($sp)
lw $s3, 36($sp)
lw $s2, 32($sp)
lw $s1, 28($sp)
lw $s0, 24($sp)
lw $fp, 20($sp)
lw $ra, 16($sp)
lw $a0, 12($sp)
lw $a1, 8($sp)
addi $sp, $sp, 48
jr $ra
__MACOSX/cs47_proj_source/._CS47_proj_alu_logical.asm
CS47 Section 01
Abstract—This work thoroughly explains the implementation
of a basic calculator through digital logic in the MIPS assembly
language. The paper first describes the software and knowledge
needed to understand the design and implementation of the
calculator. The paper then describes the upper level design of
the
implementation followed by details on the actual
implementation
of the program. Code snippets are provided to provide a better
understanding of the program. The program is tested with a pre-
written test file which compares the calculator's results with
MIPS arithmetic instruction sets.
I. INTRODUCTION
he use of logical operators to calculate expressions is a
fundamental concept that serves as the foundation for
digital circuits. To understand how digital logic can be used to
carry out basic arithmetic, the objective of this project is to
implement a basic calculator mainly through the use of logical
operators. Functions supported by the calculator include the
addition, subtraction, multiplication, and division of two
integers.
The calculator is written in MIPS (microprocessor without
Interlocked Pipeline Stages), which is one of many types of
assembly language. The software used to simulate a MIPS
environment and write the implementation is MARS (MIPS
Assembler and Runtime Simulator), an IDE developed and
released by Missouri State University.
II. REQUIREMENTS
This sections describes both the software required to
implement the calculator as well as the preliminary knowledge
to understand the design and implementation of the calculator.
A. Software Requirements
To simulate the runtime environment of the MIPS assembly
language, the software MARS is used as an IDE. MARS
simulates the runtime environment and execution of MIPS
without needing to operate in a low-level environment, as well
as providing the same instruction sets and pseudo-instruction
sets for use. Note that since MARS is written in Java, the user
will require an installation of Java on the work station.
Once MARS is launched, some settings will have to change
for the program to run correctly. Under Settings, select
"Initialize Program Counter to global 'main' if defined." The
three files required for the calculator are
cs_47_proj_macros.asm," cs_47_proj_procs.asm, and proj-
auto_test.asm.
B. Knowledge of Boolean Logic and Binary System
The following subsections describe the preliminary
concepts required to implement the logical calculator.
1) Boolean Logic
The implementation of digital logic requires a solid
understanding of both Boolean logic and binary arithmetic. In
digital circuits, the expressions true and false are represented
as a 1 or 0 respectively. From here, truth tables are constructed
to determine the output of a Boolean expression given two
truth values.
The AND operation will essentially return 0 if its two inputs
are neither 1. Table I illustrates the output of the AND
operation given two inputs.
TABLE I
TRUTH TABLE FOR LOGICAL AND
A B A.B
0 0 0
0 1 0
1 0 0
1 1 1
The OR operation will essentially return 0 only if its two
inputs are both 0. Table II illustrates the output of the OR
operation given two inputs.
TABLE II
TRUTH TABLE FOR LOGICAL OR
A B A+B
0 0 0
0 1 1
1 0 1
1 1 1
Implementation of a Basic Calculator through
Digital Logic in MIPS
FirstName LastName, Computer Scientist, San Jose State
University
T
CS47 Section 01
The XOR operation will return 0 if its two inputs match, and
will return 1 if its two inputs do not match. Table III illustrates
the output of the XOR operation given two inputs.
TABLE III
TRUTH TABLE FOR LOGICAL XOR
A B A ⊕B
0 0 0
0 1 1
1 0 1
1 1 0
2) Binary System
A number with a counting base of two is known as a binary
number. Typically, the alphabet consists of 0 and 1, symbols
which conveniently coincide with the expressions of Boolean
logic. In the counting system, a digits place will count to 1
before “rolling over” the digit to the next higher place. For
example in the base 10 system, the next digit after 9 will roll
over to form 10, 19 will roll over to form 20, and 99 will roll
over to form 100. In binary, 1 is represented as 1, which rolls
over to 10 when incremented to 2.
Elementary hand-paper arithmetic algorithms work for both
base 10 and base 2 systems. Moreover, inputs that are
equivalent in both systems will yield an output that are
equivalent as well. This fact can be used to ensure that the
program produces correct outputs.
In computers, integers are represented with binary. To
distinguish between negative and positive numbers, the most
significant bit determines the sign of the number. As an
example, the number 2 represented with 6 bits would be
000010 while -2 would be 111110. To convert between a
number and its complement (assuming the number is in range
of its signed counterpart), invert the bits and add 1 to the
number.
III. DESIGN AND IMPLEMENTATION
The following section describes the design and
implementation of the logical calculator. The operators
implemented by the calculator and described by the paper are
addition, subtraction, multiplication, and division.
A. Design of Calculator
This subsection describes the design of the basic operations
of the calculator.
1) Addition and Subtraction
The design of the addition and subtraction implementation
is lumped together because of the similarities of the operation.
In fact, the subtraction operation is simply the addition
operation with the second input complemented to form its
negated counterpart.
The addition logic involves performing logical operations to
determine the digit of the final output as well as a “carry bit”
to carry over the number for the next logical operation. These
operations are performed 32 times (the number of bits
available in a register).
To determine the nth digit of the final output, the logical
XOR operation is performed on the nth digits of the first and
second inputs as well as the carry bit. The carry bit is
initialized to 0, and is calculated by taking the OR operation of
the AND of the nth digits of the two inputs with the AND
operation of the current carry bit value and XOR operation
with the nth digits of the inputs. The figure below illustrates
the logical equations formally.
Once the operations are performed 32 times (once for each
bit in the registers), the procedure ends. Note that there is a
possibility that the carry bit is not carried over if the
operations are performed 32 times. In this case, the overflow
can be stored in another register to return.
For subtraction, simply find the complement of the second
input before performing the procedure.
2) Multiplication
The unsigned multiplication logic involves creating a mask
from the least significant bit of the current multiplier, using
the mask on the multiplicand and adding the result to the final
output (initialized to 0).
The mask is created by replicating the first bit of the current
multiplier. If the bit is 0, the mask is 0; if the bit is 1, the mask
is -1. The mask and the multiplicand are AND together and
added to a hi counter. The multiplier and hi counter are shifted
to the left by 1, with the hi counter’s dropped off bit inserted
into the multiplier’s most significant bit. These operations are
performed 32 times to receive the final output (in place of
multiplier).
For signed multiplication, the multiplier and multiplicand
are made positive if either are negative and the unsigned
multiplication is performed. The final sign is determined by
performing the XOR operation on the most significant bits,
and complementing the results of the unsigned multiplication
if the sign value is 1.
3) Division
The unsigned division logic first shifts the remainder
(initialized to 0) to the left, grabbing the most significant bit
from the current dividend storing the bit in the least significant
bit in the remainder. The dividend is then shifted to the left.
The divisor is then subtracted from the remainder value. If
the result is more than or equal to 0, the remainder is made to
equal the result, and the bit 1 is inserted in the dividend’s least
significant bit. If the result is less than 0, the loop simply
continues. Once the steps are performed 32 times, the
operation ends with the quotient stored in the dividend’s place.
For signed division, the sign of the quotient is determined
similarly as the product’s sign was determined in the signed
CS47 Section 01
multiplication logic. The sign of the remainder is determined
by checking the most significant bit of the dividend. If the sign
is 1, complement the remainder.
B. Implementation Details
Before the logical calculator operations can be implemented
through MIPS, and handful of utility procedures and macroes
are defined to assist in the implementation.
1) Utility Macroes
The additional macroes defined in the program are
extract_nth_bit, insert_to_nth_bit, store_stack, and load_stack.
i. Extract_nth_bit
Extract_nth_bit returns the bit value of a given position for
a given number.
The defined macro takes three arguments in the following
order: the register to store the result, register containing source
bit pattern, and register holding the value of the bit position.
The macro functions by shifting the source bit pattern by
the bit position number, moving the desired bit to the least
significant bit position. From there, AND is called with 1 to
extract the desired bit and stored.
ii. Insert_to_nth_bit
Insert_to_nth_bit loads a given bit value into the nth position
of a value and returns it.
The defined macro takes four arguments in the following
order: register of the bit pattern in which to insert to, register
containing the position in which to insert, register containing
the value to insert (0 or 1), and a temporary register to create a
mask.
The macro functions first by setting the mask value to 1.
The mask is then shifted to the left by n. The OR operation is
then called with the mask and -1 to invert its bits. Once done,
AND is called on the mask and the bit pattern in which to
modify. The bit to insert is then shifted left by n and OR is
called with the bit pattern.
iii. Store_stack and load_stack
The purpose of these two functions is to simply store and
load the proper registers on call. They take no arguments and
will store/load the registers listed regardless of whether they
were used or not. Though the proper use of the stack involves
storing and loading only the registers that are used, macroes
were defined to cut down on the number of lines in the code
and increase readability. Specifically, the registers stored and
loaded are $fp, $ra, $a0-$a3, and $s0-$s7.
2) Utility Procedures
i. twos_complement and twos_complement_if_neg
Twos_complement takes an argument in $a0 and returns its
complement in $v0.
The complement is calculated by calling XOR on the
argument and -1. Add_logical is then called to add the XOR’d
result and 1.
Twos_complement_if_neg will return the argument if it is
more than 0, and branch to twos_complement if the argument
is less than 0.
ii. Twos_complement_64bit
This procedure takes the lo and hi values as arguments from
the results mul_unsigned and returns the complement of the
two.
First, both the arguments are inverted by calling XOR and
-1. The inverted lo value and 1 is passed into the add_logical
function, which returns the complemented lo value in $v0, and
the overflowed carry bit in $v1. This bit is then added to the
inverted hi to get its complement. The complemented lo and hi
are returned in $v0 and $v1 respectively.
iii. bit_replicator and replicate
#$regD contains 0 or 1 depending on nth bit 0
or 1
#$regS source bit pattern
#$regT bit position
<CODE REMOVED>
#$regD bit pattern in which to insert to
#$regS position of bit to insert (0-31)
#$regT register containing 0 or 1 to insert
#$maskReg register to hold mask
.macro insert_to_nth_bit($regD, $regS, $regT,
$maskReg)
<CODE REMOVED>
.end_macro
twos_complement:
<CODE REMOVED>
twos_complement_if_neg:
<CODE REMOVED>
bit_replicator:
<CODE REMOVED>
replicate:
<CODE REMOVED>
CS47 Section 01
These two procedures assist in “replicating” a given bit to
occupy all 32 registers.
Bit_replicator will take an argument in $a0 and return 0 in
$v0 if the argument is 0. The argument will branch to replicate
if the argument is 1.
For replicate, the procedure simply returns -1 in $v0.
iv. Exit
This procedure will simply call the load_stack macro and
jump back to the return address. The procedure is called after
the end of a calculator operation.
3) Addition/Subtraction Implementation
i. add_logical / sub_logical
Initially, the carry bit, final sum, and index are initialized to
0 in add_logical. For sub_logical, the first argument is stored,
and the second argument is moved to $a0 to be complemented
with the twos_complement procedure. The arguments are
moved back to place and the proper variables are initialized.
From here, both procedures jump to add_loop.
ii. add_loop
The add_loop function will logically calculate the sum of
the two inputs in $a0 and $a1. The loop first checks if the
counter is equal to 32. If not, the procedure will call macroes
to extract the nth position of the argument. Using the XOR
operation, the sum bit is calculated. The carry bit is also
calculated and stored in $v1. Afterward, the insert macro is
called to place the sum bit into its proper place in $v0. Finally,
the index is incremented by 1 and the procedure jumps to
itself. Once the index equals 32, the procedure branches to the
exit procedure and returns to the calling procedure.
4) Multiplication Implementation
i. mul_logical
The arguments are initially stored twice to free space for the
complement procedure and to check for the sign in the later
procedure. The two arguments are checked and complemented
if negative. From here, the results are passed into the argument
registers and mul_unsigned is called.
ii. mul_unsigned
The procedure initializes the index, the hi counter, and
stores the arguments. The multiplicand is stored in $s4 while
the multiplier is stored in $s5. The procedure then calls
mul_loop
add_logical:
<CODE REMOVED>
sub_logical:
<CODE REMOVED>
<CODE REMOVED>
add_loop:
<CODE REMOVED>
add_loop:
beq $t0, 32, exit
#grabbing a[i] bits of $a0 and $a1
#stored in $t2 and $t3 respectively
extract_nth_bit($t2, $a0, $t0)
extract_nth_bit($t3, $a1, $t0)
#calculate bit value of y through xor
operations
xor $s1, $t2, $t3 #xor bits a0[i] and
a1[i]
xor $s2, $s1, $s0 #xor carry-in bits
with previous sum
#calculate bit value of carry-out
and $s4, $t2, $t3 #a and b
and $s0, $s0, $s1 #carry bit and (a
xor b)
or $s0, $s0, $s4
la $v1, ($s0)
insert_to_nth_bit($v0, $t0, $s2, $t7)
addi $t0, $t0, 1
j add_loop
mul_logical:
<CODE REMOVED>
CS47 Section 01
iii. mul_loop
The loop initially checks to see if the index is equal to 32.
Then the procedure extracts the first bit of the multiplier,
which is then replicated after loaded into $a0. The result of the
replicator and the multiplicand are ANDed together and stored
into $s7. The current hi counter value and $s7 are loaded into
arguments and add_logical is called.
The result of the add_logical is moved back to the hi
counter. The multiplier is then shifted to the right, while the
least significant bit of the hi counter is extracted and inserted
into the most significant bit of the multiplier. The hi counter is
then shifted to the right. The results of the lo (corresponding
with the multiplier’s register) and hi counter are stored in $v0
and $v1 respectively. Finally, the index is incremented and the
procedure calls itself.
Once the index reaches 32, mul_signed is called to place the
appropriate signs.
iv. mul_signed
The purpose of mul_signed is to ensure that the final
product contains the right sign after the unsigned procedure is
called. Recall that mul_logical stored the original arguments
and complemented the arguments if either were negative.
Here, the most significant bits of both the multiplier and
multiplicand are extracted with the macro and XOR’d together
to receive the sign. If the sign is 0, the procedure calls exit. If
the sign is not 0, the lo and hi results of mul_loop are loaded
into the argument variables and passed into the procedure
twos_complement_64bit. Afterward, the procedure exits.
5) Division Implementation
<CODE REMOVED>
div_logical:
<CODE REMOVED>
CS47 Section 01
i. div_logical
Much like mul_logical, the arguments are stored twice and
complemented if negative. Afterward, the arguments,
complemented or otherwise, are loaded into argument
registers. The procedure div_unsigned is called.
ii. div_unsigned
The index and remainder registers are initialized to 0. The
dividend and divisor are stored and div_loop is called.
div_loop and branch
The procedure first branches if the index is equal to 32. The
remainder is then shifted to the left by 1. The extract macro is
called on the 0
th
position of the dividend and inserted into the
new position of the remainder variable with the insert macro.
The dividend is the shifted to the left.
The remainder and divisor are loaded into $a0 and $a1
respectively and sub_logical is called. The result is then
moved into $s2. A branch is called if the subtraction result
(stored in $s2)is greater than or equal to 0. If the value of $s2
greater than or equal to 0, the remainder is assigned the value
of $s2, and the bit 1 is inserted into the first bit of the divisor.
If $s2 is less than 0, the branch is not called. In either case,
the index is incremented by one. The quotient (corresponding
with the dividend) and remainder are loaded into $v0 and $v1
respectively.
Once the index is equal to 32, div_signed is called to handle
the signs of the quotient and remainder.
iii. div_signed, signed_quotient, and signed_remainder
These procedure handles the signs of the remainder and
quotient.
Div_signed first stores the results of the div_loop procedure.
The procedure then extracts the 31
st
bits of both the dividend
and divisor and store the results in $s2 and $s3 respectively.
$s2 and $s3 are then XOR’d and the sign is then stored in $s4.
The procedure the branches depending on whether the
quotient or remainder needs to be complemented. If $s4 is not
equal to 0, the procedure calls signed_quotient. If $s2 (first bit
of dividend) is not equal to 0, the procedure calls
signed_remainder. Otherwise, the procedure exits.
In signed_quotient, the quotient (stored in $s6 by
div_signed) is passed into $a0 and twos_complement is called.
The result is re-stored in $s6. If $s2 is not equal to 0, the
procedure will call signed_remainder. Otherwise, the result of
the complement and remainder is loaded into $v0 and $v1 and
the procedure exits.
In signed_remainder, the remainder (stored in $s7 by,
div_signed) is passed into $a0 and twos_complement is called.
The result of the complement and the quotient are loaded into
$v1, and $v0 respectively.
IV. TESTING
To test that the calculator’s procedures operate correctly,
control procedures are written using MIPS’s inbuilt arithmetic
instructions. The procedure au_normal is written to parse the
input and call the respective instruction.
div_loop:
<CODE REMOVED>
au_normal:
store_stack
beq $a2, '+' , add_normal
beq $a2, '-' , sub_normal
beq $a2, '*' , mul_normal
beq $a2, '/' , div_normal
add_normal:
add $v0, $a0, $a1
j exit
sub_normal:
sub $v0, $a0, $a1
j exit
mul_normal:
mul $v0, $a0, $a1
mfhi $v1
j exit
div_normal:
CS47 Section 01
A. Testing Implementation
1) Add_normal and sub_normal
Add_normal and sub_normal will call MIPS instructions
add and sub respectively. The arguments are passed into the
parameters and the result is stored in $v0.
2) Mul_normal
Mul_normal will call the instruction mul and store the
results in $v0. The hi result of the instruction is moved from
the hi counter to $v1.
3) Div_normal
Div_normal will call the instruction div, which stores the
results in the quotient in the lo counter and remainder in the hi
counter. These results are moved to $v0 and $v1 respectively.
B. Proj-auto-test
An assembly file was written and provided to easily test
that the calculator operations work as expected. The file
provides sample inputs and matches the results of
au_normal with au_logical to ensure that the outputs are
correct. The snippet above is a sample of the output of
this test.
V. CONCLUSION
The objective of this project was to implement a basic
calculator through the use of logical operators. The project
provided insight on how digital circuits operate and how the
logic behind the circuits are implemented. The program was
written using the MIPS assembly language and tested with a
provided testing file which matched the outputs of the logical
calculator operations with the MIPS arithmetic instruction set.
Next possible steps include implementing more complex
expressions such as exponentiation, square rooting, decimal
calculations, and more.
(4 + 2) normal=> 6 logcal=> 6 [matched]
(4 - 2) normal=> 2 logcal=> 2 [matched]
(4 * 2) normal=> HI:0 LO:8 logical=> HI:0 LO:8
[matched]
(4 / 2) normal=> R:0 Q:2 logical=> R:0 Q:2
[matched]
(16 + -3) normal=> 13 logcal=> 13 [matched]
(16 - -3) normal=> 19 logcal=> 19 [matched]
(16 * -3) normal=> HI:-1 LO:-48 logical=> HI:-1
LO:-48 [matched]
(16 / -3) normal=> R:1 Q:-5 logical=> R:1 Q:-5
[matched]
(-13 + 5) normal=> -8 logcal=> -8 [matched]
(-13 - 5) normal=> -18 logcal=> -18 [matched]
(-13 * 5) normal=> HI:-1 LO:-65 logical=> HI:-1
LO:-65 [matched]
(-13 / 5) normal=> R:-3 Q:-2 logical=> R:-3 Q:-2
[matched]
(-2 + -8) normal=> -10 logcal=> -10 [matched]
.
.
.
.
.
.
.
(-19 / 3) normal=> R:-1 Q:-6 logical=> R:-1
Q:-6 [matched]
(4 + 3) normal=> 7 logcal=> 7 [matched]
(4 - 3) normal=> 1 logcal=> 1 [matched]
(4 * 3) normal=> HI:0 LO:12 logical=> HI:0
LO:12 [matched]
(4 / 3) normal=> R:1 Q:1 logical=> R:1 Q:1
[matched]
(-26 + -64) normal=> -90 logcal=> -90
[matched]
(-26 - -64) normal=> 38 logcal=> 38
[matched]
(-26 * -64) normal=> HI:0 LO:1664 logical=> HI:0
LO:1664 [matched]
(-26 / -64) normal=> R:-26 Q:0 logical=> R:-26
Q:0 [matched]
Total passed 40 / 40
*** OVERALL RESULT PASS ***
-- program is finished running --
Report of Arithmetic Implemented By MIPS
XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE
Abstract—This cs47 report is about by using MIPS language
and logical procedures, we make the calculation to solve the
operations. This report included diagrams for requirement and
design, code snippet, containing objective and all detailed
screenshot to explain how to get the process for this
project.Introduction (Heading 1)
This project is using MARS simulator environment which is an
assembler of MIPS to perform the calculation of basic
mathematic operation. It is basic on the MPIS logic operation.
The goal of this project is understanding how digital logic can
be used to implement a basic calculator through logical
operators.
This project are operated by the following steps:
1.Open MARS and implement the modules to design the
mathematics operation
2.Complete the procedures and verify each other files
3.Run and compare the results to get correct conclusion
The goal of this project is understand how digital logic can be
used to implement a basic calculator through logical operators.
Prapareation and set up
Praperation: software and file
Download MARS simulator and the file from canvas and unzip
the files to make sure everything be all set.
We use the MARS 4.5 software version and the Link is:
http://courses.missouristate.edu/KenVollmar/mars/
The files download from canvas named CS47ProjectI.zip.
After unzip CS47ProjectI.zip, there are six files by following:
1.cs47_common_macro.asm
This has all important macros required for test.
2.cs47_proj_alu_logical.asm
This need to be implemented for all logical arithmetic
procedures.
3.cs47_proj_alu_normal.asm
This need to be implemented for all normal arithmetic
procedures.
4.cs47_proj_macro.asm
This includes the macro which required during calculating
5.cs47_proj_procs.asm
This includes all print procedures.
6.proj-auto-text.asm
This used to text if the arithmetic modules get correct.
Fig1: the files after unzipping
Open six files by MARS
1. open Mars and click File to implement these six files
Fig2: to open files
Fig3: find the files and open
Adjustment MARS enveriment
Fig4: Turn on them to show the details and to make sure the
files can be successfully executed. aAAAAA
When everything is ready, the much harder part need to be
done which is to see the requirement in every file. Then follow
the requirement to write the code.
Fig: the symbol of each Boolean algebraic operation.
In cs47_proj_alu_logical.asm, all logical operations are put
in there to calculate the mathematical operations in logical.
Such as XNOR, NAND, NOT, NOR, AND and OR.
Fig: there are 3 kinds of arguments (a0, a1, a2) and 2 kinds of
returns(v0,v1).
In cs47_proj_alu_normal.asm, all normal arithmetic
operations are included in there, such as ADD, SUBTRACT,
DIVIDE and MULTIPLY.
Fig: there are 3 kinds of arguments (a0, a1, a2) and 2 kinds of
returns(v0,v1)Which is the same as cs47_proj_alu_logical.asm.
Then explain the mean of each register.
1.Register $a0: the first operand in calculation
2.Register $a1: the second operand in calculation
3.Register $a2: the operator in calculation. which are symbols
represented to ‘+’, ‘-’, ‘*’, ‘/’.
a. when $a2 represented to ‘+’, the procedure need to jump the
addition section. Cause add means the sum of two operations.
b. when $a2 represented to ‘-’, the procedure need to jump the
subtraction section. Cause subtract means the difference of two
operations.
c. when $a2 represented to ‘*’, the procedure needs to jump the
multiplication section. Cause subtract means the product of two
operations.
d. when $a2 represented to ‘/’, the procedure needs to jump the
division section. Cause subtract means the quotient of two
operations.
4.Register $v0: a storage, to store the result from addition and
subtraction.
5.Register $v1: different multiplication has different means.
When multiplication, it contains hi; when division, it contains
remainder.
Fig: implementation of cs47_proj_alu_normal.asm
Next, back to logical.asm, it was the logical arithmetic
procedure. It calculates every mathematical procedure by
logical operation. Also, it needs the basic logical procedure
which is similar to the normal.asm.
Consider restoring the results that other register cannot
change except $v0 and $v1:
Also, the same operation should be done when we want to do
more. Therefore, shift $sp back to the place that it stay before.
Now explain every procedure during calculation.
For example: ADD
In this method, is the sum of two registers for $a0 and $a1. $a2
is the operator on the calculation: ‘+’.
Fig: the truth table and basic identifies
Write begain there
Transl. J. Magn. Japan, vol. 2, pp. 740–741, August 1987
[Digests 9th Annual Conf. Magnetics Japan, p. 301, 1982].
M. Young, The Technical Writer’s Handbook. Mill Valley, CA:
University Science, 1989.
IEEE conference
We suggest that you use a text box to insert a graphic (which is
ideally a 300 dpi TIFF or EPS file, with all fonts embedded)
because, in an MSW document, this method is somewhat more
stable than directly inserting a picture.
To have non-visible rules on your frame, use the MSWord
“Format” pull-down menu, select Text Box > Colors and Lines
to choose No Fill and No Line.
CS47ProjectI/cs47_common_macro.asm
# ***** DO NOT MODIFY THIS FILE **** #
#<------------------ MACRO DEFINITIONS ----------------------
>#
# Macro : print_str
# Usage: print_str(<address of the string>)
.macro print_str($arg)
li $v0, 4 # System call code for print_str
la $a0, $arg # Address of the string to print
syscall # Print the string
.end_macro
# Macro : print_int
# Usage: print_int(<val>)
.macro print_int($arg)
li $v0, 1 # System call code for print_int
li $a0, $arg # Integer to print
syscall # Print the integer
.end_macro
# Macro : exit
# Usage: exit
.macro exit
li $v0, 10
syscall
.end_macro
# Macro: read_int
# Usage: read_int(<reg>)
.macro read_int($arg)
li $v0,5 # Read intger
syscall
move $arg, $v0 # move the data to target reg
.end_macro
# Macro: print_reg_int
# Usage: print_reg_int(<reg>)
.macro print_reg_int ($arg)
li $v0, 1 # print_int call
move $a0, $arg # move the source reg value to $a0
syscall
.end_macro
# Macro: lwi
# Usage: lwi (<reg>, <upper imm>, <lower imm>)
.macro lwi ($reg, $ui, $li)
lui $reg, $ui
ori $reg, $reg, $li
.end_macro
# Macro: push
# Usage: push (<reg>)
.macro push($reg)
sw $reg, 0x0($sp) # M[$sp] = R[reg]
addi $sp, $sp, -4 # R[sp] = R[sp] - 4
.end_macro
# Macro: push
# Usage: push (<reg>)
.macro pop($reg)
addi $sp, $sp, +4 # R[sp] = R[sp] + 4
lw $reg, 0x0($sp) # M[$sp] = R[reg]
.end_macro
.macro push_var_value($varName)
lw $t0, $varName
push($t0)
.end_macro
.macro push_var_address($varName)
la $t0, $varName
push($t0)
.end_macro
.macro call_printf($format)
la $a0, $format
jal printf
.end_macro
CS47ProjectI/CS47_proj_alu_logical.asm
.include "./cs47_proj_macro.asm"
.text
.globl au_logical
# TBD: Complete your project procedures
# Needed skeleton is given
#####################################################
################
# Implement au_logical
# Argument:
# $a0: First number
# $a1: Second number
# $a2: operation code ('+':add, '-':sub, '*':mul, '/':div)
# Return:
# $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1)
# $v1: ($a0 * $a1):HI | ($a0 % $a1)
# Notes:
#####################################################
################
au_logical:
# TBD: Complete it
jr $ra
CS47ProjectI/CS47_proj_alu_normal.asm
.include "./cs47_proj_macro.asm"
.text
.globl au_normal
# TBD: Complete your project procedures
# Needed skeleton is given
#####################################################
################
# Implement au_normal
# Argument:
# $a0: First number
# $a1: Second number
# $a2: operation code ('+':add, '-':sub, '*':mul, '/':div)
# Return:
# $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1)
# $v1: ($a0 * $a1):HI | ($a0 % $a1)
# Notes:
#####################################################
################
au_normal:
# TBD: Complete it
jr $ra
CS47ProjectI/cs47_proj_macro.asm
# Add you macro definition here - do not touch
cs47_common_macro.asm"
#<------------------ MACRO DEFINITIONS ----------------------
>#
CS47ProjectI/cs47_proj_procs.asm
# ***** DO NOT MODIFY THIS FILE **** #
.include "./cs47_common_macro.asm"
.text
.globl printf
#-----------------------------------------------
# C style signature 'printf(<format string>,<arg1>,
# <arg2>, ... , <argn>)'
#
# This routine supports %s and %d only
#
# Argument: $a0, address to the format string
# All other addresses / values goes into stack
#-----------------------------------------------
printf:
#store RTE - 5 *4 = 20 bytes
addi $sp, $sp, -24
sw $fp, 24($sp)
sw $ra, 20($sp)
sw $a0, 16($sp)
sw $s0, 12($sp)
sw $s1, 8($sp)
addi $fp, $sp, 24
# body
move $s0, $a0 #save the argument
add $s1, $zero, $zero # store argument index
printf_loop:
lbu $a0, 0($s0)
beqz $a0, printf_ret
beq $a0, '%', printf_format
# print the character
li $v0, 11
syscall
j printf_last
printf_format:
addi $s1, $s1, 1 # increase argument index
mul $t0, $s1, 4
add $t0, $t0, $fp # all print type assumes
# the latest argument pointer at $t0
addi $s0, $s0, 1
lbu $a0, 0($s0)
beq $a0, 'd', printf_int
beq $a0, 's', printf_str
beq $a0, 'c', printf_char
printf_int:
lw $a0, 0($t0) # printf_int
li $v0, 1
syscall
j printf_last
printf_str:
lw $a0, 0($t0) # printf_str
li $v0, 4
syscall
j printf_last
printf_char:
lbu $a0, 0($t0)
li $v0, 11
syscall
j printf_last
printf_last:
addi $s0, $s0, 1 # move to next character
j printf_loop
printf_ret:
#restore RTE
lw $fp, 24($sp)
lw $ra, 20($sp)
lw $a0, 16($sp)
lw $s0, 12($sp)
lw $s1, 8($sp)
addi $sp, $sp, 24
jr $ra
CS47ProjectI/proj-auto-test.asm
# ***** DO NOT MODIFY THIS FILE **** #
.include "./cs47_common_macro.asm"
.include "./cs47_proj_macro.asm"
# data section
.data
.align 2
matchMsg: .asciiz "matched"
unmatchMsg: .asciiz "not matched"
charCR: .asciiz "n"
testD: .word 0xffffffff
var0: .word 0x00000000
var1: .word 0x00000000
var2: .word 0x00000000
var3: .word 0x00000000
testV1Arr: .word 4 16 -13 -2 -6 -18 5 -19 4 -26
testV2Arr: .word 2 -3 5 -8 -6 18 -8 3 3 -64
noTest: .word 10
passTest: .word 0
totalTest: .word 0
opList: .byte '/' '*' '-' '+'
testFlag: .word 0x0
as_msg: .asciiz "(%d %c %d) t normal => %d t logical => %d
t [%s]n"
mul_msg: .asciiz "(%d %c %d) t normal => HI:%d LO:%d t
logical => HI:%d LO:%d t [%s]n"
div_msg: .asciiz "(%d %c %d) t normal => R:%d Q:%d t
logical => R:%d Q:%d t [%s]n"
finalMSG: .asciiz "*** OVERALL RESULT %s ***n"
statPASS: .asciiz "PASS"
statFAIL: .asciiz "FAILED"
testStatus: .asciiz "nnTotal passed %d / %dn"
.text
.globl main
#####################################################
################
# Main Program
#####################################################
################
main:
add $s0, $zero, $zero # $s0 = 0 ; used as index
lw $s1, noTest
test_loop:
mul $t0, $s0, 4
# $s3 = testV1Arr[$s0]
la $t1, testV1Arr
add $t1, $t1, $t0
lw $s3, 0($t1)
# $s4 = testV2Arr[$s0]
la $t1, testV2Arr
add $t1, $t1, $t0
lw $s4, 0($t1)
addi $s5, $zero, 4
op_loop:
addi $t0, $s5, -1
la $t1, opList
add $t1, $t1,$t0
lb $s6, 0($t1)
# increase number of tests
lw $t0, totalTest
addi $t0, $t0, 1
sw $t0, totalTest
# normal operation
or $a0, $s3, $zero
or $a1, $s4, $zero
or $a2, $s6, $zero
ori $v0, $zero, 0x0
ori $v1, $zero, 0x1
jal au_normal
sw $v0, var0
sw $v1, var1
# logical operation
or $a0, $s3, $zero
or $a1, $s4, $zero
or $a2, $s6, $zero
ori $v0, $zero, 0x2
ori $v1, $zero, 0x3
jal au_logical
sw $v0, var2
sw $v1, var3
# Set if mul or div
# print the result
lw $t0, var0
lw $t1, var2
bne $t0, $t1, main_mismatch
beq $s6, '*', main_extra_match
beq $s6, '/', main_extra_match
j main_L6
main_extra_match:
lw $t0, var1
lw $t1, var3
bne $t0, $t1, main_mismatch
main_L6:
push_var_address(matchMsg)
lw $t0, passTest
addi $t0, $t0, 1
sw $t0, passTest
j main_L5
main_mismatch:
push_var_address(unmatchMsg)
ori $t0, $zero, 0x1
sw $t0, testFlag
main_L5:
push_var_value(var2)
beq $s6, '*', main_ins_1
beq $s6, '/', main_ins_1
j main_L1
main_ins_1:
push_var_value(var3) # main_ins_1
main_L1:
push_var_value(var0) # main_L1
beq $s6, '*', main_ins_2
beq $s6, '/', main_ins_2
j main_L2
main_ins_2:
push_var_value(var1) # main_ins_2
main_L2:
push($s4) # main_L2
push($s6)
push($s3)
beq $s6, '*', main_print_mul
beq $s6, '/', main_print_div
call_printf(as_msg)
j main_L3
main_print_mul:
call_printf(mul_msg) # main_print_mul
j main_L3
main_print_div:
call_printf(div_msg) # main_print_div
j main_L3
main_L3:
pop($t0) # main_L3
pop($t0)
pop($t0)
pop($t0)
pop($t0)
pop($t0)
beq $s6, '*', main_pop_2
beq $s6, '/', main_pop_2
j main_L4
main_pop_2:
pop($t0)
pop($t0)
main_L4:
addi $s5, $s5, -1 # main_L4
bnez $s5 op_loop
addi $s0, $s0, 1
bne $s0, $s1, test_loop
# Test statistics
lw $t0, totalTest
push($t0)
lw $t0, passTest
push($t0)
call_printf(testStatus)
pop($t0)
pop($t0)
# Final msg
lw $t0, testFlag
beqz $t0, main_pass
push_var_address(statFAIL)
j main_L7
main_pass:
push_var_address(statPASS)
main_L7:
call_printf(finalMSG)
pop($t0)
exit

Más contenido relacionado

Similar a cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx

Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Workhorse Computing
 
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfNeed help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfactexerode
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfWhat is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfbadshetoms
 
How to fixed these provide listsort-asm assembly code as same as the l.pdf
How to fixed these provide listsort-asm assembly code as same as the l.pdfHow to fixed these provide listsort-asm assembly code as same as the l.pdf
How to fixed these provide listsort-asm assembly code as same as the l.pdfThomasXUMParsonsx
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2osfameron
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly LanguageMotaz Saad
 
Calling Functions
Calling FunctionsCalling Functions
Calling FunctionsPat Hawks
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type Systemabrummett
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perltinypigdotcom
 
Laziness in Swift
Laziness in Swift Laziness in Swift
Laziness in Swift SwiftWro
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなしMasahiro Honma
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic trapsDamien Seguy
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giantsIan Barber
 
SAT/SMT solving in Haskell
SAT/SMT solving in HaskellSAT/SMT solving in Haskell
SAT/SMT solving in HaskellMasahiro Sakai
 
Call Return Exploration
Call Return ExplorationCall Return Exploration
Call Return ExplorationPat Hawks
 

Similar a cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx (20)

Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
Neatly Hashing a Tree: FP tree-fold in Perl5 & Perl6
 
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdfNeed help optimizing my code for MIPS- Completely lost on how-what to.pdf
Need help optimizing my code for MIPS- Completely lost on how-what to.pdf
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfWhat is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
 
How to fixed these provide listsort-asm assembly code as same as the l.pdf
How to fixed these provide listsort-asm assembly code as same as the l.pdfHow to fixed these provide listsort-asm assembly code as same as the l.pdf
How to fixed these provide listsort-asm assembly code as same as the l.pdf
 
Data Types Master
Data Types MasterData Types Master
Data Types Master
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
Functional Pe(a)rls version 2
Functional Pe(a)rls version 2Functional Pe(a)rls version 2
Functional Pe(a)rls version 2
 
Ns2programs
Ns2programsNs2programs
Ns2programs
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Calling Functions
Calling FunctionsCalling Functions
Calling Functions
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
PHP Tips & Tricks
PHP Tips & TricksPHP Tips & Tricks
PHP Tips & Tricks
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perl
 
Laziness in Swift
Laziness in Swift Laziness in Swift
Laziness in Swift
 
循環参照のはなし
循環参照のはなし循環参照のはなし
循環参照のはなし
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
 
How to stand on the shoulders of giants
How to stand on the shoulders of giantsHow to stand on the shoulders of giants
How to stand on the shoulders of giants
 
SAT/SMT solving in Haskell
SAT/SMT solving in HaskellSAT/SMT solving in Haskell
SAT/SMT solving in Haskell
 
Call Return Exploration
Call Return ExplorationCall Return Exploration
Call Return Exploration
 

Más de mydrynan

CSIA 413 Cybersecurity Policy, Plans, and Programs.docx
CSIA 413 Cybersecurity Policy, Plans, and Programs.docxCSIA 413 Cybersecurity Policy, Plans, and Programs.docx
CSIA 413 Cybersecurity Policy, Plans, and Programs.docxmydrynan
 
CSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docx
CSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docxCSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docx
CSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docxmydrynan
 
CSI Paper Grading Rubric- (worth a possible 100 points) .docx
CSI Paper Grading Rubric- (worth a possible 100 points)   .docxCSI Paper Grading Rubric- (worth a possible 100 points)   .docx
CSI Paper Grading Rubric- (worth a possible 100 points) .docxmydrynan
 
CSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docx
CSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docxCSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docx
CSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docxmydrynan
 
CSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docx
CSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docxCSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docx
CSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docxmydrynan
 
CSE422 Section 002 – Computer Networking Fall 2018 Ho.docx
CSE422 Section 002 – Computer Networking Fall 2018  Ho.docxCSE422 Section 002 – Computer Networking Fall 2018  Ho.docx
CSE422 Section 002 – Computer Networking Fall 2018 Ho.docxmydrynan
 
CSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docxCSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docxmydrynan
 
CSCI 714 Software Project Planning and EstimationLec.docx
CSCI 714 Software Project Planning and EstimationLec.docxCSCI 714 Software Project Planning and EstimationLec.docx
CSCI 714 Software Project Planning and EstimationLec.docxmydrynan
 
CSCI 561Research Paper Topic Proposal and Outline Instructions.docx
CSCI 561Research Paper Topic Proposal and Outline Instructions.docxCSCI 561Research Paper Topic Proposal and Outline Instructions.docx
CSCI 561Research Paper Topic Proposal and Outline Instructions.docxmydrynan
 
CSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docx
CSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docxCSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docx
CSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docxmydrynan
 
CryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docx
CryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docxCryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docx
CryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docxmydrynan
 
CSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docx
CSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docxCSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docx
CSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docxmydrynan
 
CSCE 1040 Homework 2 For this assignment we are going to .docx
CSCE 1040 Homework 2  For this assignment we are going to .docxCSCE 1040 Homework 2  For this assignment we are going to .docx
CSCE 1040 Homework 2 For this assignment we are going to .docxmydrynan
 
CSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docxCSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docxmydrynan
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxmydrynan
 
CSCE 3110 Data Structures & Algorithms Summer 2019 1 of .docx
CSCE 3110 Data Structures & Algorithms Summer 2019   1 of .docxCSCE 3110 Data Structures & Algorithms Summer 2019   1 of .docx
CSCE 3110 Data Structures & Algorithms Summer 2019 1 of .docxmydrynan
 
CSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docx
CSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docxCSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docx
CSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docxmydrynan
 
CSC-321 Final Writing Assignment In this assignment, you .docx
CSC-321 Final Writing Assignment  In this assignment, you .docxCSC-321 Final Writing Assignment  In this assignment, you .docx
CSC-321 Final Writing Assignment In this assignment, you .docxmydrynan
 
Cryptography is the application of algorithms to ensure the confiden.docx
Cryptography is the application of algorithms to ensure the confiden.docxCryptography is the application of algorithms to ensure the confiden.docx
Cryptography is the application of algorithms to ensure the confiden.docxmydrynan
 
CSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docx
CSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docxCSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docx
CSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docxmydrynan
 

Más de mydrynan (20)

CSIA 413 Cybersecurity Policy, Plans, and Programs.docx
CSIA 413 Cybersecurity Policy, Plans, and Programs.docxCSIA 413 Cybersecurity Policy, Plans, and Programs.docx
CSIA 413 Cybersecurity Policy, Plans, and Programs.docx
 
CSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docx
CSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docxCSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docx
CSIS 100CSIS 100 - Discussion Board Topic #1One of the object.docx
 
CSI Paper Grading Rubric- (worth a possible 100 points) .docx
CSI Paper Grading Rubric- (worth a possible 100 points)   .docxCSI Paper Grading Rubric- (worth a possible 100 points)   .docx
CSI Paper Grading Rubric- (worth a possible 100 points) .docx
 
CSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docx
CSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docxCSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docx
CSIA 413 Cybersecurity Policy, Plans, and ProgramsProject #4 IT .docx
 
CSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docx
CSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docxCSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docx
CSI 170 Week 3 AssingmentAssignment 1 Cyber Computer CrimeAss.docx
 
CSE422 Section 002 – Computer Networking Fall 2018 Ho.docx
CSE422 Section 002 – Computer Networking Fall 2018  Ho.docxCSE422 Section 002 – Computer Networking Fall 2018  Ho.docx
CSE422 Section 002 – Computer Networking Fall 2018 Ho.docx
 
CSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docxCSCI  132  Practical  Unix  and  Programming   .docx
CSCI  132  Practical  Unix  and  Programming   .docx
 
CSCI 714 Software Project Planning and EstimationLec.docx
CSCI 714 Software Project Planning and EstimationLec.docxCSCI 714 Software Project Planning and EstimationLec.docx
CSCI 714 Software Project Planning and EstimationLec.docx
 
CSCI 561Research Paper Topic Proposal and Outline Instructions.docx
CSCI 561Research Paper Topic Proposal and Outline Instructions.docxCSCI 561Research Paper Topic Proposal and Outline Instructions.docx
CSCI 561Research Paper Topic Proposal and Outline Instructions.docx
 
CSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docx
CSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docxCSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docx
CSCI 561 DB Standardized Rubric50 PointsCriteriaLevels of .docx
 
CryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docx
CryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docxCryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docx
CryptographyLesson 10© Copyright 2012-2013 (ISC)², Inc. Al.docx
 
CSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docx
CSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docxCSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docx
CSCI 352 - Digital Forensics Assignment #1 Spring 2020 .docx
 
CSCE 1040 Homework 2 For this assignment we are going to .docx
CSCE 1040 Homework 2  For this assignment we are going to .docxCSCE 1040 Homework 2  For this assignment we are going to .docx
CSCE 1040 Homework 2 For this assignment we are going to .docx
 
CSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docxCSCE509–Spring2019Assignment3updated01May19DU.docx
CSCE509–Spring2019Assignment3updated01May19DU.docx
 
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docxCSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
CSCI 2033 Elementary Computational Linear Algebra(Spring 20.docx
 
CSCE 3110 Data Structures & Algorithms Summer 2019 1 of .docx
CSCE 3110 Data Structures & Algorithms Summer 2019   1 of .docxCSCE 3110 Data Structures & Algorithms Summer 2019   1 of .docx
CSCE 3110 Data Structures & Algorithms Summer 2019 1 of .docx
 
CSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docx
CSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docxCSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docx
CSCI 340 Final Group ProjectNatalie Warden, Arturo Gonzalez, R.docx
 
CSC-321 Final Writing Assignment In this assignment, you .docx
CSC-321 Final Writing Assignment  In this assignment, you .docxCSC-321 Final Writing Assignment  In this assignment, you .docx
CSC-321 Final Writing Assignment In this assignment, you .docx
 
Cryptography is the application of algorithms to ensure the confiden.docx
Cryptography is the application of algorithms to ensure the confiden.docxCryptography is the application of algorithms to ensure the confiden.docx
Cryptography is the application of algorithms to ensure the confiden.docx
 
CSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docx
CSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docxCSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docx
CSc3320 Assignment 6 Due on 24th April, 2013 Socket programming .docx
 

Último

Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Último (20)

LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

cs47_proj_sourceCS47_proj_alu_normal.asm.include .cs47_proj.docx

  • 1. cs47_proj_source/CS47_proj_alu_normal.asm .include "./cs47_proj_macro.asm" .text .globl au_normal # TBD: Complete your project procedures # Needed skeleton is given ##################################################### ################ # Implement au_normal # Argument: # $a0: First number # $a1: Second number # $a2: operation code ('+':add, '-':sub, '*':mul, '/':div) # Return: # $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1) # $v1: ($a0 * $a1):HI | ($a0 % $a1) # Notes: ##################################################### ################ au_normal: # TBD: Complete it addi $sp, $sp, -16 sw $fp, 16($sp) sw $ra, 12($sp) sw $s0, 8($sp) addi $fp, $sp, 16 beq $a2, '+', add_normal beq $a2, '-', sub_normal beq $a2, '*', mult_normal beq $a2, '/', div_normal add_normal: add $s0, $a0, $a1 move $v0, $s0
  • 2. j normal_end sub_normal: sub $s0, $a0, $a1 la $v0, 0($s0) move $v0, $s0 j normal_end mult_normal: mult $a0, $a1 mfhi $v1 mflo $v0 j normal_end div_normal: div $a0, $a1 mfhi $v1 mflo $v0 j normal_end normal_end: lw $fp, 16($sp) lw $ra, 12($sp) lw $s0, 8($sp) addi $sp, $sp, 16 jr $ra __MACOSX/cs47_proj_source/._CS47_proj_alu_normal.asm cs47_proj_source/.DS_Store __MACOSX/cs47_proj_source/._.DS_Store cs47_proj_source/cs47_proj_macro.asm # Add you macro definition here - do not touch cs47_common_macro.asm" #<------------------ MACRO DEFINITIONS ---------------------- ># # Macro to take away the nth bit for operations .macro take_nth_bit ($regD, $regS, $regT)
  • 3. # right shift by $regT srlv $regD, $regS, $regT and $regD, $regD, 0x1 .end_macro # Macro to put value to nth bit .macro put_value_to_nth_bit($regD, $regS, $regT, $maskReg) # shift 0x1 for $regS li $t9, 0x1 sllv $maskReg, $t9, $regS # inverse nor $maskReg, $maskReg, $0 and $regD, $regD, $maskReg # shift left $regT by the amount of it sllv $regT, $regT, $regS or $regD, $regD, $regT .end_macro __MACOSX/cs47_proj_source/._cs47_proj_macro.asm cs47_proj_source/CS47_proj_alu_logical.asm .include "./cs47_proj_macro.asm" .text .globl au_logical # TBD: Complete your project procedures # Needed skeleton is given ##################################################### ################ # Implement au_logical # Argument: # $a0: First number # $a1: Second number # $a2: operation code ('+':add, '-':sub, '*':mul, '/':div) # Return: # $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1)
  • 4. # $v1: ($a0 * $a1):HI | ($a0 % $a1) # Notes: ##################################################### ################ au_logical: # TBD: Complete it # store frame addi $sp, $sp, -16 sw $fp, 16($sp) sw $ra, 12($sp) sw $a2, 8($sp) addi $fp, $sp, 16 operation_check: beq $a2, '+', add_logical beq $a2, '-', sub_logical beq $a2, '*', mult_logical beq $a2, '/', div_logical j logical_end add_logical: li $a2, 0x0 jal add_sub_logical j logical_end sub_logical: li $a2, 0xFFFFFFFF jal add_sub_logical j logical_end mult_logical: jal mult_signed j logical_end div_logical: jal div_signed logical_end: lw $fp, 16($sp) lw $ra, 12($sp) lw $a2, 8($sp) addi $sp, $sp, 16
  • 5. jr $ra add_sub_logical: addi $sp, $sp, -20 sw $fp, 20($sp) sw $ra, 16($sp) sw $s0, 12($sp) sw $a1, 8($sp) addi $fp, $sp, 20 # start from li $t0, 0x0 li $s0, 0x0 take_nth_bit($t1, $a2, $t0) beq $t1, 0x0, add_steps nor $a1, $a1, $0 add_steps: # if I = 32, jump to the end beq $t0, 0x20, add_sub_logical_end take_nth_bit($t2, $a0, $t0) take_nth_bit($t3, $a1, $t0) xor $t4, $t2, $t3 xor $t5, $t1, $t4 and $t6, $t1, $t4 and $t7, $t2, $t3 or $t1, $t6, $t7 # change C to CO put_value_to_nth_bit($s0, $t0, $t5, $t8) # I = I + 1 addi $t0, $t0, 0x1 j add_steps add_sub_logical_end: move $v0, $s0 move $v1, $t1 lw $fp, 20($sp)
  • 6. lw $ra, 16($sp) lw $s0, 12($sp) lw $a1, 8($sp) addi $sp, $sp, 20 jr $ra mult_unsigned: addi $sp, $sp, -40 sw $fp, 40($sp) sw $ra, 36($sp) sw $s0, 32($sp) sw $s1, 28($sp) sw $s2, 24($sp) sw $s3, 20($sp) sw $a0, 16($sp) sw $a1, 12($sp) sw $a2, 8($sp) addi $fp, $sp, 40 li $s0, 0x0 li $s1, 0x0 la $s2, 0($a1) la $s3, 0($a0) add_loop: take_nth_bit($t4, $s2, $zero) la $t5, 0($a0) la $a0, 0($t4) jal bit_repeat la $t4, 0($v0) and $t7, $s3, $t4 la $a0, 0($s1) la $a1, 0($t7) li $a2, '+' jal au_logical la $s1, 0($v0)
  • 7. li $t6, 0x1 li $t4, 0x1f srlv $s2, $s2, $t6 take_nth_bit($t8, $s1, $zero) put_value_to_nth_bit($s2, $t4, $t8, $t9) srlv $s1, $s1, $t6 addi $s0, $s0, 0x1 beq $s0, 0x20, mult_unsigned_end j add_loop mult_unsigned_end: move $v0, $s2 move $v1, $s1 lw $fp, 40($sp) lw $ra, 36($sp) lw $s0, 32($sp) lw $s1, 28($sp) lw $s2, 24($sp) lw $s3, 20($sp) lw $a0, 16($sp) lw $a1, 12($sp) lw $a2, 8($sp) addi $sp, $sp, 40 jr $ra mult_signed: addi $sp, $sp, -44 sw $s1, 44($sp) sw $s0, 40($sp) sw $s7, 36($sp) sw $fp, 32($sp) sw $ra, 28($sp) sw $s4, 24($sp) sw $s5, 20($sp) sw $s6, 16($sp)
  • 8. sw $a0, 12($sp) sw $a1, 8($sp) addi $fp, $sp, 44 # start from la $s4, 0($a0) # begin with N1 la $s5, 0($a1) # begin with N2 jal twos_complement_add la $s7, 0($v0) la $a0, 0($a1) jal twos_complement_add la $a1, 0($v0) la $a0, 0($s7) jal mult_unsigned addi $t7, $zero, 31 take_nth_bit($s1, $s4, $t7) take_nth_bit($s0, $s5, $t7) xor $s6, $s1, $s0 bne $s6, 1, mult_signed_end move $a0, $v0 move $a1, $v1 jal twos_complement_64bit mult_signed_end: lw $s1, 44($sp) lw $s0, 40($sp) lw $s7, 36($sp) lw $fp, 32($sp) lw $ra, 28($sp) lw $s4, 24($sp) lw $s5, 20($sp) lw $s6, 16($sp) lw $a0, 12($sp) lw $a1, 8($sp) addi $sp, $sp, 44 jr $ra
  • 9. twos_complement_add: # store frame addi $sp, $sp, -16 sw $fp, 16($sp) sw $ra, 12($sp) sw $a0, 8($sp) addi $fp, $sp, 16 # start from move $v0 , $a0 bge $a0, 0x0, twos_complement_end jal twos_complement twos_complement_end: # restore frame lw $fp, 16($sp) lw $ra, 12($sp) lw $a0, 8($sp) addi $sp, $sp, 16 jr $ra twos_complement: # store frame addi $sp, $sp, -24 sw $fp, 24($sp) sw $ra, 20($sp) sw $a0, 16($sp) sw $a1, 12($sp) sw $a2, 8($sp) addi $fp, $sp, 24 # begin nor $a0, $a0, $zero # $a0 = ~$a0 addi $a1, $zero, 1 # $a1 = 1 li $a2, '+' jal au_logical # adding ~$a0 and 1
  • 10. # restore frame lw $fp, 24($sp) lw $ra, 20($sp) lw $a0, 16($sp) lw $a1, 12($sp) lw $a2, 8($sp) addi $sp, $sp, 24 jr $ra bit_repeat: # store frame addi $sp, $sp, -16 sw $fp, 16($sp) sw $ra, 12($sp) sw $a0, 8($sp) addi $fp, $sp, 16 # begin beq $a0, 0x0, repeat_zero li $t0, 0xFFFFFFFF # if !zero j bit_repeat_end repeat_zero: li $t0, 0x0 bit_repeat_end: move $v0, $t0 # return value # restore frame lw $fp, 16($sp) lw $ra, 12($sp) lw $a0, 8($sp) addi $sp, $sp, 16 jr $ra twos_complement_64bit: # store frame
  • 11. addi $sp, $sp, -28 sw $s0, 28($sp) sw $fp, 24($sp) sw $ra, 20($sp) sw $a0, 16($sp) sw $a1, 12($sp) sw $a2, 8($sp) addi $fp, $sp, 28 # begin nor $a0, $a0, $zero nor $a1, $a1, $zero la $s0, 0($a1) addi $a1, $zero, 1 li $a2, '+' jal au_logical la $a1, 0($s0) # move s0 back to a1 la $s0, 0($v0) la $a0, 0($v1) li $a2, '+' jal au_logical move $v1, $v0 # high move $v0, $s0 # low twos_complement_64bit_end: # restore frame lw $s0, 28($sp) lw $fp, 24($sp) lw $ra, 20($sp) lw $a0, 16($sp) lw $a1, 12($sp) lw $a2, 8($sp) addi $sp, $sp, 28 jr $ra div_unsigned: # store the frame
  • 12. addi $sp, $sp, -40 sw $s5, 40($sp) sw $s2, 36($sp) sw $s7, 32($sp) sw $fp, 28($sp) sw $ra, 24($sp) sw $a0, 20($sp) sw $a2, 16($sp) sw $s0, 12($sp) sw $s1, 8($sp) addi $fp, $sp, 40 # start from li $s7, 0x0 # s7 = I = 0 li $s2, 0x0 la $s0, 0($a0) # original values la $s1, 0($a1) div_loop: li $t3, 0x1 sllv $s2, $s2, $t3 li $t3, 0x1f take_nth_bit($t4, $s0, $t3) put_value_to_nth_bit($s2, $zero, $t4, $t5) li $t3, 0x1 sllv $s0, $s0, $t3 la $t6, 0($a0) la $a0, 0($s2) # move R to a0 li $a2, '-' jal au_logical la $s2, 0($a0) la $a0, 0($t6) la $s5, 0($v0) # S = R - D bge $s5, $zero, intermediate_label div_loop_part2: addi $s7, $s7, 0x1
  • 13. addi $t3, $zero, 32 beq $s7, 32, div_unsigned_end j div_loop intermediate_label: move $s2, $s5 # R = S addi $t3, $zero, 1 # t3 = 1 put_value_to_nth_bit($s0, $zero, $t3, $t6) # Q[0] = 1 j div_loop_part2 div_unsigned_end: move $v0, $s0 move $v1, $s2 #remainder # restore the frame lw $s5, 40($sp) lw $s2, 36($sp) lw $s7, 32($sp) lw $fp, 28($sp) lw $ra, 24($sp) lw $a0, 20($sp) lw $a2, 16($sp) lw $s0, 12($sp) lw $s1, 8($sp) addi $sp, $sp, 40 jr $ra div_signed: # store frame addi $sp, $sp, -48 sw $s5, 48($sp) sw $s6, 44($sp) sw $s7, 40($sp) sw $s3, 36($sp) sw $s2, 32($sp) sw $s1, 28($sp) sw $s0, 24($sp)
  • 14. sw $fp, 20($sp) sw $ra, 16($sp) sw $a0, 12($sp) sw $a1, 8($sp) addi $fp, $sp, 48 la $s0, 0($a0) # a0 begin la $s1, 0($a1) # a1 begin jal twos_complement_add la $s2, 0($v0) la $a0, 0($s1) jal twos_complement_add la $a1, 0($v0) la $a0, 0($s2) jal div_unsigned la $s2, 0($v0) la $s3, 0($v1) li $t4, 0x1f take_nth_bit($s5, $s0, $t4) take_nth_bit($s6, $s1, $t4) xor $s7, $s5, $s6 bne $s7, 1, find_sign_to_R la $a0, 0($s2) jal twos_complement la $s2, 0($v0) find_sign_to_R: la $s7, 0($s5) bne $s7, 1, div_signed_end la $a0, 0($s3) jal twos_complement la $s3, 0($v0) div_signed_end: move $v0, $s2 move $v1, $s3 lw $s5, 48($sp)
  • 15. lw $s6, 44($sp) lw $s7, 40($sp) lw $s3, 36($sp) lw $s2, 32($sp) lw $s1, 28($sp) lw $s0, 24($sp) lw $fp, 20($sp) lw $ra, 16($sp) lw $a0, 12($sp) lw $a1, 8($sp) addi $sp, $sp, 48 jr $ra __MACOSX/cs47_proj_source/._CS47_proj_alu_logical.asm CS47 Section 01 Abstract—This work thoroughly explains the implementation of a basic calculator through digital logic in the MIPS assembly language. The paper first describes the software and knowledge needed to understand the design and implementation of the calculator. The paper then describes the upper level design of the implementation followed by details on the actual implementation of the program. Code snippets are provided to provide a better
  • 16. understanding of the program. The program is tested with a pre- written test file which compares the calculator's results with MIPS arithmetic instruction sets. I. INTRODUCTION he use of logical operators to calculate expressions is a fundamental concept that serves as the foundation for digital circuits. To understand how digital logic can be used to carry out basic arithmetic, the objective of this project is to implement a basic calculator mainly through the use of logical operators. Functions supported by the calculator include the addition, subtraction, multiplication, and division of two integers. The calculator is written in MIPS (microprocessor without Interlocked Pipeline Stages), which is one of many types of assembly language. The software used to simulate a MIPS environment and write the implementation is MARS (MIPS Assembler and Runtime Simulator), an IDE developed and released by Missouri State University.
  • 17. II. REQUIREMENTS This sections describes both the software required to implement the calculator as well as the preliminary knowledge to understand the design and implementation of the calculator. A. Software Requirements To simulate the runtime environment of the MIPS assembly language, the software MARS is used as an IDE. MARS simulates the runtime environment and execution of MIPS without needing to operate in a low-level environment, as well as providing the same instruction sets and pseudo-instruction sets for use. Note that since MARS is written in Java, the user will require an installation of Java on the work station. Once MARS is launched, some settings will have to change for the program to run correctly. Under Settings, select "Initialize Program Counter to global 'main' if defined." The three files required for the calculator are cs_47_proj_macros.asm," cs_47_proj_procs.asm, and proj- auto_test.asm.
  • 18. B. Knowledge of Boolean Logic and Binary System The following subsections describe the preliminary concepts required to implement the logical calculator. 1) Boolean Logic The implementation of digital logic requires a solid understanding of both Boolean logic and binary arithmetic. In digital circuits, the expressions true and false are represented as a 1 or 0 respectively. From here, truth tables are constructed to determine the output of a Boolean expression given two truth values. The AND operation will essentially return 0 if its two inputs are neither 1. Table I illustrates the output of the AND operation given two inputs. TABLE I TRUTH TABLE FOR LOGICAL AND A B A.B 0 0 0 0 1 0
  • 19. 1 0 0 1 1 1 The OR operation will essentially return 0 only if its two inputs are both 0. Table II illustrates the output of the OR operation given two inputs. TABLE II TRUTH TABLE FOR LOGICAL OR A B A+B 0 0 0 0 1 1 1 0 1 1 1 1 Implementation of a Basic Calculator through Digital Logic in MIPS FirstName LastName, Computer Scientist, San Jose State University T CS47 Section 01
  • 20. The XOR operation will return 0 if its two inputs match, and will return 1 if its two inputs do not match. Table III illustrates the output of the XOR operation given two inputs. TABLE III TRUTH TABLE FOR LOGICAL XOR A B A ⊕B 0 0 0 0 1 1 1 0 1 1 1 0 2) Binary System A number with a counting base of two is known as a binary number. Typically, the alphabet consists of 0 and 1, symbols which conveniently coincide with the expressions of Boolean logic. In the counting system, a digits place will count to 1 before “rolling over” the digit to the next higher place. For example in the base 10 system, the next digit after 9 will roll over to form 10, 19 will roll over to form 20, and 99 will roll
  • 21. over to form 100. In binary, 1 is represented as 1, which rolls over to 10 when incremented to 2. Elementary hand-paper arithmetic algorithms work for both base 10 and base 2 systems. Moreover, inputs that are equivalent in both systems will yield an output that are equivalent as well. This fact can be used to ensure that the program produces correct outputs. In computers, integers are represented with binary. To distinguish between negative and positive numbers, the most significant bit determines the sign of the number. As an example, the number 2 represented with 6 bits would be 000010 while -2 would be 111110. To convert between a number and its complement (assuming the number is in range of its signed counterpart), invert the bits and add 1 to the number. III. DESIGN AND IMPLEMENTATION The following section describes the design and implementation of the logical calculator. The operators
  • 22. implemented by the calculator and described by the paper are addition, subtraction, multiplication, and division. A. Design of Calculator This subsection describes the design of the basic operations of the calculator. 1) Addition and Subtraction The design of the addition and subtraction implementation is lumped together because of the similarities of the operation. In fact, the subtraction operation is simply the addition operation with the second input complemented to form its negated counterpart. The addition logic involves performing logical operations to determine the digit of the final output as well as a “carry bit” to carry over the number for the next logical operation. These operations are performed 32 times (the number of bits available in a register). To determine the nth digit of the final output, the logical XOR operation is performed on the nth digits of the first and
  • 23. second inputs as well as the carry bit. The carry bit is initialized to 0, and is calculated by taking the OR operation of the AND of the nth digits of the two inputs with the AND operation of the current carry bit value and XOR operation with the nth digits of the inputs. The figure below illustrates the logical equations formally. Once the operations are performed 32 times (once for each bit in the registers), the procedure ends. Note that there is a possibility that the carry bit is not carried over if the operations are performed 32 times. In this case, the overflow can be stored in another register to return. For subtraction, simply find the complement of the second input before performing the procedure. 2) Multiplication The unsigned multiplication logic involves creating a mask from the least significant bit of the current multiplier, using the mask on the multiplicand and adding the result to the final output (initialized to 0).
  • 24. The mask is created by replicating the first bit of the current multiplier. If the bit is 0, the mask is 0; if the bit is 1, the mask is -1. The mask and the multiplicand are AND together and added to a hi counter. The multiplier and hi counter are shifted to the left by 1, with the hi counter’s dropped off bit inserted into the multiplier’s most significant bit. These operations are performed 32 times to receive the final output (in place of multiplier). For signed multiplication, the multiplier and multiplicand are made positive if either are negative and the unsigned multiplication is performed. The final sign is determined by performing the XOR operation on the most significant bits, and complementing the results of the unsigned multiplication if the sign value is 1. 3) Division The unsigned division logic first shifts the remainder (initialized to 0) to the left, grabbing the most significant bit from the current dividend storing the bit in the least significant
  • 25. bit in the remainder. The dividend is then shifted to the left. The divisor is then subtracted from the remainder value. If the result is more than or equal to 0, the remainder is made to equal the result, and the bit 1 is inserted in the dividend’s least significant bit. If the result is less than 0, the loop simply continues. Once the steps are performed 32 times, the operation ends with the quotient stored in the dividend’s place. For signed division, the sign of the quotient is determined similarly as the product’s sign was determined in the signed CS47 Section 01 multiplication logic. The sign of the remainder is determined by checking the most significant bit of the dividend. If the sign is 1, complement the remainder. B. Implementation Details Before the logical calculator operations can be implemented through MIPS, and handful of utility procedures and macroes are defined to assist in the implementation.
  • 26. 1) Utility Macroes The additional macroes defined in the program are extract_nth_bit, insert_to_nth_bit, store_stack, and load_stack. i. Extract_nth_bit Extract_nth_bit returns the bit value of a given position for a given number. The defined macro takes three arguments in the following order: the register to store the result, register containing source bit pattern, and register holding the value of the bit position. The macro functions by shifting the source bit pattern by the bit position number, moving the desired bit to the least significant bit position. From there, AND is called with 1 to extract the desired bit and stored. ii. Insert_to_nth_bit Insert_to_nth_bit loads a given bit value into the nth position of a value and returns it. The defined macro takes four arguments in the following order: register of the bit pattern in which to insert to, register
  • 27. containing the position in which to insert, register containing the value to insert (0 or 1), and a temporary register to create a mask. The macro functions first by setting the mask value to 1. The mask is then shifted to the left by n. The OR operation is then called with the mask and -1 to invert its bits. Once done, AND is called on the mask and the bit pattern in which to modify. The bit to insert is then shifted left by n and OR is called with the bit pattern. iii. Store_stack and load_stack The purpose of these two functions is to simply store and load the proper registers on call. They take no arguments and will store/load the registers listed regardless of whether they were used or not. Though the proper use of the stack involves storing and loading only the registers that are used, macroes were defined to cut down on the number of lines in the code and increase readability. Specifically, the registers stored and loaded are $fp, $ra, $a0-$a3, and $s0-$s7.
  • 28. 2) Utility Procedures i. twos_complement and twos_complement_if_neg Twos_complement takes an argument in $a0 and returns its complement in $v0. The complement is calculated by calling XOR on the argument and -1. Add_logical is then called to add the XOR’d result and 1. Twos_complement_if_neg will return the argument if it is more than 0, and branch to twos_complement if the argument is less than 0. ii. Twos_complement_64bit This procedure takes the lo and hi values as arguments from the results mul_unsigned and returns the complement of the two. First, both the arguments are inverted by calling XOR and -1. The inverted lo value and 1 is passed into the add_logical function, which returns the complemented lo value in $v0, and the overflowed carry bit in $v1. This bit is then added to the
  • 29. inverted hi to get its complement. The complemented lo and hi are returned in $v0 and $v1 respectively. iii. bit_replicator and replicate #$regD contains 0 or 1 depending on nth bit 0 or 1 #$regS source bit pattern #$regT bit position <CODE REMOVED> #$regD bit pattern in which to insert to #$regS position of bit to insert (0-31) #$regT register containing 0 or 1 to insert #$maskReg register to hold mask .macro insert_to_nth_bit($regD, $regS, $regT, $maskReg) <CODE REMOVED> .end_macro twos_complement: <CODE REMOVED> twos_complement_if_neg: <CODE REMOVED> bit_replicator:
  • 30. <CODE REMOVED> replicate: <CODE REMOVED> CS47 Section 01 These two procedures assist in “replicating” a given bit to occupy all 32 registers. Bit_replicator will take an argument in $a0 and return 0 in $v0 if the argument is 0. The argument will branch to replicate if the argument is 1. For replicate, the procedure simply returns -1 in $v0. iv. Exit This procedure will simply call the load_stack macro and jump back to the return address. The procedure is called after the end of a calculator operation. 3) Addition/Subtraction Implementation i. add_logical / sub_logical
  • 31. Initially, the carry bit, final sum, and index are initialized to 0 in add_logical. For sub_logical, the first argument is stored, and the second argument is moved to $a0 to be complemented with the twos_complement procedure. The arguments are moved back to place and the proper variables are initialized. From here, both procedures jump to add_loop. ii. add_loop The add_loop function will logically calculate the sum of the two inputs in $a0 and $a1. The loop first checks if the counter is equal to 32. If not, the procedure will call macroes to extract the nth position of the argument. Using the XOR operation, the sum bit is calculated. The carry bit is also calculated and stored in $v1. Afterward, the insert macro is called to place the sum bit into its proper place in $v0. Finally, the index is incremented by 1 and the procedure jumps to itself. Once the index equals 32, the procedure branches to the exit procedure and returns to the calling procedure. 4) Multiplication Implementation
  • 32. i. mul_logical The arguments are initially stored twice to free space for the complement procedure and to check for the sign in the later procedure. The two arguments are checked and complemented if negative. From here, the results are passed into the argument registers and mul_unsigned is called. ii. mul_unsigned The procedure initializes the index, the hi counter, and stores the arguments. The multiplicand is stored in $s4 while the multiplier is stored in $s5. The procedure then calls mul_loop add_logical: <CODE REMOVED> sub_logical: <CODE REMOVED> <CODE REMOVED> add_loop:
  • 33. <CODE REMOVED> add_loop: beq $t0, 32, exit #grabbing a[i] bits of $a0 and $a1 #stored in $t2 and $t3 respectively extract_nth_bit($t2, $a0, $t0) extract_nth_bit($t3, $a1, $t0) #calculate bit value of y through xor operations xor $s1, $t2, $t3 #xor bits a0[i] and a1[i] xor $s2, $s1, $s0 #xor carry-in bits with previous sum #calculate bit value of carry-out and $s4, $t2, $t3 #a and b and $s0, $s0, $s1 #carry bit and (a xor b) or $s0, $s0, $s4 la $v1, ($s0) insert_to_nth_bit($v0, $t0, $s2, $t7) addi $t0, $t0, 1 j add_loop mul_logical: <CODE REMOVED>
  • 34. CS47 Section 01 iii. mul_loop The loop initially checks to see if the index is equal to 32. Then the procedure extracts the first bit of the multiplier, which is then replicated after loaded into $a0. The result of the replicator and the multiplicand are ANDed together and stored into $s7. The current hi counter value and $s7 are loaded into arguments and add_logical is called. The result of the add_logical is moved back to the hi counter. The multiplier is then shifted to the right, while the least significant bit of the hi counter is extracted and inserted into the most significant bit of the multiplier. The hi counter is then shifted to the right. The results of the lo (corresponding with the multiplier’s register) and hi counter are stored in $v0 and $v1 respectively. Finally, the index is incremented and the procedure calls itself. Once the index reaches 32, mul_signed is called to place the
  • 35. appropriate signs. iv. mul_signed The purpose of mul_signed is to ensure that the final product contains the right sign after the unsigned procedure is called. Recall that mul_logical stored the original arguments and complemented the arguments if either were negative. Here, the most significant bits of both the multiplier and multiplicand are extracted with the macro and XOR’d together to receive the sign. If the sign is 0, the procedure calls exit. If the sign is not 0, the lo and hi results of mul_loop are loaded into the argument variables and passed into the procedure twos_complement_64bit. Afterward, the procedure exits. 5) Division Implementation <CODE REMOVED> div_logical: <CODE REMOVED> CS47 Section 01
  • 36. i. div_logical Much like mul_logical, the arguments are stored twice and complemented if negative. Afterward, the arguments, complemented or otherwise, are loaded into argument registers. The procedure div_unsigned is called. ii. div_unsigned The index and remainder registers are initialized to 0. The dividend and divisor are stored and div_loop is called. div_loop and branch The procedure first branches if the index is equal to 32. The remainder is then shifted to the left by 1. The extract macro is called on the 0 th position of the dividend and inserted into the new position of the remainder variable with the insert macro. The dividend is the shifted to the left. The remainder and divisor are loaded into $a0 and $a1 respectively and sub_logical is called. The result is then
  • 37. moved into $s2. A branch is called if the subtraction result (stored in $s2)is greater than or equal to 0. If the value of $s2 greater than or equal to 0, the remainder is assigned the value of $s2, and the bit 1 is inserted into the first bit of the divisor. If $s2 is less than 0, the branch is not called. In either case, the index is incremented by one. The quotient (corresponding with the dividend) and remainder are loaded into $v0 and $v1 respectively. Once the index is equal to 32, div_signed is called to handle the signs of the quotient and remainder. iii. div_signed, signed_quotient, and signed_remainder These procedure handles the signs of the remainder and quotient. Div_signed first stores the results of the div_loop procedure. The procedure then extracts the 31 st bits of both the dividend and divisor and store the results in $s2 and $s3 respectively. $s2 and $s3 are then XOR’d and the sign is then stored in $s4.
  • 38. The procedure the branches depending on whether the quotient or remainder needs to be complemented. If $s4 is not equal to 0, the procedure calls signed_quotient. If $s2 (first bit of dividend) is not equal to 0, the procedure calls signed_remainder. Otherwise, the procedure exits. In signed_quotient, the quotient (stored in $s6 by div_signed) is passed into $a0 and twos_complement is called. The result is re-stored in $s6. If $s2 is not equal to 0, the procedure will call signed_remainder. Otherwise, the result of the complement and remainder is loaded into $v0 and $v1 and the procedure exits. In signed_remainder, the remainder (stored in $s7 by, div_signed) is passed into $a0 and twos_complement is called. The result of the complement and the quotient are loaded into $v1, and $v0 respectively. IV. TESTING To test that the calculator’s procedures operate correctly, control procedures are written using MIPS’s inbuilt arithmetic
  • 39. instructions. The procedure au_normal is written to parse the input and call the respective instruction. div_loop: <CODE REMOVED> au_normal: store_stack beq $a2, '+' , add_normal beq $a2, '-' , sub_normal beq $a2, '*' , mul_normal beq $a2, '/' , div_normal add_normal: add $v0, $a0, $a1 j exit sub_normal: sub $v0, $a0, $a1 j exit mul_normal: mul $v0, $a0, $a1 mfhi $v1 j exit div_normal: CS47 Section 01 A. Testing Implementation
  • 40. 1) Add_normal and sub_normal Add_normal and sub_normal will call MIPS instructions add and sub respectively. The arguments are passed into the parameters and the result is stored in $v0. 2) Mul_normal Mul_normal will call the instruction mul and store the results in $v0. The hi result of the instruction is moved from the hi counter to $v1. 3) Div_normal Div_normal will call the instruction div, which stores the results in the quotient in the lo counter and remainder in the hi counter. These results are moved to $v0 and $v1 respectively. B. Proj-auto-test An assembly file was written and provided to easily test that the calculator operations work as expected. The file provides sample inputs and matches the results of au_normal with au_logical to ensure that the outputs are correct. The snippet above is a sample of the output of
  • 41. this test. V. CONCLUSION The objective of this project was to implement a basic calculator through the use of logical operators. The project provided insight on how digital circuits operate and how the logic behind the circuits are implemented. The program was written using the MIPS assembly language and tested with a provided testing file which matched the outputs of the logical calculator operations with the MIPS arithmetic instruction set. Next possible steps include implementing more complex expressions such as exponentiation, square rooting, decimal calculations, and more. (4 + 2) normal=> 6 logcal=> 6 [matched] (4 - 2) normal=> 2 logcal=> 2 [matched] (4 * 2) normal=> HI:0 LO:8 logical=> HI:0 LO:8 [matched] (4 / 2) normal=> R:0 Q:2 logical=> R:0 Q:2 [matched] (16 + -3) normal=> 13 logcal=> 13 [matched] (16 - -3) normal=> 19 logcal=> 19 [matched] (16 * -3) normal=> HI:-1 LO:-48 logical=> HI:-1 LO:-48 [matched] (16 / -3) normal=> R:1 Q:-5 logical=> R:1 Q:-5
  • 42. [matched] (-13 + 5) normal=> -8 logcal=> -8 [matched] (-13 - 5) normal=> -18 logcal=> -18 [matched] (-13 * 5) normal=> HI:-1 LO:-65 logical=> HI:-1 LO:-65 [matched] (-13 / 5) normal=> R:-3 Q:-2 logical=> R:-3 Q:-2 [matched] (-2 + -8) normal=> -10 logcal=> -10 [matched] . . . . . . . (-19 / 3) normal=> R:-1 Q:-6 logical=> R:-1 Q:-6 [matched] (4 + 3) normal=> 7 logcal=> 7 [matched] (4 - 3) normal=> 1 logcal=> 1 [matched] (4 * 3) normal=> HI:0 LO:12 logical=> HI:0 LO:12 [matched] (4 / 3) normal=> R:1 Q:1 logical=> R:1 Q:1 [matched] (-26 + -64) normal=> -90 logcal=> -90 [matched] (-26 - -64) normal=> 38 logcal=> 38
  • 43. [matched] (-26 * -64) normal=> HI:0 LO:1664 logical=> HI:0 LO:1664 [matched] (-26 / -64) normal=> R:-26 Q:0 logical=> R:-26 Q:0 [matched] Total passed 40 / 40 *** OVERALL RESULT PASS *** -- program is finished running -- Report of Arithmetic Implemented By MIPS XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE Abstract—This cs47 report is about by using MIPS language and logical procedures, we make the calculation to solve the operations. This report included diagrams for requirement and design, code snippet, containing objective and all detailed screenshot to explain how to get the process for this project.Introduction (Heading 1) This project is using MARS simulator environment which is an assembler of MIPS to perform the calculation of basic mathematic operation. It is basic on the MPIS logic operation. The goal of this project is understanding how digital logic can be used to implement a basic calculator through logical operators. This project are operated by the following steps: 1.Open MARS and implement the modules to design the mathematics operation 2.Complete the procedures and verify each other files 3.Run and compare the results to get correct conclusion
  • 44. The goal of this project is understand how digital logic can be used to implement a basic calculator through logical operators. Prapareation and set up Praperation: software and file Download MARS simulator and the file from canvas and unzip the files to make sure everything be all set. We use the MARS 4.5 software version and the Link is: http://courses.missouristate.edu/KenVollmar/mars/ The files download from canvas named CS47ProjectI.zip. After unzip CS47ProjectI.zip, there are six files by following: 1.cs47_common_macro.asm This has all important macros required for test. 2.cs47_proj_alu_logical.asm This need to be implemented for all logical arithmetic procedures. 3.cs47_proj_alu_normal.asm This need to be implemented for all normal arithmetic procedures. 4.cs47_proj_macro.asm This includes the macro which required during calculating 5.cs47_proj_procs.asm This includes all print procedures. 6.proj-auto-text.asm This used to text if the arithmetic modules get correct. Fig1: the files after unzipping Open six files by MARS 1. open Mars and click File to implement these six files Fig2: to open files Fig3: find the files and open
  • 45. Adjustment MARS enveriment Fig4: Turn on them to show the details and to make sure the files can be successfully executed. aAAAAA When everything is ready, the much harder part need to be done which is to see the requirement in every file. Then follow the requirement to write the code. Fig: the symbol of each Boolean algebraic operation. In cs47_proj_alu_logical.asm, all logical operations are put in there to calculate the mathematical operations in logical. Such as XNOR, NAND, NOT, NOR, AND and OR. Fig: there are 3 kinds of arguments (a0, a1, a2) and 2 kinds of returns(v0,v1). In cs47_proj_alu_normal.asm, all normal arithmetic operations are included in there, such as ADD, SUBTRACT, DIVIDE and MULTIPLY. Fig: there are 3 kinds of arguments (a0, a1, a2) and 2 kinds of returns(v0,v1)Which is the same as cs47_proj_alu_logical.asm. Then explain the mean of each register. 1.Register $a0: the first operand in calculation 2.Register $a1: the second operand in calculation 3.Register $a2: the operator in calculation. which are symbols represented to ‘+’, ‘-’, ‘*’, ‘/’. a. when $a2 represented to ‘+’, the procedure need to jump the addition section. Cause add means the sum of two operations. b. when $a2 represented to ‘-’, the procedure need to jump the subtraction section. Cause subtract means the difference of two operations. c. when $a2 represented to ‘*’, the procedure needs to jump the
  • 46. multiplication section. Cause subtract means the product of two operations. d. when $a2 represented to ‘/’, the procedure needs to jump the division section. Cause subtract means the quotient of two operations. 4.Register $v0: a storage, to store the result from addition and subtraction. 5.Register $v1: different multiplication has different means. When multiplication, it contains hi; when division, it contains remainder. Fig: implementation of cs47_proj_alu_normal.asm Next, back to logical.asm, it was the logical arithmetic procedure. It calculates every mathematical procedure by logical operation. Also, it needs the basic logical procedure which is similar to the normal.asm. Consider restoring the results that other register cannot change except $v0 and $v1: Also, the same operation should be done when we want to do more. Therefore, shift $sp back to the place that it stay before. Now explain every procedure during calculation. For example: ADD In this method, is the sum of two registers for $a0 and $a1. $a2 is the operator on the calculation: ‘+’. Fig: the truth table and basic identifies
  • 47. Write begain there Transl. J. Magn. Japan, vol. 2, pp. 740–741, August 1987 [Digests 9th Annual Conf. Magnetics Japan, p. 301, 1982]. M. Young, The Technical Writer’s Handbook. Mill Valley, CA: University Science, 1989. IEEE conference We suggest that you use a text box to insert a graphic (which is ideally a 300 dpi TIFF or EPS file, with all fonts embedded) because, in an MSW document, this method is somewhat more stable than directly inserting a picture. To have non-visible rules on your frame, use the MSWord “Format” pull-down menu, select Text Box > Colors and Lines to choose No Fill and No Line. CS47ProjectI/cs47_common_macro.asm # ***** DO NOT MODIFY THIS FILE **** # #<------------------ MACRO DEFINITIONS ---------------------- ># # Macro : print_str # Usage: print_str(<address of the string>) .macro print_str($arg) li $v0, 4 # System call code for print_str la $a0, $arg # Address of the string to print syscall # Print the string .end_macro
  • 48. # Macro : print_int # Usage: print_int(<val>) .macro print_int($arg) li $v0, 1 # System call code for print_int li $a0, $arg # Integer to print syscall # Print the integer .end_macro # Macro : exit # Usage: exit .macro exit li $v0, 10 syscall .end_macro # Macro: read_int # Usage: read_int(<reg>) .macro read_int($arg) li $v0,5 # Read intger syscall move $arg, $v0 # move the data to target reg .end_macro # Macro: print_reg_int # Usage: print_reg_int(<reg>) .macro print_reg_int ($arg) li $v0, 1 # print_int call move $a0, $arg # move the source reg value to $a0 syscall .end_macro # Macro: lwi # Usage: lwi (<reg>, <upper imm>, <lower imm>) .macro lwi ($reg, $ui, $li) lui $reg, $ui ori $reg, $reg, $li
  • 49. .end_macro # Macro: push # Usage: push (<reg>) .macro push($reg) sw $reg, 0x0($sp) # M[$sp] = R[reg] addi $sp, $sp, -4 # R[sp] = R[sp] - 4 .end_macro # Macro: push # Usage: push (<reg>) .macro pop($reg) addi $sp, $sp, +4 # R[sp] = R[sp] + 4 lw $reg, 0x0($sp) # M[$sp] = R[reg] .end_macro .macro push_var_value($varName) lw $t0, $varName push($t0) .end_macro .macro push_var_address($varName) la $t0, $varName push($t0) .end_macro .macro call_printf($format) la $a0, $format jal printf .end_macro CS47ProjectI/CS47_proj_alu_logical.asm .include "./cs47_proj_macro.asm" .text .globl au_logical
  • 50. # TBD: Complete your project procedures # Needed skeleton is given ##################################################### ################ # Implement au_logical # Argument: # $a0: First number # $a1: Second number # $a2: operation code ('+':add, '-':sub, '*':mul, '/':div) # Return: # $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1) # $v1: ($a0 * $a1):HI | ($a0 % $a1) # Notes: ##################################################### ################ au_logical: # TBD: Complete it jr $ra CS47ProjectI/CS47_proj_alu_normal.asm .include "./cs47_proj_macro.asm" .text .globl au_normal # TBD: Complete your project procedures # Needed skeleton is given ##################################################### ################ # Implement au_normal # Argument: # $a0: First number # $a1: Second number # $a2: operation code ('+':add, '-':sub, '*':mul, '/':div) # Return: # $v0: ($a0+$a1) | ($a0-$a1) | ($a0*$a1):LO | ($a0 / $a1) # $v1: ($a0 * $a1):HI | ($a0 % $a1) # Notes:
  • 51. ##################################################### ################ au_normal: # TBD: Complete it jr $ra CS47ProjectI/cs47_proj_macro.asm # Add you macro definition here - do not touch cs47_common_macro.asm" #<------------------ MACRO DEFINITIONS ---------------------- ># CS47ProjectI/cs47_proj_procs.asm # ***** DO NOT MODIFY THIS FILE **** # .include "./cs47_common_macro.asm" .text .globl printf #----------------------------------------------- # C style signature 'printf(<format string>,<arg1>, # <arg2>, ... , <argn>)' # # This routine supports %s and %d only # # Argument: $a0, address to the format string # All other addresses / values goes into stack #----------------------------------------------- printf: #store RTE - 5 *4 = 20 bytes addi $sp, $sp, -24 sw $fp, 24($sp) sw $ra, 20($sp) sw $a0, 16($sp) sw $s0, 12($sp)
  • 52. sw $s1, 8($sp) addi $fp, $sp, 24 # body move $s0, $a0 #save the argument add $s1, $zero, $zero # store argument index printf_loop: lbu $a0, 0($s0) beqz $a0, printf_ret beq $a0, '%', printf_format # print the character li $v0, 11 syscall j printf_last printf_format: addi $s1, $s1, 1 # increase argument index mul $t0, $s1, 4 add $t0, $t0, $fp # all print type assumes # the latest argument pointer at $t0 addi $s0, $s0, 1 lbu $a0, 0($s0) beq $a0, 'd', printf_int beq $a0, 's', printf_str beq $a0, 'c', printf_char printf_int: lw $a0, 0($t0) # printf_int li $v0, 1 syscall j printf_last printf_str: lw $a0, 0($t0) # printf_str li $v0, 4 syscall j printf_last printf_char: lbu $a0, 0($t0) li $v0, 11
  • 53. syscall j printf_last printf_last: addi $s0, $s0, 1 # move to next character j printf_loop printf_ret: #restore RTE lw $fp, 24($sp) lw $ra, 20($sp) lw $a0, 16($sp) lw $s0, 12($sp) lw $s1, 8($sp) addi $sp, $sp, 24 jr $ra CS47ProjectI/proj-auto-test.asm # ***** DO NOT MODIFY THIS FILE **** # .include "./cs47_common_macro.asm" .include "./cs47_proj_macro.asm" # data section .data .align 2 matchMsg: .asciiz "matched" unmatchMsg: .asciiz "not matched" charCR: .asciiz "n" testD: .word 0xffffffff var0: .word 0x00000000 var1: .word 0x00000000 var2: .word 0x00000000 var3: .word 0x00000000 testV1Arr: .word 4 16 -13 -2 -6 -18 5 -19 4 -26 testV2Arr: .word 2 -3 5 -8 -6 18 -8 3 3 -64 noTest: .word 10
  • 54. passTest: .word 0 totalTest: .word 0 opList: .byte '/' '*' '-' '+' testFlag: .word 0x0 as_msg: .asciiz "(%d %c %d) t normal => %d t logical => %d t [%s]n" mul_msg: .asciiz "(%d %c %d) t normal => HI:%d LO:%d t logical => HI:%d LO:%d t [%s]n" div_msg: .asciiz "(%d %c %d) t normal => R:%d Q:%d t logical => R:%d Q:%d t [%s]n" finalMSG: .asciiz "*** OVERALL RESULT %s ***n" statPASS: .asciiz "PASS" statFAIL: .asciiz "FAILED" testStatus: .asciiz "nnTotal passed %d / %dn" .text .globl main ##################################################### ################ # Main Program ##################################################### ################ main: add $s0, $zero, $zero # $s0 = 0 ; used as index lw $s1, noTest test_loop: mul $t0, $s0, 4 # $s3 = testV1Arr[$s0] la $t1, testV1Arr add $t1, $t1, $t0 lw $s3, 0($t1) # $s4 = testV2Arr[$s0] la $t1, testV2Arr add $t1, $t1, $t0 lw $s4, 0($t1) addi $s5, $zero, 4
  • 55. op_loop: addi $t0, $s5, -1 la $t1, opList add $t1, $t1,$t0 lb $s6, 0($t1) # increase number of tests lw $t0, totalTest addi $t0, $t0, 1 sw $t0, totalTest # normal operation or $a0, $s3, $zero or $a1, $s4, $zero or $a2, $s6, $zero ori $v0, $zero, 0x0 ori $v1, $zero, 0x1 jal au_normal sw $v0, var0 sw $v1, var1 # logical operation or $a0, $s3, $zero or $a1, $s4, $zero or $a2, $s6, $zero ori $v0, $zero, 0x2 ori $v1, $zero, 0x3 jal au_logical sw $v0, var2 sw $v1, var3 # Set if mul or div # print the result lw $t0, var0 lw $t1, var2 bne $t0, $t1, main_mismatch beq $s6, '*', main_extra_match beq $s6, '/', main_extra_match j main_L6 main_extra_match:
  • 56. lw $t0, var1 lw $t1, var3 bne $t0, $t1, main_mismatch main_L6: push_var_address(matchMsg) lw $t0, passTest addi $t0, $t0, 1 sw $t0, passTest j main_L5 main_mismatch: push_var_address(unmatchMsg) ori $t0, $zero, 0x1 sw $t0, testFlag main_L5: push_var_value(var2) beq $s6, '*', main_ins_1 beq $s6, '/', main_ins_1 j main_L1 main_ins_1: push_var_value(var3) # main_ins_1 main_L1: push_var_value(var0) # main_L1 beq $s6, '*', main_ins_2 beq $s6, '/', main_ins_2 j main_L2 main_ins_2: push_var_value(var1) # main_ins_2 main_L2: push($s4) # main_L2 push($s6) push($s3) beq $s6, '*', main_print_mul beq $s6, '/', main_print_div call_printf(as_msg) j main_L3 main_print_mul:
  • 57. call_printf(mul_msg) # main_print_mul j main_L3 main_print_div: call_printf(div_msg) # main_print_div j main_L3 main_L3: pop($t0) # main_L3 pop($t0) pop($t0) pop($t0) pop($t0) pop($t0) beq $s6, '*', main_pop_2 beq $s6, '/', main_pop_2 j main_L4 main_pop_2: pop($t0) pop($t0) main_L4: addi $s5, $s5, -1 # main_L4 bnez $s5 op_loop addi $s0, $s0, 1 bne $s0, $s1, test_loop # Test statistics lw $t0, totalTest push($t0) lw $t0, passTest push($t0) call_printf(testStatus) pop($t0) pop($t0) # Final msg lw $t0, testFlag beqz $t0, main_pass push_var_address(statFAIL)