Answered step by step
Verified Expert Solution
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 Lab #
#
# 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.
#
studentname: asciiz "Krish Monpara"
studentid: asciiz
newline: asciiz
space: asciiz
floatptarithlabel: asciiz "Floating Point Arithmetic
Expected Output:
Obtained Output:
floattestoneA: float
floattestoneB: float
floattestoneC: float
floattestoneD: float
floattesttwoA: float
floattesttwoB: float
floattesttwoC: float
floattesttwoD: float
floattestthreeA: float
floattestthreeB: float
floattestthreeC: float
floattestthreeD: float
bcdbinlbl: asciiz
Aiken to Binary Hexadecimal Values
Expected output:
CCBCE AE
Obtained output:
binbcdlbl: asciiz
Binary to Aiken Hexadecimal Values
Expected output:
BF CCCCBBB
Obtained output:
bcdbintestdata: word xBFxBCDE, xBBB
binbcdtestdata: word xCCxxFFFF
hexdigits: byte ABCDEF
###############################################################
# Text Section
text
# Utility function to print hexadecimal numbers
printhex:
move $t $a
li $t # digits
lui $txf # mask
maskandprint:
# print last hex digit
and $t $t $t
srl $t $t
la $t hexdigits
add $t $t $t
lb $a$t
li $v
syscall
# shift times
sll $t $t
addi $t $t
bgtz $t maskandprint
exit:
jr $ra
###############################################################
###############################################################
###############################################################
# PART Flaoting Point Arithmetic
# You are given four numbers
# A is preloaded in registers f
# B is preloaded in registers f
# C is preloaded in registers f
# D is preloaded in registers f
# Evaluate the arithmetic expression
# Store the result in register f
globl floatptarith
floatptarith:
############################## Part : your code begins here ###
############################## Part : your code ends here ###
jr $ra
###############################################################
###############################################################
###############################################################
# PART Aiken Code to Binary
#
# You are given a bits integer stored in $t This bits
# present a Aiken number. You need to convert it to a binary number.
# For example: xDCB should return xFFEA
# The result must be stored inside $t as well.
globl aikenbin
aikenbin:
move $t $a
############################ Part : your code begins here ###
############################ Part : your code ends here ###
move $v $t
jr $ra
###############################################################
###############################################################
###############################################################
###############################################################
# Main Function
main:
li $v
la $a studentname
syscall
la $a newline
syscall
la $a studentid
syscall
la $a newline
syscall
la $a newline
syscall
##############################################
##############################################
testbitAddUnsigned:
li $v
la $a floatptarithlabel
syscall
##############################################
ls $f floattestoneA # Load num into $f
ls $f floattestoneB # Load num into $f
ls $f floattestoneC # Load num into $f
ls $f floattestoneD # Load num into $f
jal floatptarith
li $v
syscall
li $v
la $a space
syscall
##############################################
ls $f floattesttwoA # Load num into $f
ls $f floattesttwoB # Load num into $f
ls $f floattesttwoC # Load num into $f
ls $f floattesttwoD # Load num into $f
jal floatptarith
li $v
syscall
li $v
la $a space
syscall
########################################
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started