VEDIT = 3 ; edit level, change every time
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;* *
;* Copyright (c) 1986 by Software Designs, PO Box 9227, Spokane WA 99209 *
;* All rights reserved. Phone: (509) 326-2480. *
;* Written by Tom Faust, author of RELIEF Input Line Editor. *
;* *
;* This program may be "freely" copied and used but may never be sold. *
;* *
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;
; Pgm Name: CHR.LIT
;
; Pgm Desc: Display any character in ascii & decimal & (hex or octal).
;
; Version: 1.0(3)
;
; Hash Total: 130-170-010-302
;
; Patch Log
; Version Date Inits Description of Change
; ------- --------- ----- -------------------------------------
; 1.0 17 Nov 83 TGF New.
; (2) 11 Jan 86 TGF Allow toggle of xlt mode.
; (3) 26 Aug 86 TGF Add new ^C message, OCT/HEX, etc.
; Add notice of 'CHR ?' option.
; Fix XLT toggle on/off message
;
RADIX 8 ; code is written in octal
SEARCH SYS
SEARCH SYSSYM
SEARCH TRM
;; program major and minor version = 1.0
VMAJOR = 1 ; program version
VMINOR = 0
;; misc character equates
CTL.C = 3 ; control-C
CR = 15 ; carriage return
SPA = 40 ; space char
DEL = 177 ; del char
;; macro to test a bit in a word (non-destructive)
DEFINE BITW SRC,DST
MOVW DST,D7
ANDW SRC,D7
ENDM
;; macro to define ascii text followed by a CR
DEFINE ASCIIC TEXT
ASCII TEXT
BYTE CR
ENDM
BASE: PHDR -1,0,PH$REE!PH$REU
START: JOBIDX A0 ; Point A6 to job control block
MOV JOBTRM(A0),A5 ; index A5 to terminal control block
MOVW JOBTYP(A0),D4 ; save current...
ANDW #J.HEX,D4 ; ...octal/hex setting (save j.hex)
SWAP D4 ; ...in high order word
MOVW @A5,D4 ; save current...
ANDW #T$XLT,D4 ; ...XLT setting in low order word
ANDW #~T$XLT,@A5 ; be sure it's not set now
10$: ORW #<T$DAT!T$ECS>,@a5 ; Set image mode & echo suppress
TTYL CRIGHT
TYPECR <From AMOS, type 'CHR ?' for usage>
TYPECR <Enter desired character, or type CTRL-C to end.>
RESTRT: TYPE <Chr Dec >
BITW #J.HEX,JOBTYP(A0) ; hex set?
BNE 10$
TYPE <Oct>
BR 20$
10$: TYPE <Hex>
20$: TYPE < XLT >
BITW #T$XLT,@A5 ; is XLT set now?
BEQ 30$
TYPE <On>
BR 40$
30$: TYPE <Off>
40$: CRLF
LOOP: MOVW #1,D0 ; default space count
KBD ; get a character
PUSHB D1
CMPB D1,#DEL ; > del?
BLOS 10$
TYPE <+>
SUBB #200,D1 ; adjust to control or printable char
BR 11$
10$: INCW D0
11$: CMPB D1,#SPA ; less than a space?
BGE 20$
TYPE <^>
ADD #100,D1 ; adjust to printable character
BR 21$
20$: INCW D0
21$: CMPB D1,#177 ; del or greater?
BLO ECHO
TYPE DEL ; (special case)
DECW D0
BR NOECHO
ECHO: TTY ; display the char
DECW D0
BMI NOECHO
10$: TYPE < >
DBF D0,10$
CTLC: TYPE ^C ; display ^C
MOV #7,D1 ; and ring the bell
EXIT: TTY ; display the Y or bell
CRLF
EXIT2: ANDW #~T$XLT,@A5 ; reset t$xlt bit
ORW D4,@A5 ; reset original XLT setting
SWAP D4 ; shift j.hex into position
ANDW #~J.HEX,JOBTYP(A0) ; reset j.hex bit
ORW D4,JOBTYP(A0) ; reset original octal/hex setting
EXIT
USAGE: TTYI
ASCIIC "Usage: CHR {/H/O/T}"
ASCIIC " /H = Display decimal and hex"
ASCIIC " /O = Display decimal and octal"
ASCIIC " /T = Begin in Fkey translation mode"
ASCIIC " ^C to exit"
ASCIIC
ASCIIC " For character display:"
ASCIIC " the symbol ^ signifies a control character"
ASCIIC " the symbol + signifies the parity bit is set"
ASCIIC
CRIGHT: ASCIIC <"Copyright 1983,1986 Software Designs, Spokane, WA">
BYTE 0
EVEN
JMP EXIT2