Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Lab 3 test driver. Insert your intersect routine following the intersect
- # label, run driver.sh with the name of this file as the only argument.
- .text
- j DRIVER
- intersect:
- # Insert your code here
- ## Test driver
- # DO NOT MODIFY BELOW THIS LINE
- DRIVER:
- la $a0, lista
- jal DRIVER_dlist
- la $a0, listb
- jal DRIVER_dlist
- la $a0, lista
- la $a1, lista_tail
- la $a2, listb
- la $a3, listb_tail
- jal intersect
- move $a0, $v0
- jal DRIVER_dlist
- li $v0, 10
- syscall
- # Display the list pointed to by $a0
- DRIVER_dlist:
- move $t0, $a0
- li $a0, '['
- li $v0, 11
- syscall # print_character('[')
- DRIVER_dlist_next:
- lw $t0, 8($t0) # Next node
- lw $t1, 8($t0)
- beq $t1, -1, DRIVER_dlist_done # Stop if node's next is NULL
- lw $a0, ($t0)
- li $v0, 1
- syscall # print_integer(node)
- li $a0, ' '
- li $v0, 11
- syscall # print_character(' ')
- j DRIVER_dlist_next
- DRIVER_dlist_done:
- li $v0, 11
- li $a0, ']'
- syscall # print_character(']')
- li $v0, 11
- li $a0, '\n'
- syscall
- jr $ra
- .data
- .align 2
- #lista: # [1, 2], shuffled about a bit
- #lista_0:
- # .word 0
- # .word -1
- # .word lista_1
- #lista_2:
- # .word 2
- # .word lista_1
- # .word lista_3
- #lista_1:
- # .word 1
- # .word lista_0
- # .word lista_2
- #lista_3:
- #lista_tail:
- # .word 0
- # .word lista_2
- # .word -1
- #
- #listb: # [1], again shuffled a bit
- #listb_0:
- # .word 0
- # .word -1
- # .word listb_1
- #listb_2:
- #listb_tail:
- # .word 0
- # .word listb_1
- # .word -1
- #listb_1:
- # .word 1
- # .word listb_0
- # .word listb_2
Add Comment
Please, Sign In to add comment