[SOLVED] CS260-010 Assembly Language Programming (Spring 2015)

$25

File Name: CS260-010__Assembly_Language_Programming_(Spring_2015).zip
File Size: 508.68 KB

5/5 - (1 vote)

CS260-010 Assembly Language Programming (Spring 2015)

Overview

This document encompasses 3 projects which will all be due at the same time, but will be graded independently. You will have until the last day of classes to complete and hand in the code. You may hand in individual files for each part, or a single file that implements all 3 at your discression.

Part 1 Procedures

Convert your existing multiply and divide functions (or use the reference solutions provided on Sakai) into procedures that take arguments and return a value. You may either use the stack to store your arguments and return values like a compiler would, or just use registers to store the inputs and outputs. Your program should first multiply, then divide the two integers, storing the result in two different registers.
Part 2 Output

Extend part 1 by adding output to your program. Instead of just storing the results as a register, display the results to the user. (i.e. 42=8, 4/2=2)

Part 3 Input and selection

Modify your program again to take input from the user. Ask the user for two integers and use those as inputs to the multiply and divide procedures

Resources

A discussion of I/O for SPIM can be found here.

http://www.cs.uni.edu/~fienup/cs041f05/lectures/lec17_10-18-05_SPIM_IO.pdf

part1 reference solution.text

.globl main
main: li $a0, 10 # Dividend

lui $a1, 7 # Divisor

li $t0, 0x8000 li $t1, 0
lui $s0, 0xffff

lui $t2, 0x8000

intro_loop:
and $a2, $t0, $a0
beq $a2, $t0, Division_loopbeq $a2, 0, Division_shift
Division_shift:

sll $a0, $a0, 1

#Find the significant bit to be 1

addi $t1, $t1, 1j intro_loop

Division_loop:

subu $a0, $a0, $a1
and $a2, $a0, $t2
beq $a2, $t2, Division_undo
beq $a2, $zero, Division_do_subtract

Division_undo:
add $a0, $a0, $a1
sll $a0, $a0, 1
addi $t1, $t1, 1
beq $t1, 16, Division_endj Division_loop

Division_do_subtract:

addi $a0, $a0,1
beq $t1, 16, Division_endj Division_loop

Division_end:

and $a2, $a0, $s0

bge $a2, $a1, LastCheckj endFn

LastCheck:
subu $a0, $a0, $a1addi $a0, $a0, 1

endFn:

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS260-010 Assembly Language Programming (Spring 2015)
$25