Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
pSIMPLETRON 1.4 - LMS.pas

LMS.pas

Caricato da: NOVA99
Scarica il programma completo

  1. (*
  2. *       pSIMPLETRON 1.4
  3. *
  4. *   COMPLETATO IL 07/09/2014
  5. *
  6. *          BY NOVA99
  7. *)
  8.  
  9. unit LMS;
  10.  
  11. interface
  12.  
  13. uses crt;
  14.  
  15. var (*MEMORIE DI SISTEMA*)
  16.       InstructionReg:Array[0..100] of integer; //MEMORIA DEL PROGRAMMA
  17.       InstructionMem:Array[0..100] of integer; //CRONOLOGIA DELLE ISTRUZIONI ESEGUITE
  18.       Memory:Array[0..100] of real; //MEMORIA VARIABILI
  19.  
  20.  
  21.     (*REGISTRI*)
  22.       numI:byte; //CONTATORE ISTRUZIONI
  23.       operationCode:integer; //IDENTIFICATORE DELL'OPERAZIONE DA ESEGUIRE
  24.       operand:integer; //IDENTIFICATORE DELLA POSZIONE DELLA VARIABILE IN USO
  25.       accumulator:real; //ACCUMULATORE ARITMETICO
  26.       aux_accumulator:real; //ACCUMULATORE AUSILIARIO
  27.       exit_correct:string[12]='SUCCESSFUL'; //REGISTRO DEL TIPO DI USCITA
  28.    
  29.       cont:byte=00; //VARIABILE DI SERVIZIO
  30.  
  31. const (*COMMENTI*)
  32.       OLC        = 00; //COMMENTO SU UNA RIGA
  33.       MLC        = 01; //COMMENTO SU PIU' RIGHE
  34.  
  35.       (*OPERAZIONI DI I/O*)
  36.       CIN        = 10; //INPUT
  37.       COUT       = 11; //OUTPUT
  38.      
  39.       (*OPERAZIONI DI GESTIONE DELLA MEMORIA (x = Memory[ x ]) *)
  40.       LOAD       = 20; //CARICA NELL'ACCUMULATORE
  41.       STORE      = 21; //SALVA IN x
  42.       DELETE     = 22; //RESETTA x
  43.       RESET      = 23; //RESETTA LA MEMORIA
  44.       RESETINSTR = 24; //RESETTA LA CRONOLOGIA DELLE ISTRUZIONI
  45.       LOADAUX    = 25; //CARICA x NELL'ACCUMULATORE AUSILIARIO
  46.       RANDR      = 26; //SALVA IN x UN NUMERO REALE CASUALE TR 0 E 1
  47.       RANDINT    = 27; //  "    " "  "   "    INTERO CASUALE TRA 0 E [ACCUMULATORE]
  48.      
  49.       (*OPERAZIONI MATEMATICHE FONDAMENTALI (x = Memory[ x ]) *)
  50.       ADD        = 30; //AGGIUNGE x ALL'ACCUMULATORE
  51.       SUBTR      = 31; //SOTTRAE  x  "      "
  52.       DIVIS      = 32; //DIVIDE   L'ACCUMULATORE PER x
  53.       MULT       = 33; //MOLTIPLICA   L'ACCUMULATORE PER x
  54.       QUOZ       = 34; //QUOTA    L'ACCUMULATORE PER x
  55.       RES        = 35; //CALCOLA IL RESTO DELL'OP. PRECEDENTE
  56.       ROOF       = 36; //ARROTONDA x ALL'INTERO MINORE PIU' VICINO
  57.       CEIL       = 37; //    "     "  "    "  MAGGIORE PIU' VICINO
  58.       FROUND     = 38; //ARROTONDA x
  59.       FABS       = 39; //CALCOLA IL VALORE ASSOLUTO DI x
  60.          
  61.       (*OPERAZIONI DI CONTROLLO (x = Memory[ x ], y = InstructionReg[ y ]) *)
  62.       BRANCH     = 40; //SALTA A y
  63.       BRANCHNEG  = 41; //  "    "      "      " SE L'ACCUMULATORE E' NEGATIVO
  64.       BRANCHZERO = 42; //  "    "      "      "  "        "       "  ZERO
  65.       BRANCHPOS  = 43; //  "    "      "      "  "        "       "  POSITIVO
  66.       HALT       = 44; //INTERROMPE L'ESECUZIONE
  67.       PAUSE      = 45; //METTE IN PAUSA L'ESECUZIONE E CHIEDE UN INPUT PER CONTINUARE
  68.       RETARD     = 46; //RITARDA L'ESECUZIONE PER x SECONDI
  69.       BRANCHMORE = 47; //SALTA A y SE ACCUMULATORE > ACCUMULATORE_AUSLIARIO
  70.       BRANCHEQL  = 48; //  "   " "  "     "        =            "  
  71.       BRANCHLESS = 49; //  "   " "  "     "        <            "
  72.      
  73.       (*OPERAZIONI MATEMATICHE AVANZATE (x = Memory[ x ]) *)
  74.       FSQRT      = 50; //CALCOLA LA RADICE DI x
  75.       FSQR       = 51; //   "    IL QUADRATO DI x
  76.       FEXP       = 52; //   "    L'ESPONENZIALE DI x
  77.       FLOG       = 53; //   "    IL LOGARITMO DECIMALE DI x
  78.       FLN        = 54; //   "     "    "      NATURALE "  "
  79.       POW        = 55; //   "    ACCUMULATORE ^ x
  80.       ROOT       = 56; //   "    x-esima RADICE DELL'ACCUMULATORE
  81.       FSIN       = 57; //   "    IL SENO DI x
  82.       FCOS       = 58; //   "     " COSENO DI x  
  83.       FTAN       = 59; //   "    LA TANGENTE DI x
  84.      
  85.       (*OPERAZIONE AUSILIARIA*)
  86.       STOPLOAD   = 9999; //INTERROMPE L'INSERIMENTO DEL PROGRAMMA
  87.      
  88.       CodeMem : SET OF byte = [CIN, COUT, LOAD..RANDINT, ADD..FABS, BRANCH..BRANCHLESS, FSQRT..FTAN, 99]; //MEMORIA DELLE FUNZIONI UTILIZZABILI
  89.      
  90. procedure Caption; //VISUALIZZA A VIDEO L'INTESTAZIONE
  91. procedure GetInstr; //ACQUISISCE LE ISTRUZIONI
  92. function InstrOK:boolean; //CONTROLLA IL CODICE INSERITO
  93. procedure ExeInstr; //ESEGUE IL PROGRAMMA
  94. procedure ViewDump; //VISUALIZZA IL DUMP DI MEMORIA
  95.  
  96. implementation
  97.  
  98. procedure Caption;
  99. begin
  100.  
  101.      clrscr;
  102.      
  103.      writeln('*** WELCOME TO SIMPLETRON! ***');
  104.      writeln('*** PLEASE ENTER YOUR PROGRAM ONE INSTRUCTION ***');
  105.      writeln('*** (OR DATA WORD) AT A TIME. I WILL TYPE THE ***');
  106.      writeln('*** LOCATION NUMBER AND A QUESTION MARK (?).  ***');
  107.      writeln('*** YOU THEN TYPE THE WORD FOR THAT LOCATION. ***');
  108.      writeln('*** TYPE THE SENTINEL 9999 TO STOP ENTERING   ***');
  109.      writeln('*** YOUR PROGRAM ***');
  110.      writeln;writeln;
  111.  
  112. end;
  113.  
  114. procedure GetInstr;
  115.  
  116. var instr : integer = 0;
  117.     comment : string;
  118.  
  119. begin
  120.  
  121.      numI:=0;
  122.      
  123.      repeat
  124.      begin
  125.  
  126.        write(numI, ' ? ');
  127.        readln( instr );
  128.        
  129.        if (instr = OLC) then
  130.        begin
  131.        
  132.             numI-=1;
  133.        
  134.             gotoXY( 1, WhereY-1);
  135.             ClrEOL;
  136.             writeln;
  137.        
  138.             write('# >   ');
  139.             readln(comment);
  140.        
  141.             writeln;
  142.        
  143.        end
  144.        else
  145.        begin
  146.            
  147.             if (instr = MLC) then
  148.             begin
  149.        
  150.                 numI-=1;
  151.        
  152.                 gotoXY( 1, WhereY-1);
  153.                 ClrEOL;
  154.                 writeln;
  155.            
  156.                 write('##>   ');
  157.                 readln(comment);
  158.                
  159.                 while (comment <> '###') do
  160.                 begin
  161.            
  162.                     write('      ');
  163.                     readln(comment);
  164.            
  165.                 end;
  166.        
  167.                 writeln;
  168.        
  169.             end
  170.        
  171.             else InstructionReg[ numI ] := instr;
  172.        
  173.         end;
  174.    
  175.         numI+=1;
  176.  
  177.      end;
  178.      until InstructionReg[ numI-1 ] = STOPLOAD;
  179.  
  180.      writeln;writeln;
  181.      write('*** PROGRAM LOADING COMPLETE ***');
  182.      writeln;writeln;
  183.      write('*** START PROGRAM CONTROL... ***');
  184.      writeln;writeln;
  185.  
  186. end;
  187.  
  188. function InstrOK:boolean;
  189.  
  190. var err_num:byte = 0;
  191.     warn_num:byte = 0;
  192.     halt_flag:boolean=false;
  193.  
  194. begin
  195.  
  196.      numI:=00;
  197.      
  198.      if (InstructionReg[ 0 ] = 9999) then //SE L'UNICA ISTRUZIONE PRESENTE E' STOPLOAD IL PROGRAMMA NON PUO' (OVVIAMENTE) ESSERE ESEGUITO
  199.      begin
  200.      
  201.                writeln;
  202.                writeln('*** ERROR FOUND IN LINE N°0: ***');
  203.                writeln('*** NO INSTRUCTION BEFORE STOPLOAD (9999)  ***');
  204.                writeln;
  205.            
  206.                err_num:=1;
  207.      end
  208.      else
  209.      begin
  210.          repeat
  211.                
  212.                //CONTROLLA SE L'ISTRUZIONE E' COMPRESA TRA STOPLOAD (9999) E L'INPUT ALLA VARIABILE 0 (1000)
  213.                 if  NOT( InstructionReg[ numI ] = STOPLOAD) AND NOT( (InstructionReg[ numI ] < 6000) AND (InstructionReg[ numI ] > 999) ) then
  214.                 begin
  215.  
  216.                     err_num+=1;
  217.                
  218.                     writeln;
  219.                     writeln('*** ERROR FOUND IN LINE N°', numI, ': ***');
  220.                     writeln('*** INSTRUCTION ''', InstructionReg[ numI ], ''' IS OUT OF THE ALLOWED RANGE  ***');
  221.                     writeln;
  222.  
  223.                 end;
  224.            
  225.                 operationCode:=InstructionReg[ numI ] div 100;
  226.                 operand:=InstructionReg[ numI ] mod 100;    
  227.        
  228.                 //CONTROLLA CHE IL CODICE DELL'OPERAZIONE ESISTA IN MEMORIA
  229.                 if NOT(  operationCode in CodeMem ) then
  230.                 begin
  231.  
  232.                     err_num+=1;
  233.  
  234.                     writeln;
  235.                     writeln('*** ERROR FOUND IN LINE N°', numI:2, ':  ***');
  236.                     writeln('*** INSTRUCTION CODE ''', operationCode, ''' NOT FOUND ***');
  237.                     writeln;
  238.  
  239.                 end
  240.                 else
  241.                 begin
  242.          
  243.                      if ( operand > 1) AND ( operationCode = PAUSE) then //LA FUNZIONE PAUSE ACCETTA COME ARGOMENTI  0 O 1
  244.                      begin
  245.        
  246.                           err_num+=1;
  247.  
  248.                           writeln;
  249.                           writeln('*** ERROR FOUND IN LINE N°', numI:2, ':  ***');
  250.                           writeln('*** INVALID ARGUMENT (''', operand ,''') FOR PAUSE FUNCTION ***');
  251.                           writeln;
  252.        
  253.                      end;
  254.                      
  255.                      //LE FUNZIONI RESET, RESETINSTR E HALT NON RICHIEDONO ARGOMENTI. SE QUESTI VENGONO INSERITI SONO IGNORATI
  256.                      if ((operationCode = RESET) OR (operationCode = RESETINSTR) OR (operationCode = HALT)) AND (operand > 0) then
  257.                      begin
  258.            
  259.                           writeln;
  260.                           writeln('*** WARNING IN LINE N°', numI:2, ':  ***');
  261.                           writeln('*** THIS FUNCTION DOESN''T USE AN ARGUMENT. ***');
  262.                           writeln('*** YOUR ARGUMENT (''', operand ,''') WILL BE IGNORED  ***');
  263.                           writeln;
  264.                        
  265.                           warn_num+=1;  
  266.        
  267.                      end;
  268.  
  269.            
  270.                 end;                
  271.                
  272.                 numI+=1;
  273.        
  274.                 if operationCode=HALT then halt_flag:=true; //CONTROLLA CHE VI SIA UNA ISTRUZIONE HALT
  275.  
  276.           until InstructionReg[ numI-1 ] = STOPLOAD;
  277.      
  278.       end;
  279.      
  280.      
  281.       if err_num>0 then
  282.       begin
  283.  
  284.            writeln;
  285.            writeln('*** ', err_num, ' ERROR(S) FOUND ***');
  286.            if warn_num>0 then writeln('*** ', warn_num:2, ' WARNING(S) GENERATED ***');
  287.            writeln('*** PROGRAM CAN''T BE EXECUTED ***');
  288.            writeln;
  289.  
  290.            InstrOK:=false;
  291.  
  292.       end
  293.       else
  294.       begin
  295.  
  296.            //SE NON VI SONO HALT IL PROGRAMMA POTREBBE COMPORTARSI IN MODO IMPREVEDIBILE
  297.            if halt_flag=false then
  298.            begin
  299.        
  300.                 writeln;
  301.                 writeln('*** WARNING: NO HALT FUNCTIONS FOUND ***');
  302.                 writeln('*** EXECUTION WON''T STOP TILL A STOPLOAD  ***');
  303.                 writeln('*** PROGRAM''S BEAHVIOR COULD BE UNDEFINED ***');
  304.                 writeln;
  305.        
  306.                 warn_num+=1;
  307.        
  308.            end;
  309.                  
  310.            writeln;
  311.            writeln('*** NO ERRORS FOUND ***');
  312.            if warn_num>0 then writeln('*** ', warn_num:2, ' WARNING(S) GENERATED ***');
  313.            writeln('*** PROGRAM CAN BE EXECUTED ***');
  314.            writeln;
  315.  
  316.            InstrOK:=true;
  317.  
  318.       end;
  319.  
  320. end;
  321.  
  322. procedure ExeInstr;
  323.  
  324. var cont2, cont3:byte;
  325.     instruction:integer;
  326.     delay_factor:integer;
  327.     rand_max:integer;
  328.  
  329. begin
  330.  
  331.      cont3:=00;
  332.      numI:=0;
  333.      
  334.      cont:=0;
  335.      
  336.      randomize;
  337.        
  338.      repeat
  339.      begin
  340.  
  341.             instruction:=InstructionReg[ numI ];
  342.  
  343.             operationCode:=instruction div 100;
  344.             operand      :=instruction mod 100;
  345.            
  346.             //SE LA FUNZIONE ATTUALE PRODUCE UN OUTPUT A VIDEO, SI SCRIVE L'INIZIO DI UNA NUOVA RIGA A VIDEO
  347.             if ( operationCode = CIN ) OR ( operationCode = COUT ) then
  348.             begin
  349.        
  350.                 write(cont, ' > ');
  351.        
  352.             end;
  353.            
  354.             case operationCode of
  355.  
  356.                 CIN:  readln(Memory[ operand ]);
  357.                 COUT: writeln(Memory[ operand ]:6:4);
  358.  
  359.                 LOAD:       accumulator:=Memory[ operand ];
  360.                 STORE:      Memory[ operand ]:=accumulator;
  361.                 DELETE:     Memory[ operand ]:=0;
  362.                 RESET:      for cont2:=0 to 100 do Memory[ cont2 ]:=0;
  363.                 RESETINSTR: begin
  364.                                 for cont2:=0 to 100 do InstructionMem[ cont2 ]:=0;
  365.                                 cont3:=0;
  366.                             end;
  367.                 LOADAUX:    aux_accumulator:=Memory[ operand ];
  368.                 RANDR:      Memory[ operand ]:=random;
  369.                 RANDINT:    begin
  370.                                 rand_max:=trunc(accumulator);
  371.                                 Memory[ operand ]:=random( rand_max +1);
  372.                             end;
  373.  
  374.                 ADD:    accumulator+=Memory[ operand ];
  375.                 SUBTR:  accumulator-=Memory[ operand ];
  376.                 DIVIS:  begin
  377.  
  378.                              //SE SI STA TENTANDO DI DIVIDERE 0/0 O <NUMERO NATURALE>/0 SI PRODUCE UN ERRORE
  379.                              if ( ( Memory[ operand ]= 0)AND(accumulator = 0) ) OR ( ( Memory[ operand ]= 0)AND(accumulator <> 0) ) then
  380.                              begin
  381.                                
  382.                                  writeln;
  383.                                
  384.                                  if ( Memory[ operand ]= 0)AND(accumulator = 0) then
  385.                                  begin
  386.                                          writeln('*** ATTEMPT TO DIVIDE 0 BY 0. UNDEFINED RESULT ***');
  387.                                          writeln('*** SIMPLETRON EXECUTON ABNORMALLY TERMINATED ***');
  388.                                  end
  389.                                  else
  390.                                  begin
  391.                                         if ( Memory[ operand ]= 0)AND(accumulator <> 0) then writeln('*** ATTEMPT TO DIVIDE BY 0. IMPOSSIBLE OPERATION ***');
  392.                                         writeln('*** SIMPLETRON EXECUTION ABNORMALLY TERMINATED   ***');
  393.                                  end;
  394.                                
  395.                                  exit_correct:='FAILURE';
  396.                                  break;
  397.                
  398.                              end
  399.                              else accumulator /= Memory[ operand ];
  400.                
  401.                         end;
  402.                 MULT:   accumulator *= Memory[ operand ];
  403.                 QUOZ:   accumulator := trunc(accumulator) div trunc( Memory[ operand ] );
  404.                 RES:    accumulator := trunc(accumulator) mod trunc( Memory[ operand ] );
  405.                 ROOF:   Memory[ operand ] := trunc(Memory[ operand ]);
  406.                 CEIL:   Memory[ operand ] := trunc(Memory[ operand ]) + 1;
  407.                 FROUND: Memory[ operand ] := round(Memory[ operand ]);
  408.                 FABS:   Memory[ operand ] := abs(Memory[ operand ]);
  409.  
  410.                 BRANCH:     numI:=operand;
  411.                 BRANCHNEG:  if(accumulator<0)then numI:=operand else numI+=1;
  412.                 BRANCHZERO: if(accumulator=0)then numI:=operand else numI+=1;
  413.                 BRANCHPOS:  if(accumulator>0)then numI:=operand else numI+=1;
  414.                 HALT:       begin
  415.                                 writeln;
  416.                                 writeln('*** SIMPLETRON EXECUTION TERMINATED ***');
  417.                                 break;
  418.                             end;
  419.                 PAUSE:      begin
  420.                                 if operand=1 then write('  *** PRESS A KEY TO PROCEED... ***');
  421.                                 readkey;
  422.                                 gotoXY( 1, WhereY);
  423.                                 ClrEOL;
  424.                             end;
  425.                 RETARD:     begin
  426.                                 write('*** DELAYING EXECUTION... ***');
  427.                                 delay_factor := trunc(Memory[ operand ] * 1000);
  428.                                 delay(delay_factor);
  429.                                 gotoXY( 1, WhereY);
  430.                                 ClrEOL;
  431.                             end;
  432.                 BRANCHMORE:if(accumulator>aux_accumulator)then numI:=operand else numI+=1;
  433.                 BRANCHEQL: if(accumulator=aux_accumulator)then numI:=operand else numI+=1;
  434.                 BRANCHLESS:if(accumulator<aux_accumulator)then numI:=operand else numI+=1;
  435.                                
  436.                        //COM'E' NOTO, CALCOLARE UNA RADICE PARI DI UN NUMERO NEGATIVO PRODUCE UN ERRORE
  437.                 FSQRT: if (Memory[ operand ]>=0) then accumulator := SQRT(Memory[ operand ])
  438.                        else
  439.                        begin
  440.                
  441.                             writeln;
  442.                             writeln('*** ATTEMPT TO CALCULATE THE SQUARE ROOT OF A NEGATIVE NUMBER ***');
  443.                             writeln('*** SIMPLETRON EXECUTION ABNORMALLY TERMINATED ***');
  444.                             exit_correct:='FAILURE';
  445.                             break;
  446.                
  447.                         end;
  448.                 FSQR : Memory[ operand ] := SQR(Memory[ operand ]);
  449.                 FEXP : Memory[ operand ] := EXP(Memory[ operand ]);
  450.                 FLOG : Memory[ operand ] := LN(Memory[ operand ]) / LN(10);
  451.                 FLN  : Memory[ operand ] := LN(Memory[ operand ]);
  452.                 POW  : accumulator := EXP( LN(accumulator) * Memory[ operand ] );
  453.                 ROOT : begin
  454.        
  455.                            if (accumulator>=0) then accumulator := EXP( LN(accumulator) / Memory[ operand ] )
  456.                            else
  457.                            begin
  458.                                 if ( trunc(Memory[ operand ]) mod 2 ) <> 0 then
  459.                                 begin
  460.                    
  461.                                     writeln;
  462.                                     writeln('*** ATTEMPT TO CALCULATE AN EVEN ROOT OF A NEGATIVE NUMBER ***');
  463.                                     writeln('*** SIMPLETRON EXECUTION ABNORMALLY TERMINATED ***');
  464.                                     exit_correct:='FAILURE';
  465.                                     break;
  466.                                    
  467.                                  end
  468.                                  else accumulator := EXP( LN(accumulator) / Memory[ operand ] );
  469.                      
  470.                             end;
  471.                
  472.                         end;
  473.                 FSIN : Memory[ operand ] := SIN(Memory[ operand ]);
  474.                 FCOS : Memory[ operand ] := COS(Memory[ operand ]);
  475.                 FTAN : Memory[ operand ] := SIN(Memory[ operand ])/COS(Memory[ operand ]);
  476.  
  477.            end;
  478.  
  479.            InstructionMem[ cont3 ]:=instruction;
  480.            cont3+=1;
  481.            
  482.            
  483.            //SE NON SONO STATI ESEGUITI SALTI IL CONTATORE VIENE INCREMENTATO NORMALMENTE
  484.            if NOT( (operationCode>=BRANCH) AND (operationCode<=BRANCHPOS) ) then
  485.            begin
  486.  
  487.                 numI+=1;
  488.  
  489.            end;
  490.        
  491.            if ( operationCode = CIN ) OR ( operationCode = COUT ) then cont+=1;
  492.        
  493.      end;
  494.      until (instruction=HALT) OR (instruction=STOPLOAD); //NORMALMENTE
  495.      
  496.      ViewDump;
  497.  
  498. end;
  499.  
  500. procedure ViewDump;
  501.  
  502. var sn:char;
  503.     cont2:byte=00;
  504.  
  505. begin
  506.  
  507.     writeln;writeln;writeln;
  508.     writeln('*** PRESS ''1'' TO SEE THE MEMORY DUMP ***');
  509.    
  510.     sn:=readkey;
  511.    
  512.     gotoXY( 1, WhereY-1);
  513.     ClrEOL;
  514.    
  515.     cont := 0;
  516.    
  517.     if sn='1' then
  518.     begin
  519.    
  520.         writeln('******** SYSTEM REGISTERS:');
  521.         writeln('*');
  522.         writeln('*  ACCUMULATOR          = ', accumulator:5:2);
  523.         writeln('*');
  524.         writeln('*  AUXILIAR ACCUMULATOR = ', aux_accumulator:5:2);
  525.         writeln('*');
  526.         writeln('*  OPERATION CODE       = ', operationCode);
  527.         writeln('*');
  528.         writeln('*  OPERAND              = ', operand);
  529.         writeln('*');
  530.         writeln('*  INSTRUCTION COUNTER  = ', numI);
  531.         writeln('*');
  532.         writeln('*  EXIT TYPE            = ', exit_correct );
  533.         writeln('*');
  534.    
  535.         writeln;writeln;
  536.    
  537.         writeln('******** VARIABLES MEMORY');
  538.         writeln('*');
  539.         writeln('*       0      1      2      3      4      5      6      7      8      9');
  540.         writeln('*');
  541.         write('* ', cont,'   ');
  542.    
  543.         while (cont<100) do
  544.         begin
  545.            
  546.             for cont2:=0 to 9 do write(Memory[ cont + cont2 ]:5:2,'  ');
  547.  
  548.             if (cont<100) then writeln;writeln('*');
  549.  
  550.             cont+=10;
  551.  
  552.             if (cont<100) then write('* ', cont,'  ');
  553.  
  554.         end;
  555.    
  556.         cont:=00;
  557.    
  558.         writeln;writeln;
  559.    
  560.         //LA CRONOLOGIA DELLE ISTRUZIONI VIENE VISUALIZZATA (E REGISTRATA) PER RENDERE CONTO DI COME E' STATO ESEGUITO IL PROGRAMMA
  561.         writeln('******** INSTRUCTIONS TIMELINE:');
  562.         writeln('*');
  563.         writeln('*        0     1     2     3     4     5     6     7     8     9');
  564.         writeln('*');
  565.         write('* ', cont,'   ');
  566.    
  567.         while (cont<100) do
  568.         begin
  569.            
  570.             for cont2:=0 to 9 do write(InstructionMem[ cont + cont2 ]:4,'  ');
  571.  
  572.             if (cont<100) then writeln;writeln('*');
  573.  
  574.             cont+=10;
  575.  
  576.             if (cont<100) then write('* ', cont,'  ');
  577.  
  578.         end;
  579.    
  580.     end;
  581.  
  582. end;
  583.  
  584. end.