您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > 廖力编译原理课件第8章
12•––31••42••1)•2)––521•2••6•–“-”7•FORTRAN–FORTRAN–•Fortran–1–2COMMON–3EQUIVALENCE81FORTRAN•••COMMON22……1191FORTRAN•–“”–“”102–112•1•2•312(COMMON)1COMMON:–•COMMONX,Y,I,Z(3)•COMMONA,B,J,T(3)–XA,YB,IJ,ZT•13(COMMON)2COMMON••COMMON/1///2/……•COMMON14(COMMON)31(1)()()(2)(COMLIST)15(COMMON)31•(1)COMMON•(2)16(COMMON)31•(3)CMPDA•(4)COMLIST(COMLIST)17(COMMON)32•1CMP0COMLIST•2COMLISTFT(FTLT()•3LTCMPLT18COMMONX,YCOMMON/B1/A,B,C//D,E,F(100)0F88E77D60B1C55B1B44B1A36Y22X1CMPDA…NameCOMLIST53…B181…LTFTLENGTHNAME19(EQUIVALENCE)1(EQUIVALENCE)•2EQUIVALENCE–EQUIVALENCE12……–EQUIVALENCE(W,ST)–20(EQUIVALENCE)3•1–•2•321(EQUIVALENCE)4EQUIVALENCE•5•EQnull–•OFFSET22•INTEGERI,J,K,X,A(10,10)•EQUIVALENCE(X,A(2,3)),(I,J,A(1,2),K)•1-21A550X42-11K34-11J23-11I1EQOFFSET…NAME236•EQUIVALENCE(X,A(2,3)),(I,J,A(1,2),K)1)X•X.OFFSET=0X02)A(2,3)XXA•A(2,3).OFFSET=X.OFFSET=0;•A(2,3)A(1,1)+[(2-1)+(3-1)*10];•A21X0A-2124•II0•JI0J0•A(1,2)A.EQnull;A(1,2),I,JOFFSETI-11J-11X0A-2125•KI-11K-11X0A-21J-11261•–EQ•EQ•–271•–1N1N1.EQnull,EQN1,N2,…,Nm,f1,f2,f…,fmADDR(Ni)=a+(fif1),i=2,3,…,m–aN1N2N1N3NmM1M2M3Mi28••2a+fi-f10,•3•4len=MAX(len,a+MAX(fi-f1+SIZE(Ni))),–i=1..m–len–A0–SIZE(Ni)Ni2911272len302•1)•2)(1)(2)–a:a+(fi-f+SIZE(Ni))–NimN1,N2,…,Nmfif.MAXmi1=312•2)•3)32•BEGIN•N1:=N;f:=OFFSET[N];•WHILEEQ[N1]NDO•{N1:=EQ[N1];f:=MIN(f,OFFSET[N1])};•len:=•N1:=N;•REPEAT•DA[N1]:=•ADDR[N1]:=a+(OFFSET[N1]-f);•len:=MAX(len,(OFFSET[N1]-f)+SIZE(N1));•N1:=EQ[N1];•UNTILN1=N;•A:=a+len•END;33•FORTRAN–12•INTEGERA,B/*MAIN*/•DIMENGSIONA(2,3),C(5),D(8)•COMMONI,J,X,A/R/E,F•EQUIVALENCE(A(2,2),C(1)),(D(4),B)•……•V=B*5•U=1.5*V•…...•END34•SUBROUTINESR1/**/•COMMONM,X,B•……•END•FUNCTIONFN1/**/•REALW,Y•……•END35COMLISTK+8K+74RK+0K+417LTFTlength•12736a+181RealUK+10a+161RealVK+921280RealFK+80128K+8RealEK+72127K+0RealXK+61127K+6IntJK+50127K+5IntIK+4a+01K+101RealDK+37127K+031RealCK+2a+61K+36IntBK+141270K+202IntAK+0ADDRDACMPEQoffsetDIMCATtypename37C(2)A(2,3)910C(3)1112C(4)1314C(5)1516E01F23RMI0XJ1BX23A(1,1)4A(2,1)5A(1,2)6C(1)A(2,2)7A(1,3)8MAINSUBMAINSUB38D(1)D(2)D(3)D(4)BD(5)D(6)D(7)D(8)VUMAIN391•2••403•••41•–X:=A+B-((C+D)+(E+F)*(G+H))––1)(+,A,B,T1)T1a–2)(+,C,D,T2)T2a+1–3)(+,E,F,T3)T3a+2–4)(+,G,H,T4)T4a+3–5)(*,T3,T4,T5)T5a+2–6)(+,T2,T5,T6)T6a+1–7)(-,T1,T6,T7)T7a–8)(:=,T7,_,X)4231•2•343()•1C•2•44••MAIN()•{……•Q();•}•P()•{……}•Q()•{……•P();•}45•P–SP–TOP•QPTOPSPC46()•3SP210TOPxC471)2)SPTOPSPTOP3)4)C(SP()())()()()48•5)()x[SP]SPx–SP–•XxXx[SP],SPx49()4C•1)–Call–callQ((T1,T2,…,Tn)•ParT1•…•ParTn•Jsrn,QC(i+3)[TOP]:=Ti(i+3)[TOP]:=addr(Ti)1[TOP]:=SP;3[TOP]:=n;jsrQ;50()4C•2)•(1)SPTOP,–SP:=TOP+1–1[SP]:=–TOP:=TOP+L/*LQ*/•(2)––51()4C3)•(1)ETT()•(2)SPTOP–TOP:=SP-1SP:=0[SP]SP:=1[TOP]•(3)–X:=2[TOP]Jmp0[X]•52121)2)533display•1i1……i0i+1543display1)(1)0(2)display(3)display()(4)display(5),displayd553display2)PascalSP210TOPdPASCALDisplaydisplay3SP564•(k)XXR2–LDR1,(d+k)[SP];–LDR2,x[R1];•displaykR1•xXk575display1)•P1displayP0P1CallP2P2P2P2displayP0P1P2CallP2CallP1P0P1P2585display1)P0P1P2CallP2CallP1P1CallP2P2P2displayP0P2SPP0P2display595display1)idisplaydisplayiiSP•displaydisplay•displayP0P1P2CallP3P3605display2)M0A(X)BCallXCCallA(C)CallBBACAACALLXX615display2)(1)CdisplayC.displayA(B)B.displayCdisplay625display2)2)displaydisplaydisplaySP3)SPdisplay636Pascal•1•1–ParTi:(i+4)[TOP]:=Ti/**/–(i+4)[TOP]:=addr(Ti)/**/•2–(i+4)[TOP]:=Ti646Pascal1)(3)SPDisplayCBdisplayBB2B1M0A(X)BCallXCCallA(C)CallBAB656Pascal1)3•CBdisplay•–AB1,B2B1CB2display–(i+4)[TOP]:=addr(B1);–(i+4)[TOP]CB2Cdisplay.66(4)••PROCB;PROCA(X);PROCD(P)•procC;•………………•end;callD(X)callP•………………•call(C);endend•end67•parTi(i+4)[TOP](i+3)[SP].•SPB1B2SPSPAB2DAC686Pascal1)(4)•CdisplayB2Bdisplaydisplay•displaydisplay696Pascal1)•5P0Q(Z)PGOTOZT:CallQ(T)CallPParTQB1,B2;B1TB2P0B1Q706Pascal1)5•JSRn,Q•1[TOP]=SP;•3[TOP]=SP+d3[TOP]=B2•4[TOP]=n•JSRQ716Pascal2)–SP=TOP+1;–1[SP]=–TOP=TOP+L•display,displayISP,iLN•TOP726Pascal•3)–TOP=SP-1;–SP=0[SP];–X=2[TOP];–JMP0[X];•returnQ73•FF•ProgramM;•varA,B:integer•functionF(N:integer):integer;•ifN=2thenteturn(N)•elsereturn(N*F(N-1));•begin•read(A);/*A=5*/•B:=F(A);•write(B);•end.74K+11K+6D+12F+13K+6(SP1)+14+15K+11D+161+174N+18K+19K+14D+20F+21D4K5K+1D+2A+3B+4F+5K(SP0)+6+7K+2+81+9N+1075•–•–“”(heap)–76•1•––772•••782•(1)––•(2)––792•(3)––803•mnnnmm••811•:–Dispose(P);free(p);•––:–•822•1–•2––••832•PASCAL•841)Fortran()2)C3)PASCALDISPLAYDISPLAYDISPLAY
本文标题:廖力编译原理课件第8章
链接地址:https://www.777doc.com/doc-1776876 .html