Addition, Subtraction, Multiplication and solving equation in Assembly language (MIPS) on Mars
Use of Operands
Task 1:Write a program to add an Integer values in MIPS Assembly language.
.data
num1:.word 5
num2:.word 7
.text
lw $t0,num1
lw $t1,num2
add $t3,$t0,$t1
li,$v0,1
move $a0,$t3
syscall
Task 2:
Write a program to Subtract an Integer values in MIPS Assembly language.
.data num1:.word 5 num2:.word 7 .text lw $t0,num1 lw $t1,num2 sub $t3,$t0,$t1 li,$v0,1 move $a0,$t3 syscall
Task 3:
Write a program to Multiply an Integer values in MIPS Assembly language.
.data
num1:.word 5
num2:.word 7
.text
lw $t0,num1
lw $t1,num2
mul $t3,$t0,$t1
li,$v0,1
mflo $a0
syscall
Task 4:
Write a program to Divide an Integer values in MIPS Assembly language.
.data
num1:.word 10
num2:.word 5
.text
lw $t0,num1
lw $t1,num2
div $t3,$t0,$t1
li $v0,1
mflo $a0
syscall
Task 5:
Write a program to solve this equation 2+3-4*2 by using registers in MIPS Assembly language.
.data
num1:.word 2
num2:.word 3
num3:.word 4
num4:.word 2
.text
lw $t0,num1
lw $t1,num2
lw $t2,num3
lw $t3,num4
mul $t4,$t2,$t3
sub $t5,$t1,$t4
add $t6,$t0,$t5
li $v0,1
move $a0,$t6
syscall
Comments
Post a Comment