Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code below ( only edit in areas marked ) jal main # CS 2 4 0 , Lab # 5 # # IMPORTATNT NOTES: #

Code below (only edit in areas marked)
jal main
# CS 240, Lab #5
#
# IMPORTATNT NOTES:
#
# Write your assembly code only in the marked blocks.
#
# DO NOT change anything outside the marked blocks.
#
# Remember to fill in your name, student ID in the designated sections.
#
#
j main
###############################################################
# Data Section
.data
#
# Fill in your name, student ID in the designated sections.
#
student_name: .asciiz "Krish Monpara"
student_id: .asciiz "828137421"
new_line: .asciiz "
"
space: .asciiz ""
float_pt_arith_label: .asciiz "Floating Point Arithmetic
Expected Output:
25.995193-420.72821.5803676
Obtained Output:
"
float_test_one_A: .float 1.35
float_test_one_B: .float 2.51
float_test_one_C: .float 6.75
float_test_one_D: .float 4.67
float_test_two_A: .float 11.35
float_test_two_B: .float 21.51
float_test_two_C: .float 3.75
float_test_two_D: .float 4.67
float_test_three_A: .float 15.67
float_test_three_B: .float 15.67
float_test_three_C: .float 15.67
float_test_three_D: .float 151.67
bcd_2_bin_lbl: .asciiz "
Aiken to Binary (Hexadecimal Values)
Expected output:
004CC85300BC614E 00008AE0
Obtained output:
"
bin_2_bcd_lbl: .asciiz "
Binary to Aiken (Hexadecimal Values)
Expected output:
0B03201F 0CC3C321000CBB3B
Obtained output:
"
bcd_2_bin_test_data: .word 0x0B03201F,0x1234BCDE, 0x3BBB2
bin_2_bcd_test_data: .word 0x4CC853,0x654321,0xFFFF
hex_digits: .byte '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
###############################################################
# Text Section
.text
# Utility function to print hexadecimal numbers
print_hex:
move $t0, $a0
li $t1,8 # digits
lui $t2,0xf000 # mask
mask_and_print:
# print last hex digit
and $t4, $t0, $t2
srl $t4, $t4,28
la $t3, hex_digits
add $t3, $t3, $t4
lb $a0,0($t3)
li $v0,11
syscall
# shift 4 times
sll $t0, $t0,4
addi $t1, $t1,-1
bgtz $t1, mask_and_print
exit:
jr $ra
###############################################################
###############################################################
###############################################################
# PART 1(Flaoting Point Arithmetic)
# You are given four numbers
# A is preloaded in registers f0
# B is preloaded in registers f1
# C is preloaded in registers f2
# D is preloaded in registers f3
# Evaluate the arithmetic expression
# Store the result in register f12
.globl float_pt_arith
float_pt_arith:
############################## Part 1: your code begins here ###
############################## Part 1: your code ends here ###
jr $ra
###############################################################
###############################################################
###############################################################
# PART 2(Aiken Code to Binary)
#
# You are given a 32-bits integer stored in $t0. This 32-bits
# present a Aiken number. You need to convert it to a binary number.
# For example: 0xDCB43210 should return 0x48FF4EA.
# The result must be stored inside $t0 as well.
.globl aiken2bin
aiken2bin:
move $t0, $a0
############################ Part 2: your code begins here ###
############################ Part 2: your code ends here ###
move $v0, $t0
jr $ra
###############################################################
###############################################################
###############################################################
###############################################################
# Main Function
main:
li $v0,4
la $a0, student_name
syscall
la $a0, new_line
syscall
la $a0, student_id
syscall
la $a0, new_line
syscall
la $a0, new_line
syscall
##############################################
##############################################
test_64bit_Add_Unsigned:
li $v0,4
la $a0, float_pt_arith_label
syscall
##############################################
l.s $f0, float_test_one_A # Load num1 into $f0
l.s $f1, float_test_one_B # Load num2 into $f1
l.s $f2, float_test_one_C # Load num2 into $f1
l.s $f3, float_test_one_D # Load num2 into $f1
jal float_pt_arith
li $v0,2
syscall
li $v0,4
la $a0, space
syscall
##############################################
l.s $f0, float_test_two_A # Load num1 into $f0
l.s $f1, float_test_two_B # Load num2 into $f1
l.s $f2, float_test_two_C # Load num2 into $f1
l.s $f3, float_test_two_D # Load num2 into $f1
jal float_pt_arith
li $v0,2
syscall
li $v0,4
la $a0, space
syscall
########################################
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

I had a problem last week; they would think I am picky or a whiner!

Answered: 1 week ago