cdc:nos2.source:nam5871:ns_cvh
Table of Contents
NS$CVH
Table Of Contents
- [00003] PROC NS$CVH(INW,OUTW,ERR)
- [00004] NS$CVH - CONVERT HEX DISPLAY CODE TO BINARY.
- [00008] CONVERT HEX TO BINARY.
Source Code
- NS$CVH.txt
- *DECK NS$CVH
- USETEXT CYB$NS
- PROC NS$CVH(INW,OUTW,ERR); # CONVERT HEX DC TO BINARY #
- # TITLE NS$CVH - CONVERT HEX DISPLAY CODE TO BINARY. #
- BEGIN # NS$CVH #
- #
- ** NS$CVH - CONVERT HEX TO BINARY.
- *
- * J.C. LEE 1981
- *
- * THIS IS A UTILITY ROUTINE. ITS FUNCTION IS TO CONVERT HEX TO
- * BINARY.
- *
- * PROC NS$CVH(INW, OUTW, ERR)
- *
- * ENTRY:
- * INW - INPUT WORD, LEFT-JUSTIFIED.
- *
- * EXIT:
- * OUTW - OUTPUT WORD, RIGHT-JUSTIFIED.
- * ERR - SET IF ERROR IS FLAGED.
- *
- * METHOD:
- * PROCESS A DISPLAY CODED CHARACTER AT A TIME UNTIL THE WHOLD
- * WORD IS PROCESSED. IF ERROR IS FOUND, FLAG IT.
- *
- #
- DEF DC$0 #O"33"#; # DISPLAY-CODED 0 #
- DEF DC$9 #O"44"#; # DISPLAY-CODED 9 #
- DEF DC$A #O"01"#; # DISPLAY-CODED A #
- DEF DC$F #O"06"#; # DISPLAY-CODED F #
- #
- LOCAL VARIABLES
- #
- ITEM INW U; # INPUT WORD, LEFT-JUSTIFIED #
- ITEM OUTW I; # OUTPUT RIGHT-JUSTIFIED #
- ITEM ERR B; # ERROR INDICATOR #
- ITEM COMPLETE B; # CONVERSION DONE INDICATOR #
- ITEM DIGIT I; # DISPLAY-CODED CHARACTER #
- ITEM I I; # TEMPORARY VARIABLE #
- CONTROL EJECT;
- OUTW = 0;
- ERR = FALSE;
- COMPLETE = FALSE; # CONVERSION NOT DONE YET #
- FOR I=0 STEP 1 WHILE I LS WC
- AND NOT COMPLETE
- DO
- BEGIN # PROCESS A DISPLAY-CODED CHAR #
- DIGIT = C<I,1>INW;
- IF DIGIT GQ DC$A
- AND DIGIT LQ DC$F
- THEN # DIGIT IS BETWEEN A AND F #
- DIGIT = DIGIT + 9; # CONVERT TO BINARY #
- ELSE
- BEGIN
- IF DIGIT GQ DC$0
- AND DIGIT LQ DC$9
- THEN # DIGIT IS BETWEEN 0 AND 9 #
- DIGIT = DIGIT - O"33"; # CONVERT TO BINARY #
- ELSE # DIGIT IS NOT A VALID HEX CHAR #
- BEGIN
- COMPLETE = TRUE;
- IF DIGIT NQ 0
- THEN # ERROR IF NOT END OF FIELD #
- ERR = TRUE;
- END
- END
- IF NOT COMPLETE
- THEN
- OUTW = OUTW*16 + DIGIT; # BINARY VALUE #
- END
- RETURN;
- END
- TERM
cdc/nos2.source/nam5871/ns_cvh.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator