ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Суббота
4 мая
563056 Топик полностью
Гудвин, волшебник (29.11.2014 16:47, просмотров: 123) ответил ASDFS на PL/M!
Да!  Fils:Do; $nolist $include(reg51.dcl) $include(310io.inc) Declare PA1 byte at(1800h) auxiliary, PB1 byte at(1801h) auxiliary, PC1 byte at(1802h) auxiliary, CWR1 byte at(1803h) auxiliary, Digit byte at (1000h) auxiliary, Pinp0 literally 'PB', Pinp1 literally 'PC', ScanPort Literally 'P1', InpMode bit at(97h) register, InpLow bit at(96h) register, InpHigh bit at(95h) register, TNMin Literally '30*60', TNMax Literally '70*60', TSMin Literally '1', TSMax Literally '120', TPSMin Literally '20', TPSMax Literally '60', DisplayLen literally '8', Display(DisplayLen) byte, Blink literally '0', CharConvert(*) byte constant (3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh, 80h,00h,37h,39h,73h,76h,77h,7dh), /* 0,1,2,3,4,5,6,7,8,9,., ,Џ,‘,ђ,Ќ,Ђ,Ѓ */ Nab(8) byte constant (15,16,17,11,11,11,11,11), Prs(8) byte constant (12,14,13,11,11,11,11,11), Pos(8) byte constant (12,00,13,11,11,11,11,11), PrmS(11) byte , PolS(11) byte , MA0 byte , Mode byte, Scan byte, TimeOut byte, (Count,Interval,Tim) word, (i,Pnt) byte, mSec10 Literally '0FFFFH-(11*1000/12*2)', /*10*/ Delitel Literally '500', /*100*/ Keys word, TCycle word, (TPrSb,TPoSb) byte, (Oprm,OPol) word, SetTime bit, Semafor bit, OneSec bit, CntPC bit, CntCk bit ; $list $code SetDisplay: procedure; Declare i byte; Do case Mode; do; do i=0 to 7; Display(i)=Nab(i); end; MA0= TCycle/60; Display(3)=MA0 /10; Display(4)=MA0 mod 10; Display(5)=10; MA0= TCycle mod 60; Display(6)=MA0 / 10 ; Display(7)=MA0 mod 10; end; do; do i=0 to 7; Display(i)=Prs(i); end; Display(6)=TPrSb / 10 ; Display(7)=TPrSb mod 10; end; do; do i=0 to 7; Display(i)=Pos(i); end; Display(6)=TPoSb / 10 ; Display(7)=TPoSb mod 10; end; end; end SetDisplay; SetFils: Procedure ; Declare (Numb,i) byte; Numb=0; Do i = 0 to 10 ; If (Keys and Shl(Double(1),i)) <> 0 then do; Numb=Numb+1; If PrmS(i) = 0 then do; PrmS(i)=1; OPol= OPol and (not Double(Shl(Double(1),i))); Oprm= Oprm and (not Double(Shl(Double(1),i))); end; end; else do; PrmS(i)=0; PolS(i)=0; OPol= OPol and (not Double(Shl(Double(1),i))); Oprm= Oprm and (not Double(Shl(Double(1),i))); end; end; if Numb<>0 then Interval=TCycle/Numb; else Interval=1; end SetFils; OutPorts: Procedure; CWR1=10000000b; /* ўбҐ ­  ўлў®¤ */ PA1=Low(OPrm); PB1=Low(OPol); PC1 =(High(OPrm)+Shl(High(OPol),4)) and 01110111b; end OutPorts; CheckKeys: Procedure bit; CWR55=10000011b; /* PB ‚‚Ћ„, ђ‘(0-3) ‚‚Ћ„, ®бв «м­®Ґ ­  ўлў®¤ */ if ((not PInp0) <> Low(Keys)) or ((not PInp1 and 00000111b) <> High(Keys)) then do; Keys=Double(Shl(Double(not PInp1 and 00000111b),8) + (not PInp0)); Return 1; end; else return 0; end CheckKeys; Timer0: procedure interrupt 1 using 2; TL0=Low(mSec10); /* Reload timer0 */ TH0=High(mSec10); Scan=(Scan+1) mod DisplayLen; Digit=Blink; ScanPort=Scan or 11111000b; /**********************************/ Digit=CharConvert(Display(Scan)); If (ScanPort and 11100000b) <> 11100000b then TimeOut= 5; Tim=(Tim+1) mod Delitel; /* counter for 1 Sec*/ if Tim=0 then do; OneSec=1; Count=(Count+1) mod (Interval); if Count = 0 then Semafor=1; If TimeOut<> 0 then do; TimeOut=TimeOut-1; if Timeout=0 then SetTime=1; end; end; end timer0; /* ----------------------------Program Start here. */ Mode=0; scan=0; SetTime=0; Count=0; OneSec=0; Semafor=0; Interval=0; CntPC=1; CntCk=0; TCycle= 60*50; TPrSb=2; TPoSb=40; OPol=0; Oprm=0; Keys= 0; TimeOut=0; Interval=1; ScanPort=11111000b; Do i = 0 to 10 ; PrmS(I)=0; PolS(i)=0; end; Do i = 1 to 40; call Time(200); end; /* ‡¤Ґбм Ўг¤Ґв ­ бва®©Є  Ї®ав®ў */ /* PA1 Їа®¬.бЎа®б 1-8 -------! PB1 Ї®«.бЎа 1-8 ! ђC1 ЎЁвл (0-2) - Їа®¬.бЎа®б 9-11 ! ђ‘1 ЎЁвл (4-6) - Ї®«­.бЎа®б 9-11 -------! ђ‚ ўе®¤л Є«о祩 1-8 ђ‘ ЎЁвл (0-3) - ўе®¤л Є«о祩 9-11 ђ1 ЎЁвл (0-2) - ўл室 бзҐвзЁЄ  бЄ ­Ёа®ў ­Ёп ­  €„7 ђ1 ЎЁвл (5-7) - ўе®¤ Є« ўЁ вгал €ђ23 (Digit) - ᥬЁбҐЈ¬Ґ­в­л© ўл室 */ CWR55=10000011b; /* PB ‚‚Ћ„, ђ‘(0-3) ‚‚Ћ„, ®бв «м­®Ґ ­  ўлў®¤ */ CWR1=10000000b; /* ўбҐ ­  ўлў®¤ */ /* IE=0; */ /*“бв ­®ўЄ  в ©¬Ґа */ TMOD=TMOD and 0F0H or 00000001B;/* Timer0 as 16-bit counter*/ TR0=1; Tim=0; PT0=1; EA,ET0=1; Call SetDisplay; Pnt=0; do while 1; Call OutPorts; Do while not TestClear(OneSec); end; If TimeOut<>0 then do; If not InpMode then do; Mode= (Mode+1) mod 3; end; If not InpLow then do; do case Mode; if TCycle > TNMin then TCycle=TCycle-60; if TPrSb > TSMin then TPrSb=TPrSb-1; if TPoSb > TPSMin then TPoSb=TPoSb-1; end; end; If not InpHigh then do; do case Mode; if TCycle < TNMax then TCycle=TCycle+60; if TPrSb < TSMax then TPrSb=TPrSb+1; if TPoSb < TPSMax then TPoSb=TPoSb+1; end; end; Call SetDisplay; end; if CheckKeys or TestClear(SetTime) then Call SetFils; if Interval <>1 then do; CntCk=0;/********** oleg***********/ do I=0 to 10; if PrmS(i) > 1 then do; PrmS(i)=PrmS(i)-1; If PrmS(i)=1 then do; if CntCk then do; OPol= OPol and (not Double(Shl(Double(1),i))); Oprm= Oprm and (not Double(Shl(Double(1),i))); end; else do; PolS(i)=TPoSb+1; OPol= OPol or ( Double(Shl(Double(1),i))); Oprm= Oprm and (not Double(Shl(Double(1),i))); end; end; end; if PolS(i) > 0 then do; PolS(i)=PolS(i)-1; If PolS(i)=0 then do; OPol= OPol and (not Double(Shl(Double(1),i))); Oprm= Oprm and (not Double(Shl(Double(1),i))); end; end; end; if TestClear(Semafor) then do; If Pnt = 0 then do; CntPC = not CntPc; CntCk = CntPC; end; Do while (Keys and Shl(Double(1),Pnt)) = 0; Pnt=(Pnt+1) mod 11; If Pnt = 0 then do; CntPC = not CntPc; CntCk = CntPC; end; end; PrmS(Pnt)= TPrSb+1; OPol= OPol and (not Double(Shl(Double(1),Pnt))); Oprm= Oprm or (Double(Shl(Double(1),Pnt))); CntCk=not CntCk; Pnt=(Pnt+1) mod 11; end; end; end; end Fils;