Professional Documents
Culture Documents
main:
# Display prompt for the first input
li $v0, 4 # Load system call code for printing a string
la $a0, prompt1 # Load the address of the prompt1 string
syscall # Print the prompt
perform_or:
# Perform the binary OR operation
or $t6, $t0, $t3 # Perform OR operation between the two inputs,
result stored in $t6
j print_result # Jump to the print_result section
perform_and:
# Perform the binary AND operation
and $t6, $t0, $t3 # Perform AND operation between the two inputs,
result stored in $t6
j print_result # Jump to the print_result section
perform_add:
# Perform the addition
add $t6, $t0, $t3 # Add the two inputs, result stored in $t6
j print_result # Jump to the print_result section
perform_subb:
# Perform the subtraction
sub $t6, $t0, $t3 # Subtract the second input from the first input,
result stored in $t6
#bgez $t6, slt_not_negative
#li $t6, 0
j print_result # Jump to the print_result section
perform_sll:
# Perform the logical left shift (4 times)
sll $t6, $t0, 4 # Left shift the first input 4 times, result stored
in $t6
j print_result # Jump to the print_result section
perform_srl:
# Perform the logical right shift (4 times)
srl $t6, $t0, 4 # Right shift the first input 4 times, result
stored in $t6
j print_result # Jump to the print_result section
perform_sltt:
# Perform the Set Less Than (SLT) operation
sub $t6, $t0, $t3 # Set $t6 to 1 if $t0 is less than $t3; otherwise,
set to 0
bgez $t6, slt_not_negative # If $t6 is positive or zero, go to
slt_not_negative
li $t6, 0 # If $t6 is negative, set it to 0 (output 0)
j print_result # Jump to the print_result section
slt_not_negative:
li $t6, 1 # If $t6 is positive or zero, set it to 1 (output
1)
j print_result # Jump to the print_result section
print_result:
# Display the result
li $v0, 1 # Load system call code for printing an integer
move $a0, $t6 # Move the result to register $a0
syscall # Print the result