home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s081 / 1.img / DEMO.P51 < prev    next >
Encoding:
Text File  |  1991-07-27  |  2.0 KB  |  59 lines

  1. demo$start: do;
  2. $include(reg51.dcl)
  3. int0p: procedure interrupt 0 using 1; end;
  4. int1p: procedure interrupt 2 using 2;
  5.        declare (int1v0,int1v1) byte;
  6.        int1v0=p1;
  7.        if (p1 and 07h)=07h
  8.           then do; sbuf=25h;
  9.                                 end;
  10.        else do;
  11.               sbuf=20h;
  12.             end;
  13.        return;
  14. end int1p;
  15. samp: procedure (samp$ch) word;
  16.       declare samp$ch byte;
  17.       declare startad byte at(0e000h) auxiliary;
  18.       declare (ad0,ad1) byte at(0e010h) auxiliary;
  19.       p1=samp$ch; call time(100);
  20.       return ad0+256*ad1;
  21. end samp;
  22. comput1: procedure(var0,var1,var2) word;
  23.          declare (var0,var1,var2,result) word;
  24.          do case (p1 and 03h);
  25.             result=var0+var1+var2;
  26.             result=var0*var1+var2;
  27.             result=var0/var1-var2;
  28.             result=var0 MOD var1;
  29.          end;
  30.          return result;
  31. end comput1;
  32. comput2: procedure(count) word;
  33.          declare count byte, value word;
  34.          value=0;
  35.          do while count<>0;
  36.             value=value+(count*2-1);
  37.             count=count-1;
  38.          end;
  39.          return value;
  40. end comput2;
  41. mprog: do;
  42. declare (v0,v1,v2,v3,v4,v5) byte;
  43. declare (d0,d1,d2,d3,d4,d5) word, b0 bit;
  44.  do while 1=1;
  45.     v0=1; v1=10; v2=20; v3=25;               /*     byte      */
  46.     d1=((d0+v1)*v2)+(v3-v2)*v1-v0;           /* byte multiply */
  47.     d2=1234; d4=54321; d5=45678;             /*     word      */
  48.     do v0=1 to 2; d4=d4+2; d5=d5-3; end;     /*     loop      */ 
  49.     d2=samp(2);    d3=comput1(d0,d1,d2);     /*   procedure   */
  50.     d4=(((v3+1)*v2+1)*v1+1)+((d1+d2/d3)*3);  /*  word devide  */
  51.     d5=comput2(v1);                          /*   procedure   */
  52.     if b0=1 then do; 
  53.        d1=(v1+v2+v3)*v4;  d4=(d4+10)*d1;     /*   condition   */
  54.        p1$7=1;  b0=0;  d2=samp(3);  end;     /*  bit operate  */
  55.     else do; d1=(v1+v2+v3)/v4; d4=d4+10;
  56.        p1$7=0;  b0=1;  d2=samp(4);  end;     /*  bit operate  */     
  57.  end;
  58. end mprog;
  59. end demo$start;