Specifications

At this point execution of RTS PC returns control to the main
program.
A character is typed in DECTY by loading the teleprinter buffer
(TPB) and waiting for the teleprinter READY flag, the most significant
bit of the low-order byte of the teleprinter status word
(TPS),
to be set.
The symbols CR and LF are assumed equal to the ASCII repre-
sentations for carriage return and line feed respectively.
This’subroutine types the unsigned integer in RO. It illustrates recursion and
the use of stacks.
, DECPNT: MOV #lo., R2
DECREM: JSR PC, IDIVR
MOV Rl, -(SP)
TST RO
BEQ DECTTY
DECTTY:
l-rYOUT:
l-rYLUp:
JSR PC, DECREM
MOV (SP)+, RO
ADD #60, RO
MOV RO, TPB
TST TPS
BPL ll-YLlJP
CMP. #CR, RO
BEQ TI-YLF
RTS PC
T-IYLF: MOV ‘#LF, TPB
BR TTYLUP
;set up divisor of 10
;subroutine divides (RO) by
;W’)
;quotient is in RO, remain-
;der is in Rl
;after pushing remainder
;onto stack test quotient
;if the quotient is 0, we‘re
;done getting remainders
;if not try again
;get next remainder
;make an ASCII character
;type the ASCII character in
;RO
;wait for the teleprinter to
;be done
;TPS
is negative when the
;TP is done
;was the character of a car-
;riage return
;if not: return, if so; get a
;line feed
;returns either to DEClTY
;or main program
;type a line feed
;and wait for it to be corn-
;pleted
4. Multiple entry points-In the example that follows, the subroutines
described above are used to type out all the entries in a table of
unsigned integers that are not within specified tolerance.
.
The subroutine TOLER is entered at TOLER for initialization and at
TLOOP to pick up each bad entry of the array after the first one.
The subroutine DECPNT is entered at DECPNT to print the value of
the unsigned binary number held in RO and at TlYOUT to print the
ASCII character held in RO. TTYOUT prints the carriage return, line
feed sequence when it sees the carriage return character.
This routine types all out-of-tolerance elements of an integer array.
The program starts at TYPOUT.
30