.data
    N1: .word   0x4300BCBA
.text
    lw  $a0,    N1          # Load the number
    jal foo                 # call procedure
    add $a0,    $0, $v0     # Move result for printing
    addi    $v0,    $0, 34      # Print hexa
    syscall                 # System call
    addi    $v0,    $0, 10      # Exit 
    syscall                 # System call
foo:        
    sw  $t0,    0($sp)          # Store into the stack
    addi    $sp,    $sp,    -4      # Move pointer
    sw  $t1,    0($sp)
    addi    $t0,    $0, 4       
    addi    $v0,    $0, 0
foo_boucle:
    andi    $t1,    $a0,    0xFF        # x & 0xFF
    bne $t1,    $0, foo_suite   # if (x & 0xFF) != 0
    addi    $v0,    $v0,    1       # res++
foo_suite:
    sra $a0,    $a0,    8       # x = x >> 8
    addi    $t0,    $t0,    -1      # i--
    bne $t0,    $0, foo_boucle  # $v0 != 0 
    lw  $t0,    0($sp)          # Load result into stack
    addi    $sp,    $sp,    4       # Move pointer
    lw  $t1,    0($sp)          # Load $v0 into stack
    jr  $ra             # return function