User Tools

Site Tools


cdc:nos2.source:nam5871:ns_cvh

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
  1. *DECK NS$CVH
  2. USETEXT CYB$NS
  3. PROC NS$CVH(INW,OUTW,ERR); # CONVERT HEX DC TO BINARY #
  4. # TITLE NS$CVH - CONVERT HEX DISPLAY CODE TO BINARY. #
  5.  
  6. BEGIN # NS$CVH #
  7. #
  8. ** NS$CVH - CONVERT HEX TO BINARY.
  9. *
  10. * J.C. LEE 1981
  11. *
  12. * THIS IS A UTILITY ROUTINE. ITS FUNCTION IS TO CONVERT HEX TO
  13. * BINARY.
  14. *
  15. * PROC NS$CVH(INW, OUTW, ERR)
  16. *
  17. * ENTRY:
  18. * INW - INPUT WORD, LEFT-JUSTIFIED.
  19. *
  20. * EXIT:
  21. * OUTW - OUTPUT WORD, RIGHT-JUSTIFIED.
  22. * ERR - SET IF ERROR IS FLAGED.
  23. *
  24. * METHOD:
  25. * PROCESS A DISPLAY CODED CHARACTER AT A TIME UNTIL THE WHOLD
  26. * WORD IS PROCESSED. IF ERROR IS FOUND, FLAG IT.
  27. *
  28. #
  29. DEF DC$0 #O"33"#; # DISPLAY-CODED 0 #
  30. DEF DC$9 #O"44"#; # DISPLAY-CODED 9 #
  31. DEF DC$A #O"01"#; # DISPLAY-CODED A #
  32. DEF DC$F #O"06"#; # DISPLAY-CODED F #
  33. #
  34.   LOCAL VARIABLES
  35. #
  36. ITEM INW U; # INPUT WORD, LEFT-JUSTIFIED #
  37. ITEM OUTW I; # OUTPUT RIGHT-JUSTIFIED #
  38. ITEM ERR B; # ERROR INDICATOR #
  39. ITEM COMPLETE B; # CONVERSION DONE INDICATOR #
  40. ITEM DIGIT I; # DISPLAY-CODED CHARACTER #
  41. ITEM I I; # TEMPORARY VARIABLE #
  42. CONTROL EJECT;
  43. OUTW = 0;
  44. ERR = FALSE;
  45. COMPLETE = FALSE; # CONVERSION NOT DONE YET #
  46.  
  47. FOR I=0 STEP 1 WHILE I LS WC
  48. AND NOT COMPLETE
  49. DO
  50. BEGIN # PROCESS A DISPLAY-CODED CHAR #
  51. DIGIT = C<I,1>INW;
  52. IF DIGIT GQ DC$A
  53. AND DIGIT LQ DC$F
  54. THEN # DIGIT IS BETWEEN A AND F #
  55. DIGIT = DIGIT + 9; # CONVERT TO BINARY #
  56. ELSE
  57. BEGIN
  58. IF DIGIT GQ DC$0
  59. AND DIGIT LQ DC$9
  60. THEN # DIGIT IS BETWEEN 0 AND 9 #
  61. DIGIT = DIGIT - O"33"; # CONVERT TO BINARY #
  62. ELSE # DIGIT IS NOT A VALID HEX CHAR #
  63. BEGIN
  64. COMPLETE = TRUE;
  65. IF DIGIT NQ 0
  66. THEN # ERROR IF NOT END OF FIELD #
  67. ERR = TRUE;
  68. END
  69. END
  70. IF NOT COMPLETE
  71. THEN
  72. OUTW = OUTW*16 + DIGIT; # BINARY VALUE #
  73. END
  74. RETURN;
  75. END
  76. TERM
cdc/nos2.source/nam5871/ns_cvh.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator