User Tools

Site Tools


cdc:nos2.source:nam5871:csucdb

CSUCDB

Table Of Contents

  • [00002] PROC CSUCDB(INW,OUTW1,OUTW2,ERR)
  • [00003] CONVERT DISPLAY CODE DECIMAL TO BINARY
  • [00006] CONVERT DECIMAL TO BINARY.

Source Code

CSUCDB.txt
  1. *DECK CSUCDB
  2. PROC CSUCDB(INW,OUTW1,OUTW2,ERR);
  3. # TITLE - CONVERT DISPLAY CODE DECIMAL TO BINARY #
  4. BEGIN
  5. #
  6. ** CSUCDB - CONVERT DECIMAL TO BINARY.
  7. *
  8. * J.C. LEE 82/01/02
  9. * D.K. ENDO 82/06/03
  10. *
  11. * THIS PROCEDURE CONVERTS A LEFT JUSTIFIED DISPLAY CODE VALUE TO
  12. * BINARY. IF THE VALUE IS NOT A DECIMAL NUMBER THEN AN ERROR
  13. * STATUS IS RETURNED.
  14. *
  15. * PROC CSUCDB
  16. *
  17. * ENTRY 1. INW = INPUT WORD, LEFT JUSTIFIED.
  18. *
  19. * EXIT 1. OUTW1 = OUTPUT BINARY VALUE.
  20. * 2. OUTW2 = OUTPUT RIGHT JUSTIFIED DC.
  21. * 3. ERR = ERROR INDICATOR.
  22. *
  23. * METHOD
  24. *
  25. * FOR EACH CHARACTER BEGINNING ON THE LEFT, IF IT IS A CHARACTER
  26. * CHARACTER CONVERT IT TO BINARY ELSE, SET COMPLETE FLAG AND IF
  27. * CHARACTER IS NOT A ZERO BYTE THEN SET ERROR FLAG. IF THE
  28. * COMPLETE FLAG IS NOT SET THEN, ADD CURRENT DIGIT TO VALUE.
  29. *
  30. #
  31. DEF DC$0 #O"33"#; # DISPLAY-CODED 0 #
  32. DEF DC$9 #O"44"#; # DISPLAY-CODED 9 #
  33.  
  34. ITEM INW U; # INPUT WORD, LEFT-JUSTIFIED #
  35. ITEM OUTW1 I; # OUTPUT BINARY VALUE #
  36. ITEM OUTW2 I; # OUTPUT RIGHT-JUSTIFIED DC #
  37. ITEM ERR B; # ERROR INDICATOR #
  38. ITEM COMPLETE B; # CONVERSION DONE INDICATOR #
  39. ITEM DIGIT I; # ONE DISPLAY-CODED CHARACTER #
  40. ITEM I I; # TEMPORARY VARIABLE #
  41. CONTROL EJECT;
  42. ERR = FALSE;
  43. OUTW1 = 0;
  44. OUTW2 = 0;
  45. COMPLETE = FALSE; # CONVERSION NOT DONE YET #
  46.  
  47. FOR I=0 STEP 1 WHILE I LS 10
  48. AND NOT COMPLETE
  49. DO
  50. BEGIN # PROCESS A DISPLAY-CODED CHAR #
  51. DIGIT = C<I,1>INW;
  52.  
  53. IF DIGIT GQ DC$0
  54. AND DIGIT LQ DC$9
  55. THEN # DIGIT IS BETWEEN 0 AND 9 #
  56. DIGIT = DIGIT - O"33";
  57.  
  58. ELSE # NOT A DECIMAL NUMBER #
  59. BEGIN
  60. COMPLETE = TRUE;
  61. IF (DIGIT NQ 0) AND (DIGIT NQ O"55")
  62. THEN # ERROR IF NOT END OF FIELD #
  63. ERR = TRUE;
  64. END
  65.  
  66. IF NOT COMPLETE
  67. THEN
  68. BEGIN
  69. OUTW2 = OUTW2*O"100" + DIGIT ; # DECIMAL VALUE IN CHAR #
  70. OUTW1 = OUTW1*10 + DIGIT; # CONVERT TO BINARY VALUE #
  71. END
  72. END
  73. RETURN;
  74. END
  75. TERM
cdc/nos2.source/nam5871/csucdb.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator