MIPS Sample Code CSC 213 by Amena Cliff
MIPS Sample Code CSC 213 by Amena Cliff
.data
.text
main:
li $v0, 4
la $a0, firstMessage
syscall
j procedureToPrintHelloWorld
procedureToPrintHelloWorld:
li $v0, 4
la $a0, myMessage
syscall
(2) Program in Assembly (MIPS ) To Solve for the Lateral Surface Area of a
Cone
.data
resultText : .asciiz "\n The Value of the Lateral Surface Area of a Cone
is : "
.text
main:
lwc1 $f10, zeroAsFloat
lwc1 $f7, PI
li $v0 4
la $a0, askForRaduis
syscall
li, $v0, 6
syscall
li $v0, 4
la $a0, askForHeight
syscall
li $v0, 6
syscall
li $v0 4
la $a0 resultText
syscall
li $v0, 2
syscall
(2) (b) Solve for the Area of A Triangle using Hero’s Formula
.data
askForValueA: .asciiz " \n What is the Value of a \n "
askForValueB: .asciiz "\n What is the Value of b \n "
askForValueC: .asciiz "\n What is the Value of c \n"
answerText: .asciiz "The Area of the triangle using the Hero's
Formula is : "
zeroFloat: .float 0.00
numberTwo : .float 2.00
.text
main :
lwc1 $f1, zeroFloat
li $v0, 4
la $a0, askForValueA
syscall
li $v0, 6
syscall
li $v0, 4
la $a0, askForValueB
syscall
li $v0, 6
syscall
li $v0, 4
la $a0, askForValueC
syscall
li $v0, 6
syscall
sqrt.s $f0,$f4
li $v0, 4
la $a0, answerText
syscall
li $v0,2
syscall
.data
.text
while :
beq $t0 4000 exit
lw $t1, myArray($t0)
mul $t1, $t1 , $t8
sw $t1 , myArray($t0)
j while
exit:
printLoop:
lw $t3 myArray($t2)
li $v0 1
syscall
j printLoop
endProgram:
li $v0 10
syscall