;----------------------------------------------------------------- ; catu255.mu -- Microcode source for Alto running ; 64 Kilobit u-255 law coded speech. ; This code executes as part of the audio task. ; Last modified by L. Stewart September 22, 1979 5:20 PM ; October 15, 1979 2:30 PM silence detection ; March 17, 1980 12:15 PM CAT copy, CatU255.mu ;----------------------------------------------------------------- ;----------------------------------------------------------------- ; u-255 law encoding ; Assumes left justified 12 bit two's complement value in L ; u255 value returned r.j. in L and l.j. in utVal=Temp ;----------------------------------------------------------------- !1,2,utEPlus,utEMinus; !1,2,utEShift,utEOV; !1,2,utEDone,utEMore; !1,2,utEMinus1,utEPlus1; ; First convert to sign magnitude utEncode: utVal_L; L_100000,SH<0; utExp_L,:utEPlus; !1,2,utEPlus,utEMinus; utEPlus: L_0,TASK,:utECom1; utEMinus: L_0-T; utVal_L,T_0-1,TASK,:utECom1; utECom1: utSign_L,:utAddConst; ; Now add 41B returning max on overflow utAddConst: T_203+1; Lucky constant value L_utVal+T; NOP,SH<0; utVal _ L RSH 1,:utEShift; !1,2,utEShift,utEOV; utEOV: L_177,TASK; utVal_L,:utEAddSign; ; Now shift right by 2, to align the value so that it is right for the highest ; exponent. utEShift: L_utVal,TASK; utVal _ L RSH 1; ; Now enter the main loop of the conversion. utELoop: T_STRCWFS; STRCWFS=10000 L_utVal AND T; L_utExp-T,SH=0; utExp_L,:utEDone; !1,2,utEDone,utEMore; utEMore: L_utVal,TASK; utVal_L LSH 1,:utELoop; ; Now package everything up utEDone: T_7400; 4 bit mask T_utVal.T; L_utExp OR T,TASK; utVal_L LCY 8; ; Add in sign; utEAddSign: SINK_utSign,BUS=0; L_T_utVal,:utEMinus1; !1,2,utEMinus1,utEPlus1; utEMinus1: L_200 OR T,:utEPlus1; utEPlus1: utVal_L LCY 8,:utStore; ;----------------------------------------------------------------- ; u-255 law decoding ; Assumes right justified 8 bit u-255 value in L ; Returns linear value in L and utVal=Temp ;----------------------------------------------------------------- !1,2,utDLoop,utDDone; !1,2,utDMinus,utDPlus; utDecode: ; First step, separate components. utVal_L; T_100; T_60 OR T; Construct constant L_utVal AND T,TASK; utExp_L; T_utVal; L_200 AND T; utSign_L; Minus if Sign non-zero L_17 AND T,TASK; utVal_L LSH 1; ; Build frame for decoding; T_utVal+1; L_40+T,TASK; utVal_L LSH 1; ; The value is now 0 000 000 001 xxx x10 in binary. ; We now must shift left (Exp/20B)+1 places. utDLoop: L_utVal,TASK; utVal_L LSH 1; T_20; L_utExp-T,BUS=0,TASK; utExp_L,:utDLoop; !1,2,utDLoop,utDDone; ; Now subtract 204B (see encode), this will never underflow. utDDone: T_203+1; L_utVal-T; T_17; L_LASTL AND NOT T,TASK; Truncate towards 0. utVal_L; ; Handle sign. SINK_utSign,BUS=0; L_T_utVal,:utDMinus; !1,2,utDMinus,utDPlus; utDMinus: L_0-T; utDPlus: utVal_L,:utShipit; ;----------------------------------------------------------------- ; u-255 law decoding ; Assumes right justified 8 bit u-255 value in L ; Returns linear value in L and utVal=Temp ;----------------------------------------------------------------- !1,2,uttDLoop,uttDDone; !1,2,uttDMinus,uttDPlus; uttDecode: ; First step, separate components. utVal_L; T_100; T_60 OR T; Construct constant L_utVal AND T,TASK; utExp_L; T_utVal; L_200 AND T; utSign_L; Minus if Sign non-zero L_17 AND T,TASK; utVal_L LSH 1; ; Build frame for decoding; T_utVal+1; L_40+T,TASK; utVal_L LSH 1; ; The value is now 0 000 000 001 xxx x10 in binary. ; We now must shift left (Exp/20B)+1 places. uttDLoop: L_utVal,TASK; utVal_L LSH 1; T_20; L_utExp-T,BUS=0,TASK; utExp_L,:uttDLoop; !1,2,uttDLoop,uttDDone; ; Now subtract 204B (see encode), this will never underflow. uttDDone: T_203+1; L_utVal-T; T_17; L_LASTL AND NOT T,TASK; Truncate towards 0. utVal_L; ; Handle sign. SINK_utSign,BUS=0; L_T_utVal,:uttDMinus; !1,2,uttDMinus,uttDPlus; uttDMinus: L_0-T; uttDPlus: utVal_L,:uttShipit; (0,5376)(1,11264)\f1