;*************************** AMUS Program Label ******************************
; Filename: DSPMSG.M68                                      Date: 08/18/92
; Category: UTIL         Hash Code: 734-001-303-440      Version: 1.0(100)
; Initials: IPC/AM       Name: ROBERT B. BONNELL
; Company: IPC GROUP                               Telephone #: 6166989423
; Related Files:
; Min. Op. Sys.: AMOSL 1.3D/AMOS32 1.0D        Expertise Level: INT
; Special:
; Description: DECODES SYSMSG NUMBERS
;*****************************************************************************
;
; USAGE: DSPMSG MSG# <msg# ...# msg#>
;        (separate optional numbers with a space,comma,tab)
;
; Most, if not all, systems have SYSMSG.ldf loaded into system memory.
; But, if the boot process stops (for whatever reason) before it makes
; it to the SYSTEM SYSMSG.ldf line, all you'll get are numbers when an
; error occurrs. DSPMSG will decodes those cryptic numberic messages for
; you.
;
; Written by: Robert B. Bonnell
;             IPC Group, Grand Rapids, MI 49508
;
;          Copyright (C) 1992, Robert B. Bonnell, All rights reserved
;
; Edit History:
;
;[100] 18 August 1992 21:53     Edited by RBB
;       created
;

       SEARCH  SYS                     ; search the usual
       SEARCH  SYSSYM
       SEARCH  LIB

       VMAJOR=1.
       VMINOR=0.
       VEDIT=100.

       .OFINI                          ; define variables
       .OFDEF  BUFFER,80.              ; one called BUFFER
       .OFSIZ  IMPSIZ                  ; end of the list

HDR:    PHDR    -1,0,PH$REE!PH$REU      ; Program is Re-entrant & Re-useable

       JMP     START
       ASCIZ   / Copyright (C) 1992, Robert B. Bonnell /

START:  GETIMP  IMPSIZ,A5,NOMEM         ; get some memory

; get the message number(s) from the command line
;
       BYP                             ; by-pass spaces/tabs
       LIN                             ; end of line ?
       JEQ     USAGE                   ; - yes, explain command usage
       NUM                             ; are we looking at a number ?
       JNE     USAGE                   ; - no, explain command usage
       GTDEC                           ; get decimal number
       CMP     D1,#0.                  ; is it <= to zero ?
       JLE     USAGE                   ; - yes
       CMP     D1,#260.                ; is it > than 260 ?
       JGE     USAGE                   ; - yes
       CRLF                            ;
       TYPE    <?>                     ; typical error msg fashion
       CALL    DSPMSG                  ; range ok, display 1st message

; keep looking on the command line for additional numbers
;
LOOP:   CALL    GETNXT                  ; go for another number
       LIN                             ; end of the line ?
       JEQ     EXIT                    ; - yes
       GTDEC                           ; get decimal number
       CMP     D1,#0.                  ; is it <= to zero ?
       JLE     USAGE                   ; - yes
       CMP     D1,#260.                ; is it > than 260 ?
       JGE     USAGE                   ; - yes
       CALL    DSPMSG                  ; range ok, display next message
       BR      LOOP                    ; back for more

; display the encoded message on the crt. SMSG uses A1, A2
;
DSPMSG: PUSH    A2                      ; hang onto our command line pointer
       LEA     A2,BUFFER(A5)           ; point A2 to BUFFER variable
       PUSH    A2                      ; save this pointer on stack
       MOV     A2,A1                   ; copy pointer to A1
       SMSG    D1,OT$MEM               ; put the message into BUFFER
       CLRB    @A2                     ; end message with null

; SMSG includes a " Message #..." string. Strip it off
;
10$:    CMPB    @A1,#0                  ; at end of message?
       BEQ     20$                     ; - yes, type it out to the screen
       CMPB    (A1)+,#40               ; find a space ?
       BNE     10$                     ; - no, check the next character
       CMPB    @A1,#'M                 ; found space, how about "M" ?
       BNE     10$                     ; - no
       CLRB    @A1                     ; - yes, end the message right here

; Message is now ready to be displayed
;
20$:    POP     A2                      ; restore pointer to start of BUFFER
       TTYL    @A2                     ; type message up to the NULL
       POP     A2                      ; now point back to our command line
       RTN                             ;

; Explain the usage of this command
;
NOMEM:  TYPECR  Not enough memory to use this command
       BR      EXIT

; Explain the how this command is used
;
USAGE:  CRLF                            ;
       CRLF                            ;
       TYPECR  Usage: DSPMSG MSG# <<msg# ...# msg#>>

; exit to amos
;
EXIT:   CRLF                            ;
       CRLF                            ;
       NAME    HDR                     ; display the program name directly
       LEA     A3,CRIGHT               ; point to the copyright line
       TTYL    @A3                     ; output it to the crt
       CRLF                            ;
       EXIT                            ; return to AMOS

; bypass spaces/tabs and commas in command line
;
GETNXT: BYP                             ; bypass spaces/tabs
       CMPB    @A2,#<',>               ; comma present ?
       BNE     10$                     ; - no
       INC     A2                      ; - yes, bypass it
       BYP                             ; bypass spaces/tabs
10$:    RTN                             ; return

CRIGHT: ASCIZ   / Copyright (C) 1992, Robert B. Bonnell /

       END