MPMC Lab Final
MPMC Lab Final
Laboratory Manual
SRIKAKULAM
ID Number :
Department :
Class :
8
9
10
MIPS 32 Programming
1.
2.
3.
4.
5.
6.
7
8
9
10
Experiment: 1
Code:
ORG 100H ; Set the origin to 100H, the starting address for the program.
MOV CX, 02 ; Load CX with 2, setting up a loop to repeat twice.
MOV SI, 1000H ; Set SI to 1000H, which points to the starting address of the first 16-bit
data.
MOV DI, 2000H ; Set DI to 2000H, which points to the starting address for storing
results.
SR: MOV AX, [SI] ; Move the 16-bit value from the address pointed to by SI into AX.
INC SI ; Increment SI by 1 to point to the next byte (prepares for the next 16-
bit value).
INC SI ; Increment SI again to fully skip the current 16-bit value (total
increment is 2).
MOV BX, [SI] ; Move the next 16-bit value (pointed to by updated SI) into BX.
ADD AX, BX ; Add the values in AX and BX. The result is now in AX.
MOV [DI], AX ; Store the result from AX into the address pointed to by DI.
INC SI ; Increment SI to move to the next data pair for the next iteration.
INC SI ; Second increment to fully skip the current 16-bit value (move to next
16-bit value).
INC DI ; Increment DI by 1 to store the next result in the following 16-bit
address.
INC DI ; Second increment of DI (total increment is 2 for 16-bit spacing).
DEC CX ; Decrease CX by 1 to track the number of iterations left.
JNZ SR ; If CX is not zero, jump back to SR to repeat the process.
Explanation
1. Initialize Registers:
o MOV CX, 02: Sets CX to 2, indicating that the loop will run twice.
o MOV SI, 1000H: Sets SI to the starting addresses 1000H to read the first pair of
16-bit data.
o MOV DI, 2000H: Sets DI to the starting addresses 2000H to store the result.
4. Loop Control:
o DEC CX: Decrements CX by 1, reducing the loop counter.
o JNZ SR: Checks if CX is not zero. If CX is non-zero, it jumps back to SR to repeat
the process.
5. Program Termination:
o INT 21: Ends the program and returns control to the DOS operating system.
o RET: Returns from the subroutine, marking the end of the code.
The code reads and adds pairs of 16-bit values from memory starting at 1000H, stores the
results at 2000H, and repeats this process twice. Each iteration handles the following:
Reads two 16-bit values (one into AX and one into BX).
Adds these values and stores the result at the address pointed to by DI.
Moves to the next pair of values and stores the result in the next memory location.
This process continues for the two iterations specified by the initial value of CX = 2.
Results:
Input:
Output:
Code:
ORG 100H ; Sets the origin to 100H for this program.
MOV SI, 1000H ; Load 1000H into SI (Source Index).
MOV DI, 1010H ; Load 1010H into DI (Destination Index).
MOV CL, 04H ; Load 4 into CL, used as a loop counter (indicating 4 iterations).
MOV BP, 1020H ; Load 1020H into BP, the starting address to store results.
L2: MOV AL, [SI] ; Load the byte from the memory address pointed to by SI into
AL.
ADD AL, [DI] ; Add the byte from the memory address pointed to by DI to
AL.
MOV [BP], AL ; Store the result from AL into the memory address pointed to
by BP.
INC SI ; Increment SI to point to the next byte in memory.
INC DI ; Increment DI to point to the next byte in memory.
MOV AL, 00H ; Set AL to 00H (though this value is overwritten in the next
loop iteration).
INC BP ; Increment BP to point to the next storage location.
LOOP L2 ; Decrement CL and jump to L2 if CL is not zero.
RET ; Return from the program (in this case, return control to the
OS).
Explanation:
2. Loop (L2):
o Load and Add Data:
MOV AL, [SI]: Load the byte from the memory location pointed to by SI
(currently 1000H) into AL.
ADD AL, [DI]: Add the byte from the memory location pointed to by DI
(currently 1010H) to AL. Now AL contains the sum of the two bytes.
Results:
Input:
Output:
Code:
ORG 100H ; Set the code origin at 100H (for COM file).
MOV SI, 1000H ; Load the starting address of the first 4 bytes into SI.
MOV DI, 1010H ; Load the starting address of the second 4 bytes into DI.
MOV BP, 1020H ; Load the starting address where the results will be stored into BP.
MOV AX, 0000H ; Clear AX register (will store the sum of bytes from the first set).
MOV BX, 0000H ; Clear BX register (will store the sum of bytes from the second set).
MOV CL, 04H ; Set the loop counter to 4 (for each byte in the sets).
L1: ADD AL, [SI] ; Add the byte at [SI] to AL (accumulating in AL).
INC SI ; Move to the next byte.
LOOP L1 ; Decrement CL and repeat if CL ≠ 0.
MOV CL, 04H ; Reset the loop counter to 4 for the second set.
L2: ADD BL, [DI] ; Add the byte at [DI] to BL (accumulating in BL).
INC DI ; Move to the next byte.
LOOP L2 ; Decrement CL and repeat if CL ≠ 0.
MOV [BP], AX ; Store the sum of the first set (from AX) at address 1020H.
ADD BP, 02H ; Move BP to the next address (1022H).
MOV [BP], DX ; Store the sum of the second set (from BX) at address 1022H.
HLT ; Halt the execution.
Explanation:
1. Setup:
- ORG 100H: Set the code origin at 100H.
- MOV SI, 1000H: Load starting address of the first 4 bytes into SI.
-MOV DI, 1010H: Load starting address of the second 4 bytes into DI.
- MOV BP, 1020H: Load starting address to store results into BP.
- MOV AX, 0000H and MOV BX, 0000H: Clear AX and BX to store sums.
4. Storing Results:
- MOV [BP], AX: Store the sum of the first set (from AX) at 1020H.
- ADD BP, 02H: Move BP to 1022H.
- MOV [BP], DX: Store the sum of the second set (from BX) at 1022H.
5. End Program:
- HLT: Halt the program.
Results:
Input:
Output:
Code:
ORG 100H ; Set origin to 100H, the starting address for .COM files in DOS
MOV CX, 0003H ; Initialize CX with 3, which will act as a loop counter
MOV SI, 1000H ; Set SI to 1000H, used as a pointer to the memory location
L2: MOV AL, [SI] ; Move the byte at memory address pointed by SI into AL
CMP AL, 09 ; Compare AL with 09H
JZ L3 ; If AL is equal to 09H, jump to L3
JNZ L1 ; If AL is not equal to 09H, jump to L1
Explanation:
1. Set Starting Address:
- ORG 100H: Sets the code origin to 100H, which is the default starting address for .COM
files in DOS.
2. Initialize Registers:
- MOV CX, 0003H: Loads CX register with 0003H, which will act as a loop counter.
Results:
Input:
Output
Code:
I)
ORG 100H ; Set the code origin to address 100H. This is typical in COM programs
for DOS, where code starts at offset 100H in the segment.
MOV AX, 00H ; Initialize AX register to 0. AX will be used to accumulate the sum.
MOV BX, 01H ; Initialize BX register to 1. BX will be incremented and added to AX in
each iteration.
MOV CX, 100H ; Initialize CX register to 256 (in hexadecimal, 100H). CX will be used as
a counter to control the loop's iteration count.
L1: ADD AX, BX ; Add the value of BX to AX. AX accumulates the sum of
BX values in each iteration.
INC BX ; Increment BX by 1, so it adds the next higher number in each
loop iteration.
LOOP L1 ; Decrement CX by 1, and if CX is not zero, jump back to label
L1 to continue the loop, This loop will run 100 times as
specified by the initial value of CX.
INT 3 ; Trigger a breakpoint interrupt. This is typically used for debugging
to stop the program.
RET ; Return from the program. In DOS, this would exit to the operating
system if running as a .COM file.
Results:
Input:
Output
II)
squares.
MOV AL, DL ; Reset AL with the value in DL (which is 0 initially, but will change as
we increment AL).
INC AL ; Increment AL by 1, preparing for the next number to square in the
next iteration.
LOOP L1 ; Decrement CL by 1 and repeat the loop if CL is not zero.
HLT ; Halt the program (end execution).
Explanation:
- ORG 100H: This directive sets the starting address for the program code at `100H`,
commonly used in `.COM` programs.
- MOV CL, 03H: Load 3 into CL. This sets up CL as a loop counter for the LOOP L1 instruction,
Results:
Input:
Output
III)
ORG 100H ; Set the origin to 100H (starting address for code in .COM files)
MOV CL, 03H ; Load 3 into CL. CL will act as the loop counter (run the loop 3 times).
MOV AL, 01H ; Initialize AL to 1. AL will hold the number to be squared.
MOV BL, 00H ; Initialize BL to 0. BL will temporarily hold values for incrementing AL.
MOV DL, 00H ; Initialize DL to 0. DL will be used to hold the value of AL during the
loop.
L1: MOV DL, AL ; Copy AL (the current number to square) into DL for temporary
storage.
MUL AL ; Multiply AL by itself (square it). The result is stored in AX.
MUL AL ; Multiply AL by itself (square it). The result is stored in AX.
ADD BX, AX ; Add the result (AX, the square of AL) to BX. BX accumulates the sum of
squares.
MOV AL, DL ; Reset AL with the value in DL (which is 0 initially, but will change as
we increment AL).
INC AL ; Increment AL by 1, preparing for the next number to square in the
next iteration.
LOOP L1 ; Decrement CL by 1 and repeat the loop if CL is not zero.
HLT ; Halt the program (end execution).
Results:
Input:
Output
Code:
ORG 100H ; Set the origin to 100H (starting address for code in .COM files)
MOV CL, 04H ; Load 4 into CL. CL will act as a loop counter, meaning the loop will run
4 times.
MOV SI, 1000H ; Initialize the source index (SI) to memory address 1000H. This points
to the start of the byte sequence.
MOV AL, [SI] ; Load the first byte at memory address [SI] (1000H) into AL. AL will
store the maximum value found.
DEC CX ; Decrement CX by 1, since we've already loaded the first byte into AL.
L1: INC SI ; Increment SI to point to the next byte in memory.
CMP AL, [SI] ; Compare the current maximum value in AL with the byte at
[SI].
JC L2 ; If AL is less than [SI], jump to L2 to update AL with the new
maximum.
MOV AL, [SI] ; (This line is only reached if AL is greater than or equal to [SI]).
Update AL with the new maximum value.
L2: LOOP L1 ; Decrement CX by 1 and repeat the loop if CX is not zero.
RET ; Return from the program (end execution).
Explanation:
ORG 100H: This directive sets the starting address for the program at 100H, which is
commonly used in .COM programs.
Results:
Input:
Output
Code:
ORG 00H ; Set the origin to 00H (starting address for the code).
MOV CL, 04H ; Load 4 into CL. CL will act as a loop counter, indicating the number of
bytes to compare.
MOV SI, 1000H ; Initialize SI with the memory address 1000H. This is the starting point
Explanation:
ORG 00H: This sets the origin (starting point) for the code at address 00H. This
is typical for small programs that don’t rely on DOS segments.
MOV CL, 04H: Loads 4 into CL. This value acts as a loop counter, so the loop will
iterate 4 times, scanning 4 bytes in memory.
MOV SI, 1000H: Initializes SI to 1000H, which points to the start of the memory
range where the bytes are located.
MOV AL, [SI]: Loads the first byte from the memory address [SI] (1000H) into
AL, initially assuming it to be the maximum value.
L3: CMP AL, [SI+1]: Compares the current maximum value in AL with the next
byte in memory ([SI+1]).
JC L1: If the byte at [SI+1] is greater than the current maximum (in AL), the JC
(Jump if Carry) instruction jumps to L1, where AL is updated with this new
maximum.
INC SI: Increments SI to move to the next byte in memory for the next
comparison.
DEC CL: Decrements CL (the loop counter) by 1.
JZ EXIT: If CL reaches zero, it means all bytes have been checked, so JZ (Jump if
Zero) transfers control to the EXIT label to finish the program.
JMP L3: Jumps back to L3 to continue comparing the next byte.
L1: MOV AL, [SI+1]: If a new maximum was found, update AL with this new
value.
DEC CL: Decrement the loop counter CL.
INC SI: Increment SI to point to the next byte in memory.
JNZ L3: Jump back to L3 if CL is not zero, meaning there are more bytes to
compare.
INT 3: Triggers a software interrupt used for debugging, often pausing
execution in a debugger.
EXIT: INT 3: Another debugging interrupt, indicating the end of the program.
RET: Ends the program and returns control to the operating system.
Input:
Output:
Experiment 8:
Aim: Write an assembly language code to implement sorting in ascending order
Code:
ORG 100H ; Set the origin to 100H (starting address for the code in .COM
files)
MOV CH, 05H ; Load 5 into CH. This is the outer loop counter, representing the
number of passes in the sort.
LOOP2: MOV CL, 05H ; Start of outer loop. Load 5 into CL. CL is the inner loop
counter, representing the number of comparisons in each
pass.
MOV SI, 2000H ; Initialize SI to memory address 2000H. This points to the
start of the data to be sorted.
LOOP1: MOV AL, [SI] ; Load the current byte at [SI] into AL.
MOV BL, [SI+1] ; Load the next byte (at [SI+1]) into BL.
CMP AL, BL ; Compare the current byte (AL) with the next byte (BL).
JC EXIT ; If AL is less than BL, jump to EXIT (no swap needed since
they're in order)
MOV DL, [SI+1] ; If AL is greater than BL, prepare to swap them by loading
BL into DL.
XCHG [SI], DL ; Exchange the byte at [SI] (AL) with DL (which holds
[SI+1]).
MOV [SI+1], DL ; Store DL back into [SI+1], completing the swap.
Explanation:
ORG 100H: Sets the origin (starting point) of the code at address 100H, which
is common for .COM programs.
MOV CH, 05H: Loads 5 into CH, which serves as the outer loop counter. This
means the outer loop will perform 5 passes over the data to ensure all
elements are sorted.
LOOP2: MOV CL, 05H: The outer loop starts here. Each time LOOP2 begins, it
reloads CL with 5, setting up the inner loop to perform 5 comparisons.
MOV SI, 2000H: Initializes SI to point to the starting address 2000H in memory,
where the data sequence begins.
MOV AL, [SI]: Loads the byte at the current SI address into AL, representing the
first of a pair of bytes to compare.
MOV BL, [SI+1]: Loads the byte at SI+1 into BL, representing the second byte in
the pair to compare.
CMP AL, BL: Compares AL (first byte) with BL (second byte).
JC EXIT: If AL is less than BL, no swap is necessary because the bytes are in
order. JC (Jump if Carry) skips the swap and jumps to EXIT.
MOV DL, [SI+1]: If AL is greater than BL, prepare to swap by loading the byte at
SI+1 into DL.
XCHG [SI], DL: Exchanges the value in DL (which holds BL) with the byte at [SI],
swapping the values at [SI] and [SI+1].
MOV [SI+1], DL: Writes the swapped value back to [SI+1], completing the
exchange of adjacent bytes.
DEC CH: Decrements the outer loop counter CH. This reduces the number of
remaining passes by 1.
JNZ LOOP2: If CH is not zero, jump back to LOOP2 to start another pass through
the data.
INT 3: Triggers a software interrupt for debugging, pausing the program if in a
debugging environment.
Results:
Input:
Output:
Code:
ORG 100H ; Set the origin to 100H (starting address for the code in .COM
files)
MOV CH, 04H ; Load 4 into CH. This is the outer loop counter, indicating the
number of passes needed for sorting.
LOOP1: MOV CL, 04H ; Start of the outer loop. Load 4 into CL, which is the inner
loop counter.
MOV SI, 2000H ; Initialize SI to memory address 2000H. This points to the
start of the data sequence.
MOV AL, [SI] ; Load the first byte from memory (at address [SI]) into AL,
the first byte to compare.
LOOP2: MOV BL, [SI+1] ; Load the next byte (at address [SI+1]) into BL.
CMP AL, BL ; Compare the current byte in AL with the next byte in BL.
JNC LOOP3 ; If AL is less than or equal to BL, no swap is needed; jump
to LOOP3 to move to the next byte.
MOV DL, [SI+1] ; If AL is greater than BL, swap them. Load BL (the byte at
[SI+1]) into DL.
XCHG [SI], DL ; Exchange the value in DL with the byte at [SI], effectively
swapping AL and BL.
MOV [SI+1], DL ; Store DL back into [SI+1], completing the swap.
LOOP3: INC SI ; Move SI to the next byte in memory.
Explanation:
ORG 100H: This sets the starting address for the program to 100H, typical for
small assembly programs in .COM format.
MOV CH, 04H: Loads 4 into CH, which is used as the outer loop counter,
representing the number of passes over the data to ensure it is sorted.
LOOP1: MOV CL, 04H: Begins the outer loop, where CL is set to 4 each time.
This value serves as the inner loop counter, representing the number of
comparisons per pass.
MOV SI, 2000H: Sets SI to point to 2000H, the start address of the byte
sequence in memory.
MOV AL, [SI]: Loads the byte at [SI] into AL. This byte will be compared with
the next byte in the sequence.
LOOP2: MOV BL, [SI+1]: Loads the byte at [SI+1] into BL for comparison with
AL.
CMP AL, BL: Compares the byte in AL with the byte in BL.
JNC LOOP3: If AL is less than or equal to BL, jump to LOOP3 to move to the next
byte pair without swapping.
MOV DL, [SI+1]: If AL is greater than BL, load the byte in BL into DL to prepare
for a swap.
LOOP3: INC SI: Increments SI to move to the next byte pair in memory.
DEC CL: Decreases the inner loop counter CL.
JNZ LOOP3: If CL is not zero, jump back to LOOP3 to compare the next pair of
bytes.
DEC CH: Decrements the outer loop counter CH after completing an inner loop
pass.
JNZ LOOP1: If CH is not zero, repeat the outer loop (another sorting pass over
the entire array).
INT 3: Triggers an interrupt for debugging, pausing the program if run in a
debugger.
Results:
Input:
Output:
Code:
ORG 100H ; Set the origin to 100H (starting address for the code in .COM
files)
MOV AX, 01H ; Initialize AX to 1. AX will hold the running factorial result.
MOV CX, 05H ; Load 5 into CX. CX acts as the loop counter for the factorial
calculation.
MOV BX, 01H ; Initialize BX to 1. BX will hold the current multiplier in each loop
iteration.
L1: MUL BX ; Multiply AX by BX. The result (AX * BX) is stored in AX.
INC BX ; Increment BX by 1 for the next multiplication.
LOOP L1 ; Decrement CX by 1. If CX is not zero, repeat the loop (jump back
to L1).
HLT ; Halt the program (end of execution).
Explanation
ORG 100H: Sets the starting address for the code at 100H, which is common
for .COM files in DOS.
MOV AX, 01H: Initializes AX to 1. AX will hold the running result of the
factorial calculation.
Loop (L1)
L1: MUL BX: Multiplies AX by BX, storing the result back in AX. This
progressively builds up the factorial:
o In the first iteration, AX = 1 * 1 = 1.
o In the second iteration, AX = 1 * 2 = 2.
o In the third iteration, AX = 2 * 3 = 6.
o In the fourth iteration, AX = 6 * 4 = 24.
o In the fifth and final iteration, AX = 24 * 5 = 120.
INC BX: Increments BX by 1 to use the next integer in the sequence for the
following multiplication.
LOOP L1: Decrements CX by 1. If CX is not zero, LOOP jumps back to L1 to
repeat the loop. After 5 iterations, CX reaches zero, and the loop ends.
HLT: Halts the program, ending execution.
Results:
Input:
Output:
Aim: Write MIPS Program to add two numbers in memory and store the result in the next
location
Code:
.text
.globl main
main: la $t0,value
lw $t1,0($t0)
lw $t2,4($t0)
add $t3,$t1,$t2
sw $t3,8($t0)
.data
value: .word 50 30 0
Results:
Input:
Experiment 2:
Aim:Write MIPS Program to add two constant numbers specified as immediate data and
store the result in a register
Code:
.text
.globl main
main: add $t1, $zero, 0x2A
add $t2, $zero, 0xD0
add $s3, $t1, $t2
Result:
Input:
Output:
Aim:Write MIPS Program to add two constant numbers specified as immediate data and
store the result in a register (use system call to exit)
Code:
.text
.globl main
main: add $t1, $zero, 0x2A
add $t2, $zero, 0xD0
add $s3, $t1, $t2
li $v0, 10
Syscall
Result:
Input:
Experiment 4:
Aim:Write MIPS Program to read two numbers from the keyboard and print the sum
Code:
.data
str1: .asciiz "Enter the first number:"
str2: .asciiz "Enter the second number:"
str3: .asciiz "The Sum is = :"
.text
.globl main
main: li $v0,4
la $a0,str1 #print string
syscall
li $v0, 5 #read_integer
syscall
move $t0,$v0
li $v0,4
la $a0,str3
syscall
li $v0,1
move $a0,$t1
syscall
li $v0,10
syscall
Result:
Input:
Output
Code:
.data
num: .word 1 2 3 4 5 6 7 8 9 10
.text
.globl main
main: la $t0, num
li $t2,0 #to store sum of the value
li $t3,0 #count number
loop: lw $t1, 0($t0)
add $t2, $t2, $t1
addi $t3, $t3,1
addi $t0, $t0,4 # point to next
bne $t3,10,loop
li $v0,10
Result:
Input:
Output
Experiment 6:
Code:
.data
num: .word 0
msg: .asciiz "Enter the number"
msg1: .asciiz "Palindrome"
msg2: .asciiz "Not a Palindrome"
.text
.globl main
main: li $v0,4
la $a0, msg
syscall
li $v0,5
syscall
move $t0,$v0
bne $t3,$t2,np
li $v0,4
la $a0,msg1
syscall
li $v0,10
syscall
np:
li $v0,4
la $a0,msg2
syscall
li $v0,10
syscall
Result:
Input:
Output
Program:
.data
num1:word 14
num2:word 15
num3:word 0
.text
.global main
main:
lw $t0,num1
lw $t1,num2
jal sumfunc
sw $t1,sum
li $v0,10
syscall
Sumfunc:
add $t1, $t1, $t0
Experiment 8:
Code:
.data
prompt: .asciiz "Enter the number of Fibonacci numbers to generate: "
newline: .asciiz "\n"
.text
.globl main
main:
# Prompt user to input the number of Fibonacci terms
li $v0, 4 # Syscall: print string
la $a0, prompt # Address of prompt string
syscall
fib_loop:
# Print the current Fibonacci number ($t1)
li $v0, 1 # Syscall: print integer
move $a0, $t1 # Load $t1 into $a0
syscall
# Print a newline
li $v0, 4
la $a0, newline
syscall
exit:
li $v0, 10 # Syscall: exit program
syscall
Input:
Output
Experiment 9:
Code:
.data
numbers: .word 8, 100, 0, 3, 7 # Array to be sorted
size: .word 5 # Size of the array
message: .asciiz "Sorted Array: " # Message to be printed
newline: .asciiz "\n"
.text
.globl main
main:
la $s7, numbers # Load address of the array into $s7
lw $s6, size # Load the size of the array into $s6
# Bubble Sort
li $s0, 0 # Outer loop counter
inner_start:
li $s1, 0 # Inner loop counter
la $t0, numbers # Reset $t0 to the start of the array
inner_loop:
sub $t2, $s6, $s0 # Calculate the number of comparisons
sub $t2, $t2, 1 # t2 = size - outer loop counter - 1
bge $s1, $t2, outer_increment # If inner loop counter >= size - s0 - 1, end inner loop
skip_swap:
addi $t0, $t0, 4 # Move to the next pair
addi $s1, $s1, 1 # Increment inner loop counter
j inner_loop # Repeat inner loop
outer_increment:
addi $s0, $s0, 1 # Increment outer loop counter
j outer_loop # Repeat outer loop
# Print message
li $v0, 4 # Syscall: print string
la $a0, message
syscall
print_loop:
lw $t4, 0($s7) # Load current number into $t4
li $v0, 1 # Syscall: print integer
move $a0, $t4
syscall
# Exit program
li $v0, 10 # Syscall: exit
syscall
Result:
Output
Experiment 10:
Aim: Write a MIPS 32 program to implement Different ALU operations between two
numbers based on the user given data?
Code:
.data
str1: .asciiz"enter the first number:"
str2: .asciiz"enter the second number:"
str3: .asciiz"which operation you want:\n1-sum of two numbers\n2-diference of two
numbers\n3-product of two numbers\n4-the AND operation\n5-the OR operation\
nenter the number :"
str4: .asciiz"\nthe sum of two numbers is:"
str5: .asciiz"\nthe difference of two numbers is:"
str6: .asciiz"\nthe product of two numbers is:"
str7: .asciiz"\nthe AND operation is:"
str8: .asciiz"\nthe OR operation is:"
str9: .asciiz"\nplease enter the correct number(1,2,3,4,5):"
.text
.globl main
main: li $v0,4
la $a0,str1
syscall
li $v0,5
li $v0,4
la $a0,str2
syscall
li $v0,5
syscall
move $t1,$v0
li $v0,4
la $a0,str3
syscall
first:
li $v0,5
syscall
move $t2,$v0
beq $t2,1,case1
beq $t2,2,case2
beq $t2,3,case3
beq $t2,4,case4
beq $t2,5,case5
j default_case
case5: or $t7,$t0,$t1
li $v0,4
la $a0,str8
syscall
li $v0,1
move $a0,$t7
syscall
j end
default_case: li $v0,4
la $a0,str9
end:
li $v0,10
syscall
Result:
Input:
Output: