Four levels deep:
main calls doLines which calls convert
which calls conCh.
main SubroutineAn advantage of modular programming is that each subroutine can be displayed and explained independently of the others. Each subroutine can also be tested independently of the others. (This is called unit testing).
Here is the design of main.
.text
.globl main
main:
la $a0,mainPr # prompt the user
li $v0,4 # service 4
syscall
jal doLines # process lines of input
li $v0,10
syscall # return to QTSPIM
.data
mainPr: .ascii "Type each line of text followed by ENTER.\n"
.asciiz "Type Q at the start of a line to finish.\n"
The
main routine calls doLines.
The flowchart shows the design for that routine.
Below is its (incomplete) code.
Fill in the blanks.