go to previous page   go to home page   go to next page hear noise


In MIPS, 32 zero bits.

Traversing a Linked List

Let us write a program that visits every node of a linked list and prints out its data. A visit to every node of a data structure is called a traversal. Here is a start on the program:

## linked.asm --- hard-coded linked list
          .globl main
             $s0,elmnt01    # get the address of
                                   # the first node
loop:     beqz   $s0,done       # while not null

          . . .          

          . . .

elmnt01:  .word  1
          .word  elmnt02

elmnt02:  .word  2
          .word elmnt03 

          . . . 

The first statement loads register $s0 with the address of the first node.


Which instruction should fill the blank in the first statement: