Guest User

Untitled

a guest
Mar 10th, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .text
  2. .globl check_remaining_columns
  3. check_remaining_columns:
  4.                 ## $a0 = matrix
  5.                 ## $a1 = list
  6.                 ## $a2 = bitmask
  7.  
  8.     sub $sp, $sp, 28    ## getting memory space
  9.     sw $ra, 0($sp)      ## storing ra into stack frame
  10.     sw $s0, 4($sp)      ## getting space for s0
  11.     sw $s1, 8($sp)      ## getting space for s1
  12.     sw $s2, 12($sp)     ## getting space for s2
  13.     sw $s3, 16($sp)     ## getting space for s3
  14.     sw $s4, 20($sp)     ## getting space for s4
  15.     sw $s5, 24($sp)     ## getting space for s5
  16.  
  17.     move $s0, $a0       ## s0 = matrix
  18.     move $s1, $a1       ## s1 = list
  19.     move $s5, $a2       ## s5 = bitmask
  20.  
  21.     li $s2, 0       ## s2 = i = 0
  22.     lw $s3, 0($s1)      ## $s3 = list->size
  23.     li $s4, 1       ## 1L: which means that it is a long that can be treated as an int.
  24.  
  25. for:    bge $s2, $s3, end1  ## branch if i >= list->size
  26.     sllv $t1, $s4, $s2  ## 1L << i
  27.     and $t2, $t1, $s5   ## (1L << i) & bitmask. This is 1 or 0.
  28.     li $t3, 0       ## t3 = 0 to compare in if-statement
  29.     beq $t3, $t2, next  ## if (1L << i) & bitmask == 0 then continue to next iteration.
  30.     add $s2, $s2, 1
  31.     j for
  32.    
  33. next:   move $a0,$s0        ## a0 = s0 = matrix
  34.     move $a1,$s1        ## a1 = s1 = list
  35.     move $a2,$s2        ## a2 = s2 = i = row   
  36.     jal any_matrix_column_matches_list_row  ## $v0 = 1 or 0
  37.     ##move $s7, $v0
  38.     li $t0, 0       ## $t0 = 0 to compare in if-loop
  39.     beq $t0, $v0, end2  ## if ($v0 = 0) then branch to end2
  40.     li $v0, 0       ## return 0
  41.     j stack         ## jump to stack to put memory back
  42.     jr $ra          ## return address
  43.     add $s2, $s2, 1     ## ++i
  44.     j for           ## jumps to for loop
  45.  
  46.    
  47.  
  48. end1:   li $v0, 1       ## return 1
  49.     j stack         ## jump to stack to put memory back
  50.     jr $ra          ## return address
  51.  
  52. end2:   add $s2, $s2, 1     ## ++i
  53.     j for           ## jumps to for loop
  54.  
  55. stack:  lw $ra, 0($sp)      ## ra into stack frame
  56.     lw $s0, 4($sp)      ## space for s0
  57.     lw $s1, 8($sp)      ## space for s1
  58.     lw $s2, 12($sp)     ## space for s2
  59.     lw $s3, 16($sp)     ## space for s3
  60.     lw $s4, 20($sp)     ## space for s4
  61.     lw $s5, 24($sp)
  62.     add $sp, $sp, 28    ## putting space back into stack frame
  63.     jr $ra          ## return address
Advertisement
Add Comment
Please, Sign In to add comment