.data
    N1: .word   0x23456789 # First number
    N2: .word   0x98765432 # Second number 
    res:    .word   0      # Response
    # The result must be : 0x65748392
.text
    lw  $a0,    N1      # Correction 1
    lw  $a1,    N2      # Correction 2
    #lw $a0,    0x2000($0)      # Load the first number 
    #lw $a1,    0x2004($0)      # Load the second number
    jal     foo             # Call de function foo
    #sw $v0,    0x2008($0)  # Store value return from foo function
                
    add $a0,    $0, $v0 # Move value into $a0
    addi    $v0,    $0, 34  # Hexa print code
    syscall             # System call
    addi    $v0,    $0, 10  # Exit code
    syscall             # System call
    
foo:    # Function foo
    sw  $t0,    0($sp)     # Store into the stack
    addi    $sp,    $sp,    -4 # Change sp pointer
    sw  $t1,    0($sp)     # Store into the stack
    addi    $sp,    $sp,    -4 # Change sp pointer
    addi    $t0,    $0, 4  # i < 4
    addi    $v0,    $0, 0  # result
fooBoucle: # Start while
    # t0 = 4 
    # v0 = 0
    # a0 = x
    # a1 = y
    beq $t0,    $0, fooFin      # if i == 0 
    srl $v0,    $v0,    8       # res >> 8
    sll $t1,    $a0,    28      # x << 28
    or  $v0,    $v0,    $t1         # res | (x << 28)
    andi    $t1,    $a1,    0xF         # y & 0xF
    sll $t1,    $t1,    24      # (y & 0xF) << 24
    or  $v0,    $v0,    $t1         # (x << 28) | ((y & 0xF)) << 24)
    sra $a0,    $a0,    4       # x = x >> 4
    sra $a1,    $a1,    4       # y = y >> 4
    addi    $t0,    $t0,    -1      # i--
    beq $0, $0, fooBoucle   # while $t0 != 0
fooFin: # End function
    addi    $sp,    $sp,    0 # Move pointer stack
    lw  $a0,    0($sp)    # Load the first value
    addi    $sp,    $sp,    4 # Move pointer stack
    lw  $a1,    0($sp)    # Load second value
    jr  $ra       # Return value