TITLE REVERSE - type a line with characters reversed. .DECSAV A=1 ;Define a symbolic name for an accumulator P=17 ;And the stack pointer PDLEN==1000 ;Length of the stack PDLIST: BLOCK PDLEN ;Storage for the stack START: RESET% MOVE P,[-PDLEN,,PDLIST-1] ;Set up the stack MOVEI A,"* ;Prompt for input PBOUT% PUSHJ P,REVERS ;Do it once HRROI A,[ASCIZ " "] ;Type a CRLF PSOUT% HALTF% ;Stop JRST START ;If continued, do it again ;;Subroutine read a line and type it out in reverse REVERS: PBIN% ;Read a character CAIN A,^M ;Ignore CR JRST REVERS CAIN A,^J ;Terminate on LF POPJ P, PUSH P,A ;Else save the character CALL REVERS ;Do rest of line POP P,A ;Get back the character PBOUT% ;Output it POPJ P, ;and return END START