ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Четверг
18 апреля
1089480 Топик полностью
Гyдвин, волшебник (29.03.2021 19:46, просмотров: 546) ответил michas на Старинный кросс компилятор под DOS языка PL/M-51 для чистых x51.
Сильно облегчал задачу ;) (‎Fils.plm, 5 ‎февраля ‎1996) Дискетку с IAR урвал в КТЦ-МК года на 2 позже. Тырнетов еще не было... 
Fils:Do;

$nolist
$include(c:\intel\reg51.dcl)
$include(c:\board\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 '10*60',
  TNMax Literally '16*60',
  TSMin Literally '20',
  TSMax 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*12;
   TPrSb=40;
   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-5;
                                     if TPrSb > TSMin then TPrSb=TPrSb-1;
                                     if TPoSb > TSMin then TPoSb=TPoSb-1;
                                          end;
                                         end;

                      If not InpHigh then do;
                                          do case Mode;
                                     if TCycle < TNMax then TCycle=TCycle+5;
                                     if TPrSb < TSMax then TPrSb=TPrSb+1;
                                     if TPoSb < TSMax then TPoSb=TPoSb+1;
                                          end;
                                         end;

                           Call SetDisplay;

                         end;






       if  CheckKeys or TestClear(SetTime) then  Call SetFils;

   if Interval <>1 then do;

                       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;