*DECK NS$CVD USETEXT CYB$NS PROC NS$CVD(INW,OUTW1,OUTW2,ERR); # CONVERT DEC TO BINA # # TITLE NS$CVD - CONVERT DECIMAL TO BINARY. # BEGIN # NS$CVD # # ** NS$CVD - CONVERT DECIMAL TO BINARY. * * J.C. LEE 1981 * * THIS IS A UTILITY ROUTINE. ITS FUNCTION IS TO CONVERT DECIMAL * TO BINARY. * * PROC NS$CVD(INW, OUTW1, OUTW2, ERR) * * ENTRY: * INW = INPUT WORD, LEFT-JUSTIFIED. * * EXIT: * OUTW1 = OUTPUT BINARY VALUE. * OUTW2 = OUTPUT RIGHT-JUSTIFIED DC. * ERR = TRUE/FALSE. (TRUE IF ERROR FLAGED) * * METHOD: * PROCESS A DISPLAY-CODED CHARACTER AT A TIME, UNTIL THE * WHOLE INPUT WORD IS PROCESSED. FLAG ERROR IF ONE IS FOUND. * # DEF DC$0 #O"33"#; # DISPLAY-CODED 0 # DEF DC$9 #O"44"#; # DISPLAY-CODED 9 # ITEM INW U; # INPUT WORD, LEFT-JUSTIFIED # ITEM OUTW1 I; # OUTPUT BINARY VALUE # ITEM OUTW2 I; # OUTPUT RIGHT-JUSTIFIED DC # ITEM ERR B; # ERROR INDICATOR # ITEM COMPLETE B; # CONVERSION DONE INDICATOR # ITEM DIGIT I; # ONE DISPLAY-CODED CHARACTER # ITEM I I; # TEMPORARY VARIABLE # CONTROL EJECT; ERR = FALSE; OUTW1 = 0; OUTW2 = 0; 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 = CINW; IF DIGIT GQ DC$0 AND DIGIT LQ DC$9 THEN # DIGIT IS BETWEEN 0 AND 9 # DIGIT = DIGIT - O"33"; ELSE # NOT A DECIMAL NUMBER # BEGIN COMPLETE = TRUE; IF DIGIT NQ 0 THEN # ERROR IF NOT END OF FIELD # ERR = TRUE; END IF NOT COMPLETE THEN BEGIN OUTW2 = OUTW2*O"100" + DIGIT ; # DECIMAL VALUE IN CHAR # OUTW1 = OUTW1*10 + DIGIT; # CONVERT TO BINARY VALUE # END END RETURN; END TERM