Reputation: 17006
This is my 1st effort towards learning looping in MIPS.
.data
spc: .asciiz ", "
.globl main
main:
li $t0, 0
loop:
bgt $t0, 14, exit # branch if($t0 > 14)
addi $t0, $t0, 1 # $t0++ for loop increment
# print a comma
la $a0, spc # copy spc to $a0 for printing
li $v0, 4 # syscall value for strings
syscall
# repeat loop
j loop
exit:
li $v0, 10 # syscall value for program termination
syscall
Output:
-- program is finished running (dropped off bottom) --
This program is supposed to print 15 commas in the I/O console. That isn't taking place.
What could be the issue?
Ref: MIPS assembly for a simple for loop
Upvotes: 0
Views: 1075
Reputation: 365737
You assembled all your code into the .data
section; you never switched back to .text
.
If you're using MARS, the GUI shows no asm instructions in the disassembly (after assembling). This is why.
Apparently instead of faulting on main
being in a non-executable page, MARS simply decides that the program "dropped off the bottom" as soon as you start it.
Upvotes: 1