.TITLE WYL_CNV - Utility string conversion routines  .IDENT /0-01/ ( 2;++ <; F; TITLE: WYLCNV String conversion module group. P; Z; FACILITY: WYLVAX. d; n; ABSTRACT: x; ‚; Procedures to support character string manipulating for IO Œ; and text editing etc. Each conversion routine has the –; following parameter format:  ; 1) Input string, integer etc. ª; 2) Output string, integer etc. ´; 3) Size of output (optional) ¾; È; ENVIRONMENT: Run at any access mode - AST re-entrant Ò; Ü; AUTHOR: Douglas Palmer, CREATION DATE: 26-JUL-1980 æ; ð;-- ú  .PSECT WYL_CODE,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT   .PAGE " .SBTTL WYL_CNV_UPPER - Convert to uppercase characters. , 6;++ 7; 8; FUNCTIONAL DESCRIPTION: @; J; Lowercase characters in specified string are converted to T; uppercase. ^; h; CALLING SEQUENCE: r; |; Sts.wlc.v = WYL_CNV_UPPER(inpstr.wt.dx[,outstr.wt.dx][,outlen.wl.r]) †; ; INPUT PARAMETERS: š; ¤; inpstr Address of source string descriptor. ®; ¸; OUTPUT PARAMETERS: Â; Ì; outstr Optional address of output string descriptor. Ö; If not specified the input string is modified. à; ê; outlen Optional address of longword to accept the number ô; of characters converted and copied. þ; ; COMPLETION STATUS: ; ; WYL__NORMAL Normal successful completion. &; WYL_OUTSTRTRU Output string truncated. 0; :;-- D NINPSTR = 4 XOUTSTR = 8 bOUTLEN = 12 l v .ENTRY WYL_CNV_UPPER,^M € MOVAL G^LIB$SIG_TO_RET, 0(FP) ; Sig to return Š MOVQ @INPSTR(AP), R0 ; R0, R1 <-- Descriptor ” MOVQ R0, R4 ; R4, R5 <-- Descriptor ž CMPB (AP), #2 ; Two args? ¨ BLSS 10$ ² TSTL OUTSTR(AP) ¼ BEQL 10$ Æ MOVQ @OUTSTR(AP), R4 ; R4, R5 <-- Descriptor Ð10$: Ú MOVZWL R0, R6 ; Input length ä MOVAL G^WYL_AB_UPCTBL, R3 î MOVTC R0, (R1), #32, (R3), R4, (R5) ø BLEQ 20$  SUBL2 R0, R6 ; Characters copied  MOVL #WYL__OUTSTRTRU, R0  BRB 30$ 20$: * MOVL #WYL__NORMAL, R0 430$: > CMPB (AP), #3 H BLSS 40$ R TSTL OUTLEN(AP) \ BEQL 40$ f MOVL R6, @OUTLEN(AP) p40$: z RET „ Ž .PAGE ˜ .SBTTL WYL_CNV_LOWER - Convert to lowercase characters. ¢ ¬;++ ­; ®; FUNCTIONAL DESCRIPTION: ¶; À; Uppercase characters in specified string are converted to Ê; lowercase. Ô; Þ; CALLING SEQUENCE: è; ò; Sts.wlc.v = WYL_CNV_LOWER(inpstr.wt.dx[,outstr.wt.dx][,outlen.wl.r]) ü; ; INPUT PARAMETERS: ; ; inpstr Address of source string descriptor. $; .; OUTPUT PARAMETERS: 8; B; outstr Optional address of output string descriptor. L; If not specified the input string is modified. V; `; outlen Optional address of longword to accept the number j; of characters converted and copied. t; ~; COMPLETION STATUS: ˆ; ’; WYL__NORMAL Normal successful completion. œ; WYL_OUTSTRTRU Output string truncated. ¦; °;-- º Ä .ENTRY WYL_CNV_LOWER,^M Î MOVAL G^LIB$SIG_TO_RET, 0(FP) ; Sig to return Ø MOVQ @INPSTR(AP), R0 ; R0, R1 <-- Descriptor â MOVQ R0, R4 ; R4, R5 <-- Descriptor ì CMPB (AP), #2 ; Two args? ö BLSS 10$  TSTL OUTSTR(AP)  BEQL 10$  MOVQ @OUTSTR(AP), R4 ; R4, R5 <-- Descriptor 10$: ( MOVZWL R0, R6 ; Input length 2 MOVAL G^WYL_AB_LOCTBL, R3 < MOVTC R0, (R1), #32, (R3), R4, (R5) F BLEQ 20$ P SUBL2 R0, R6 ; Characters copied Z MOVL #WYL__OUTSTRTRU, R0 d BRB 30$ n20$: x MOVL #WYL__NORMAL, R0 ‚30$: Œ CMPB (AP), #3 – BLSS 40$   TSTL OUTLEN(AP) ª BEQL 40$ ´ MOVL R6, @OUTLEN(AP) ¾40$: È RET Ò Ü .PAGE æ .SBTTL WYL_CNV_CASE - Reverses case of characters. ð ú;++ û; ü; FUNCTIONAL DESCRIPTION: ; ; Lowercase characters in specified string are converted to ; uppercase and uppercase characters are converted to lowercase. "; ,; CALLING SEQUENCE: 6; @; Sts.wlc.v = WYL_CNV_CASE(inpstr.wt.dx[,outstr.wt.dx][,outlen.wl.r]) J; T; INPUT PARAMETERS: ^; h; inpstr Address of source string descriptor. r; |; OUTPUT PARAMETERS: †; ; outstr Optional address of output string descriptor. š; If not specified the input string is modified. ¤; ®; outlen Optional address of longword to accept the number ¸; of characters converted and copied. Â; Ì; COMPLETION STATUS: Ö; à; WYL__NORMAL Normal successful completion. ê; WYL_OUTSTRTRU Output string truncated. ô; þ;--   .ENTRY WYL_CNV_CASE,^M  MOVAL G^LIB$SIG_TO_RET, 0(FP) ; Sig to return & MOVQ @INPSTR(AP), R0 ; R0, R1 <-- Descriptor 0 MOVQ R0, R4 ; R4, R5 <-- Descriptor : CMPB (AP), #2 ; Two args? D BLSS 10$ N TSTL OUTSTR(AP) X BEQL 10$ b MOVQ @OUTSTR(AP), R4 ; R4, R5 <-- Descriptor l10$: v MOVZWL R0, R6 ; Input length € MOVAL G^WYL_AB_CASTBL, R3 Š MOVTC R0, (R1), #32, (R3), R4, (R5) ” BLEQ 20$ ž SUBL2 R0, R6 ; Characters copied ¨ MOVL #WYL__OUTSTRTRU, R0 ² BRB 30$ ¼20$: Æ MOVL #WYL__NORMAL, R0 Ð30$: Ú CMPB (AP), #3 ä BLSS 40$ î TSTL OUTLEN(AP) ø BEQL 40$  MOVL R6, @OUTLEN(AP) 40$:  RET  * .PAGE 4 .SBTTL WYL_CNV_BKSP - Remove backspace characters. > H;++ I; J; FUNCTIONAL DESCRIPTION: R; \; Backspace characters are removed from the string. f; p; CALLING SEQUENCE: z; „; Sts.wlc.v = WYL_CNV_BKSP(inpstr.mt.dx[,outstr.wt.dx][outlen.wt.dx]) Ž; ˜; INPUT PARAMETERS: ¢; ¬; inpstr Address of source string descriptor. ¶; À; OUTPUT PARAMETERS: Ê; Ô; outstr Optional address of output string descriptor. Þ; If omitted the input string is modified. è; ò; outlen Optional address of longword to receive the length of ü; the converted string.  ;  ; COMPLETION STATUS:  ; $ ; WYL__NORMAL Normal successful completion. . ; WYL_OUTSTRTRU Output string truncated. 8 ; B ;-- L V .ENTRY WYL_CNV_BKSP,^M ` MOVAL G^LIB$SIG_TO_RET, 0(FP) ; Sig to return j MOVL #WYL__NORMAL, R10 ; Initial status t MOVQ @INPSTR(AP), R6 ; R6, R7 <-- Descr ~ MOVZWL R6, R6 ; Zero extend ˆ CMPL (AP), #2 ’ BLSS 10$ œ TSTL OUTSTR(AP) ¦ BEQL 10$ ° MOVQ @INPSTR(AP), R0 º MOVQ @OUTSTR(AP), R6 Ä MOVZWL R6, R6 ; Zero extend Î MOVC5 R0, (R1), #^A/ /, R6, (R7) Ø BLEQ 10$ â MOVL #WYL__OUTSTRTRU, R10 ; Status ì 10$: ö LOCC #^X08, R6, (R7) ; Locate BS BEQL 50$ SUBL3 #1, R0, R2 ; R2(SRCLEN)=R0-1  ADDL3 #1, R1, R3 ; R3(SRCADD)=R1+1  CMPL R0, R6 ; R0=LEN? ( BEQL 40$ 2 DECL R6 < DECL R1 F INCL R0 P 40$: MOVC5 R2, (R3), #^X20, R0, (R1) ; Do the move Z DECL R6 d BRB 10$ n 50$: x CMPB (AP), #3 ‚ BLSS 80$ Œ TSTL OUTLEN(AP) – BEQL 80$   MOVL R6, @OUTLEN(AP) ª 80$: ´ MOVL R10, R0 ¾ RET È Ò .PAGE Ü .SBTTL WYL_CNV_OUT_I - Convert longword to characters. æ ð ;++ ñ ; ò ; FUNCTIONAL DESCRIPTION: ú ;  ; Fast routine for converting longword to ascii characters.  ; Routine left justifies the result. Negative values will  ; be signed. " ; , ; CALLING SEQUENCE: 6 ; @ ; Sts.wlc.v = WYL_CNV_OUT_I(integer.rl.r,outstr.wt.dx [,outlen.wl.r]) J ; T ; INPUT PARAMETERS: ^ ; h ; integer Address of longword to be converted to ascii. r ; | ; OUTPUT PARAMETERS: † ; ; outstr Address of source string descriptor. š ; ¤ ; outlen Optional address of longword to receive the output ® ; length. ¸ ;  ; COMPLETION STATUS: Ì ; Ö ; WYL__NORMAL Normal successful completion. à ; WYL__OUTSTRTRU Output string truncated. ê ; ô ;-- þ  INTEGER = 4   .ENTRY WYL_CNV_OUT_I,^M & MOVAL G^LIB$SIG_TO_RET, 0(FP) ; Signal to return 0 SUBL2 #16, SP ; Make room for packed : MOVL SP, R4 ; Packed base address D SUBL2 #20, SP ; Make room for string N MOVL SP, R5 ; String base address X CVTLP @INTEGER(AP), #16, (R4) b CVTPS #16, (R4) ,#16, (R5) l SKPC #^A/0/, #15, 1(R5) ; Find nonzero digit v INCL R0 ; # characters € CMPB (R5), #^A/+/ ; Positive? Š BEQL 20$ ” INCL R0 ; Add sign to length ž DECL R1 ; Add sign to address ¨ MOVB (R5), (R1) ; Move sign ² 20$: ¼ MOVL R0, R6 ; Save length Æ MOVQ @OUTSTR(AP), R2 ; R2, R3 <-- Descr Ð MOVZWL R2, R2 Ú CMPL R0, R2 ; Too big? ä BGTR 40$ î MOVC5 R0, (R1), #32, R2, (R3) ø MOVL #WYL__NORMAL, R0  BRB 60$ 40$:  MOVL R2, R6 ; Truncate MOVC5 #00, (AP), #^A/*/, R2, (R3) ; Asterisk fill * MOVL #WYL__OUTSTRTRU, R0 4 60$: > CMPB (AP), #3 ; Argument 3? H BLSS 80$ R TSTL OUTLEN(AP) \ BEQL 80$ f MOVL R6, @OUTLEN(AP) p 80$: z RET „ Ž .PAGE ˜ .SBTTL WYL_CNV_X_AS - Convert hex to ASCII string. ¢ ¬ ;++ ­ ; ® ; FUNCTIONAL DESCRIPTION: ¶ ; À ; Converts each pair of hexadecimal characters in a string into Ê ; its ASCII equivalent. For example: 574F4E --> NOW. Ô ; Hex characters to be converted must be in uppercase. For Þ ; example: 4e will not be recognized as representing the è ; character 'N'. ò ; ü ; CALLING SEQUENCE: ; ; Sts.wlc.v = WYL_CNV_X_AS(inpstr.rt.dx,outstr.wt.dx[,outlen.wl.r]) ; $; INPUT PARAMETERS: .; 8; inpstr Address of hexadecimal string descriptor. B; L; OUTPUT PARAMETERS: V; `; outstr Address of ASCII output string descriptor. j; t; outlen optional address of longword to receive the resultant ~; string length. ˆ; ’; RETURN CODES: œ; ¦; WYL__INVARG invalid arguments. °; º;-- Ä ÎHEXCHR: Ø .ASCII /0123456789ABCDEF/ â ì .ENTRY WYL_CNV_X_AS,^M ö MOVAL HEXCHR, R11  MOVQ @INPSTR(AP), R4 ; R4, R5 <-- Descr  MOVZWL R4, R4 ; Zero extend length  BEQL X_AS_INVARG  DECL R4 ; R4 <-- Index ( ADDL3 #2, R4, R6 ; R6 = Size + 1 2 ASHL #-1, R6, R6 ; Divide by 2 < CMPW R6, @OUTSTR(AP) ; Out large enuff F BGTR X_AS_INVARG P SUBL2 R6, SP ; Make room on stack Z MOVL SP, R7 ; Base address dX_AS_LOOP: n LOCC (R5)[R4], #16, (R11) ; Convert char x BEQL X_AS_OUTCONERR ‚ SUBL3 R0, #16, R2 ; # Œ SOBGEQ R4, 20$ – BRB 30$  20$: ª LOCC (R5)[R4], #16, (R11) ; Convert hex char ´ BEQL X_AS_OUTCONERR ¾ SUBL3 R0, #16, R0 È MULL2 #16, R0 Ò ADDL2 R0, R2 ; R2 <-- Hex character Ü30$: æ MOVB R2, (R7)+ ; Fill in character ð SOBGEQ R4, X_AS_LOOP ; Compare? ú MOVQ @OUTSTR(AP), R0 ; R0, R1 <-- descr  MOVC5 R6, (SP), #32, R0, (R1) ; Move result  MOVL #WYL__NORMAL, R0  BRB X_AS_FINISH "X_AS_INVARG: , MOVL #WYL__INVARG, R0 6 RET @X_AS_OUTCONERR: J MOVQ @OUTSTR(AP), R0 ; R0, R1 <-- descr T MOVZWL R0, R6 ^ MOVC5 #00, (SP), #^A/*/, R0, (R1) ; Fill with asterisks h MOVL #WYL__INVARG, R0 rX_AS_FINISH: | CMPB (AP), #3 † BLSS X_AS_END  TSTL OUTLEN(AP) š BEQL X_AS_END ¤ MOVL R6, @OUTLEN(AP) ®X_AS_END: ¸ RET Â Ì .PAGE Ö .SBTTL WYL_CNV_AS_X - Convert ASCII to hex string. à ê;++ ë; ì; FUNCTIONAL DESCRIPTION: ô; þ; Converts an ASCII string to it's hexadecimal string ; equivalent. For example the string: "ABCDEF" results ; in an output string: "464544434241". If the output string ; length is insufficient to contain the conversion an error &; code will be returned and the string filled with asterisks. 0; :; CALLING SEQUENCE: D; N; Sts.wlc.v = WYL_CNV_AS_X(inpstr.rt.dx,outstr.wt.dx[,outlen.wl.r]) X; b; INPUT PARAMETERS: l; v; inpstr Address of input character string descriptor. €; Š; OUTPUT PARAMETERS: ”; ž; outstr Address of Hex equivalent output string descriptor. ¨; ²; outlen Optional address of longword to receive the resultant ¼; hexadecimal string length. Æ; Ð; COMPLETION CODES: Ú; ä; WYL__INVARG invalid arguments. î; ø;--   .ENTRY WYL_CNV_AS_X, ^M  MOVAL HEXCHR, R11  MOVQ @INPSTR(AP), R4 ; R4, R5 <-- Descr * MOVZWL R4, R4 ; Zero extend 4 BEQL AS_X_OUTLEN > MULL3 #2, R4, R6 ; Number of hex chars H CMPW R6, @OUTSTR(AP) ; Room? R BGTR AS_X_INVARG \ SUBL3 #1, R4, R3 ; R3 = ASC index f SUBL2 R6, SP ; Room on stack p MOVL SP, R7 ; Base address zAS_X_LOOP: „ MOVZBL (R5)[R3], R1 ; R1 char to convert Ž EXTZV #4, #4, R1, R2 ; MSB ˜ MOVB (R11)[R2], (R7)+ ; Move first nibble ¢ EXTZV #0, #4, R1, R2 ; LSB ¬ MOVB (R11)[R2], (R7)+ ; Second nibble ¶ SOBGEQ R3, AS_X_LOOP À MOVQ @OUTSTR(AP), R0 ; R0, r1 <-- Descr Ê MOVC5 R6, (SP), #32, R0, (R1) ËAS_X_OUTLEN: Ô CMPB (AP), #3 Þ BLSS AS_X_END è TSTL OUTLEN(AP) ò BEQL AS_X_END ü MOVL R6, @OUTLEN(AP) AS_X_END:  MOVL #WYL__NORMAL, R0  RET $AS_X_INVARG: . MOVL #WYL__INVARG, R0 8 RET B L .PAGE V .SBTTL WYL_CNV_OUT_AS - Convert ASCII to text string. ` j;++ k; l; FUNCTIONAL DESCRIPTION: t; ~; Converts an ASCII coded value to it's ASCII string ˆ; equivalent. For example the string: "ABCD" results ’; in an output string: " A B C D". If the output string œ; length is insufficient to contain the conversion an error ¦; code will be returned and the string filled with asterisks. °; º; CALLING SEQUENCE: Ä; Î; Sts.wlc.v = WYL_CNV_AS_X(inpstr.rt.dx,outstr.wt.dx[,inpsiz.rl.v]) Ø; â; INPUT PARAMETERS: ì; ö; inpstr Address of input character string descriptor. ; ; inpsiz Optional longword value to specify the size of the ; input value. 1, 2, 4 bytes permissible. ; Longword (4) is the default. (; 2; OUTPUT PARAMETERS: <; F; outstr Address of Hex equivalent output string descriptor. P; Z; COMPLETION CODES: d; n; WYL__NORMAL Normal finish x; WYL__INVARG invalid arguments. ‚; Œ;-- –  VALUE = 4 ªOUTSTR = 8 ´INPSIZ = 12 ¾ È .ENTRY WYL_CNV_OUT_AS, ^M Ò MOVAL G^LIB$SIG_TO_RET, 0(FP) Ü MOVZBL #4, R8 ; Default = 4 æ CMPB (AP), #3 ; 3 args? ð BLSS 10$ ú MOVL INPSIZ(AP), R8 ; New value  BLEQ 60$ 10$:  MOVQ @OUTSTR(AP), R6 ; R6, R7 <-- Descr " MOVZWL R6, R6 , MULL3 #2, R8, R0 ; Number of ASCII chars 6 CMPW R0, R6 ; Room? @ BGTR 50$ J MOVC5 #00, (SP), #^X20, R6, (R7) ; Blank string T MOVAB (R7)[R6], R7 ; 2 off end ^ MOVL VALUE(AP), R3 ; Base address h CLRL R0 ; Index r20$: | BICB3 #^X80, (R3)+, R1 ; First character † ASHL #8, R1, R2 ; 2nd byte  BISW2 #^X0020, R2 ; Blank š CMPB R1, #^X20 ; Control? ¤ BGEQU 30$ ® BISW2 #^X405E, R2 ; Add caret ¸30$:  MOVW R2, -(R7) ; Move to string Ì AOBLSS R8, R0, 20$ Ö MOVL #WYL__NORMAL, R0 à RET ê50$: ô MOVC5 #00, (SP), #^A/*/, R6, (R7) ; Fill up þ60$:  MOVL #WYL__INVARG, R0  RET  & .PAGE 0 .SBTTL WYL_CNV_MBL - Convert blanks to single. : D;++ E; F; FUNCTIONAL DESCRIPTION: N; X; Multiple blank characters are converted to single blank b; characters. l; v; CALLING SEQUENCE: €; Š; Sts.wlc.v = WYL_CNV_MBL(inpstr.mt.dx[,outstr.wt.dx][outlen.wt.dx]) ”; ž; INPUT PARAMETERS: ¨; ²; inpstr Address of source string descriptor. ¼; Æ; OUTPUT PARAMETERS: Ð; Ú; outstr Optional address of output string descriptor. ä; If omitted the input string is modified. î; ø; outlen Optional address of longword to receive the length of ; the converted string. ; ; COMPLETION STATUS: ; *; WYL__NORMAL Normal successful completion. 4; >;-- H RINPSTR = 4 \OUTSTR = 8 fOUTLEN = 12 p z .ENTRY WYL_CNV_MBL,^M „ MOVAL G^LIB$SIG_TO_RET, 0(FP) ; Sig to return Ž MOVQ @INPSTR(AP), R1 ; Source descr ˜ MOVQ R1, R3 ; Same (default) ¢ CMPB (AP), #2 ; 2 args? ¬ BLSS 10$ ¶ TSTL OUTSTR(AP) ; Valid address À BLEQ 10$ Ê MOVQ @OUTSTR(AP), R3 ; Fill address Ô10$: Þ MOVZWL R1, R1 è BLEQ 100$ ò MOVZWL R3, R3 ü BLEQ 100$  CLRL R5 ; Blank flag  CLRL R6 ; Input index  CLRL R7 ; Fill index $20$: . MOVB (R2)[R6], R0 ; Pick up byte 8 CMPB R0, #^A/ / ; Blank B BNEQ 30$ L BBCS #0, R5, 40$ ; Previous blank? V BRB 80$ `30$: j CLRL R5 ; Clear flag t40$: ~ MOVB R0, (R4)[R7] ; Move byte ˆ60$: ’ AOBLSS R3, R7, 80$ œ BRB 100$ ¦80$: ° AOBLSS R1, R6, 20$ º100$: Ä SUBL3 R7, R3, R0 ; Blank fill count Î MOVC5 #0, (AP), #^A/ /, R0, (R4)[R7] ; Blank fill Ø CMPB (AP), #3 ; 3 args â BLSS 120$ ì TSTL OUTLEN(AP) ; Valid? ö BEQL 120$  MOVL R7, @OUTLEN(AP) 120$:  MOVL #WYL__NORMAL, R0  RET ( .END