I have an assignment to do a linked list in mips, but i cant find a good starting point, can someone offer some insignt, and also wouldi t ever be useful to use a linked list in mips?

Recommended Answers

All 2 Replies

Same as linked lists in C, but with more attention to the detail of managing memory and pointers.

Or get a version of GCC which targets MIPS, then study the output of
gcc -S prog.c

ok i got the print list to work but for the add function i can't figure out the logic of how to find the previous node, here is my code so far:

.data
.word 0x10010018, 0x2, 0x10010020, 0x6, 0x10010028, 0xa, 0x10010008, 0x4, 0x10010010, 0x8,
0x00000000, 0xc
list: .word 0x10010000
newline: .asciiz "\n"
blank: .asciiz " "
.align 2
alloc:

.text

addi $t0, $0, 7
addi $t3, $0, 0x10010064
sw $t0, ($t3)


PrintList:
lw $a1, list

runagain:
lw $a2, ($a1)
li $v0, 1 # system call code for print_int
lw $a0, 4($a1)
syscall # print integer
move $a1, $a2
li $v0, 4
la $a0, newline
syscall
bgt $a1, $0, runagain


Add:
lw $a1, list
runagain1:
lw $a2, ($a1)
lw $a0, 4($a1)
move $t1, $a1
move $a1, $a2

la $t2, ($a0)
bgt $t0, $a0, runagain1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.