There are tons of great examples on how to properly follow MIPS function calling conventions. However, I'm getting stuck on how to use a function only when 'called'. The following will print 51 (using MARS):
.data
strproc: .asciiz "procedure example"
strnl: .ascii "\n"
.text
printnl: li $v0, 1
li $a0, 5
syscall
#jal printnl
li $v0, 1
li $a0, 1
syscall
However, I'd really like to be able to only execute the instructions associated with the printnl
label when jumped and linked to (when 'called'). Is this feasible in MIPS? Feel free to criticize my design inclinations as part of your answer. I'm not sure how I should go about writing a simple assembly program who may have need of a lot of repeated instructions.
I did try this (but it doesn't assemble):
.data
strproc: .asciiz "procedure example"
strnl: .ascii "\n"
printnl: li $v0, 1
li $a0, 5
syscall
.text
li $v0, 1
li $a0, 1
syscall
jal printnl