tari

Untitled

Feb 13th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. # Lab 3 test driver. Insert your intersect routine following the intersect
  2. # label, run driver.sh with the name of this file as the only argument.
  3.  
  4. .text
  5. j DRIVER
  6.  
  7. intersect:
  8. # Insert your code here
  9.  
  10.  
  11. ## Test driver
  12. # DO NOT MODIFY BELOW THIS LINE
  13. DRIVER:
  14. la $a0, lista
  15. jal DRIVER_dlist
  16.  
  17. la $a0, listb
  18. jal DRIVER_dlist
  19.  
  20. la $a0, lista
  21. la $a1, lista_tail
  22. la $a2, listb
  23. la $a3, listb_tail
  24. jal intersect
  25.  
  26. move $a0, $v0
  27. jal DRIVER_dlist
  28.  
  29. li $v0, 10
  30. syscall
  31.  
  32. # Display the list pointed to by $a0
  33. DRIVER_dlist:
  34. move $t0, $a0
  35. li $a0, '['
  36. li $v0, 11
  37. syscall # print_character('[')
  38.  
  39. DRIVER_dlist_next:
  40. lw $t0, 8($t0) # Next node
  41. lw $t1, 8($t0)
  42. beq $t1, -1, DRIVER_dlist_done # Stop if node's next is NULL
  43. lw $a0, ($t0)
  44. li $v0, 1
  45. syscall # print_integer(node)
  46. li $a0, ' '
  47. li $v0, 11
  48. syscall # print_character(' ')
  49. j DRIVER_dlist_next
  50.  
  51. DRIVER_dlist_done:
  52. li $v0, 11
  53. li $a0, ']'
  54. syscall # print_character(']')
  55. li $v0, 11
  56. li $a0, '\n'
  57. syscall
  58. jr $ra
  59.  
  60.  
  61. .data
  62. .align 2
  63. #lista: # [1, 2], shuffled about a bit
  64. #lista_0:
  65. # .word 0
  66. # .word -1
  67. # .word lista_1
  68. #lista_2:
  69. # .word 2
  70. # .word lista_1
  71. # .word lista_3
  72. #lista_1:
  73. # .word 1
  74. # .word lista_0
  75. # .word lista_2
  76. #lista_3:
  77. #lista_tail:
  78. # .word 0
  79. # .word lista_2
  80. # .word -1
  81. #
  82. #listb: # [1], again shuffled a bit
  83. #listb_0:
  84. # .word 0
  85. # .word -1
  86. # .word listb_1
  87. #listb_2:
  88. #listb_tail:
  89. # .word 0
  90. # .word listb_1
  91. # .word -1
  92. #listb_1:
  93. # .word 1
  94. # .word listb_0
  95. # .word listb_2
Add Comment
Please, Sign In to add comment