IMG_20230118_103120.jpg

Exercice 2 :

Exercice 1 :

.DATA

prompt_A: .asciiz "Enter integer A: "
prompt_B: .asciiz "Enter integer B: "
.text
.globl main
main :

li $v0, 4        # Print string system call
la $a0, prompt_A # Load address of prompt_A into $a0
syscall          

# Read integer A from user input
li $v0, 5        
syscall         
move $s0, $v0    

# Prompt the user to enter B
li $v0, 4        
la $a0, prompt_B 
syscall          

# Read integer B from user input
li $v0, 5        
syscall          
move $s1, $v0    

# Calculate A+2B-5 and store the result in $s2
sll $s1, $s1, 1  
add $s2, $s0, $s1 
addi $s2, $s2, -5 

# Print the result to the console
li $v0, 1        
move $a0, $s2    
syscall          

# End the program
li $v0, 10       # Exit system call
syscall          # Terminate the program