laser
margin 1"
topmargin 1"
bottommargin 1"
font courier
points 7


;*******************************
; HOD - simple convert program
;
; by DAVE HEYLIGER - AMUS Staff
;
; written for AAA
;*******************************

       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  TRM
       SEARCH  STSWRD

       PHDR    -1,0,PH$REE!PH$REU

TOP:    PRTTAB  -1,0                            ;clear the screen
       PRTTAB  5,5                             ;tab to here
       TYPE    <Enter desired input base (H, O, D): >  ;ask for choice
       ONEKEY                                  ;no CR - key in D1
       KBD                                     ;get choice
       CTRLC   EXIT                            ;^C quits

       UCS                                     ;upper case the keystroke
       MLTKEY                                  ;KBD needs a CR now...

       CMPB    D1,#'H                          ;ON keystroke GOTO...
       JEQ     HEXINP
       CMPB    D1,#'O
       JEQ     OCTINP
       CMPB    D1,#'D
       JNE     EXIT

       ;you end up here on a "D" selection
       PRTTAB  7,5                             ;tab to here
       TYPE    <Enter the desired decimal number to convert: > ;ask for input
       KBD                                     ;wait for CR
       GTDEC                                   ;get number
       JMI     ERROR                           ;ERROR if too big
       HEX                                     ;set HEX
       PRTTAB  9.,5                            ;tab to here
       TYPE    <   hex: >                      ;label output
       OCVT    0,OT$TRM                        ;type it out
       OCTAL                                   ;set OCTAL
       PRTTAB  10.,5                           ;tab to here
       TYPE    < octal: >                      ;label output
       OCVT    0,OT$TRM                        ;type it out
       JMP     MORE                            ;see if user wants a repeat

       ;you end up here on a "H" selection
HEXINP: PRTTAB  7,5
       TYPE    <Enter the desired hex number to convert: >
       HEX
       KBD
       GTOCT
       JMI     ERROR
       PRTTAB  9.,5
       TYPE    <decimal: >
       DCVT    0,OT$TRM
       OCTAL
       PRTTAB  10.,5
       TYPE    <  octal: >
       OCVT    0,OT$TRM
       JMP     MORE

       ;you end up here on a "O" selection
OCTINP: PRTTAB  7,5
       TYPE    <Enter the desired octal number to convert: >
       OCTAL
       KBD
       GTOCT
       JMI     ERROR
       HEX
       PRTTAB  9.,5
       TYPE    <     hex: >
       OCVT    0,OT$TRM
       PRTTAB  10.,5
       TYPE    < decimal: >
       DCVT    0,OT$TRM

       ;come here after a display
MORE:   ONEKEY                                  ;KBD needs one keystroke
       PRTTAB  15.,5                           ;tab to here
       TYPE    <Type C to repeat, or any other key to quit: > ;prompt user
       KBD                                     ;get the keystroke
       UCS                                     ;upper case the input
       CMPB    D1,#'C                          ;is it a "C"?
       BNE     EXIT                            ;nope
       JMP     TOP                             ;yup, repeat program

       ;come here on an error
ERROR:  CRLF                                    ;CRLF
       TYPECR  <?ERROR - not a valid number.>  ;error message!

       ;here on quit or after error message is displayed
EXIT:   CRLF                                    ;CRLF
       EXIT                                    ;bye!
       END                                     ;end of source code