eugeniucarvalho 6 years ago
parent
commit
8425921ec1

BIN
build/classes/compiler/IVANNOSYS.class


BIN
build/classes/target/mips/TListenerMips.class


BIN
build/classes/target/mips/UpdateAddressProcessor.class


BIN
build/classes/tools/mips/MipsProcessor.class


+ 27 - 27
build/classes/tools/mips/memory/md.memory

@@ -1,22 +1,22 @@
-0000:	1
-0004:	2
-0008:	3
-0012:	4
-0016:	1
-0020:	2
-0024:	3
-0028:	4
-0032:	7
-0036:	10
-0040:	15
-0044:	22
-0048:	0
-0052:	0
+0000:	0
+0004:	0
+0008:	0
+0012:	0
+0016:	0
+0020:	0
+0024:	1
+0028:	2
+0032:	3
+0036:	0
+0040:	0
+0044:	4
+0048:	5
+0052:	6
 0056:	0
 0060:	0
-0064:	0
-0068:	0
-0072:	0
+0064:	7
+0068:	8
+0072:	9
 0076:	0
 0080:	0
 0084:	0
@@ -29,19 +29,19 @@
 0112:	0
 0116:	0
 0120:	0
-0124:	0
-0128:	0
-0132:	0
+0124:	2
+0128:	1
+0132:	-4
 0136:	0
 0140:	0
-0144:	0
+0144:	-3
 0148:	0
-0152:	0
+0152:	-7
 0156:	0
 0160:	0
-0164:	0
-0168:	0
-0172:	0
+0164:	-16
+0168:	-11
+0172:	-22
 0176:	0
 0180:	0
 0184:	0
@@ -4088,9 +4088,9 @@
 16348:	0
 16352:	0
 16356:	0
-16360:	0
+16360:	10
 16364:	0
 16368:	0
-16372:	5
+16372:	0
 16376:	0
 16380:	0

+ 112 - 74
build/classes/tools/mips/memory/mi.memory

@@ -1,89 +1,127 @@
 0666697728
 0001962017
 0201326597
-0201326630
+0201326637
 4294967295
-0666763252
+0666763240
 0001962017
 0605028353
-0605093888
-0134217761
-0605159424
-0134217757
-0001136673
-0000745536
-0001206305
-0026042401
-0000815232
-0059666465
-2916089856
-0001144865
-0001032256
-0001196065
-0050905121
-0001591424
-0059328545
-2905604112
+0605093892
+0605159428
+0605224960
+0134217768
+0605290496
+0134217764
+0604831744
+0309133313
+0376504322
+0605356032
+0134217755
+0604962816
+0311361537
+0378667010
+0605356032
+0134217755
+0001091617
 0638582785
 2949644288
-0642908161
-0604831746
-0038604835
-0071368685
-0640745473
-0604897282
-0036573219
+0001263649
+0000610432
+0019548193
+0001333281
+0019613729
+0000614528
+0059531297
+2912223232
+0647233537
+0604897285
+0042864675
 0071368679
-0666697740
+0645070849
+0605552645
+0041422883
+0071368673
+0666697752
 0065011720
-0666763248
+0666763228
 0001962017
-0605028352
-0605093888
-0134217812
-0605159424
-0134217808
-0605224960
-0134217795
-0001138721
-0000813120
-0001273889
-0028207137
-0000882816
-0059734049
-2381578240
-0001359905
-0001261601
-0000542784
-0001200161
+0605028356
+0605093892
+0605159425
+0134217851
+0605224961
+0134217848
+0604831745
+0038625315
+0000815232
+0026107937
+0001275937
+0026173473
+0000835712
+0060342305
+2400452608
+0001327137
+0001198113
+0000610432
 0019548193
-0000612480
-0059463713
-2373255184
-0001400865
-0051146776
-0000028690
-0034504737
+0604831745
+0040720419
+0019613729
+0000618624
+0059666465
+2379546624
+0001407009
+0017784865
+0001228833
+0001593472
+0051036193
+0644677633
+0051232801
+0001591424
+0059328545
+2369126400
+0001470497
+0026099745
+0642711553
+0001005696
+0032208929
+0001271841
+0032340001
+0001032320
+0060342305
+2400649216
+0001525793
+0017391649
+0001208353
+0000938112
+0030044193
+0001267745
+0030109729
+0000944256
+0059598881
+2377383936
+0001341473
+0604504068
+0032030744
+0000049170
+0026781731
+0604569855
+0044634147
+0406847489
+0605356287
+0001202209
+0000749696
+0024008737
+0001271841
+0023943201
+0000751744
+0059734049
+2918514788
 0645070849
-0604962818
-0040833059
-0071368682
-0001130529
-0000544832
-0001198113
-0021581857
-0000678016
-0059463713
-2909798432
-0605028352
-2949644288
+0040964131
+0071368635
 0642908161
-0604897282
-0038670371
-0071368667
-0640745473
-0604962818
-0036638755
-0071368661
-0666697744
+0038801443
+0071368630
+0666697764
 0065011720

+ 13 - 9
nbproject/private/private.xml

@@ -10,31 +10,35 @@
             </bookmark>
         </file>
         <file>
-            <url>src/samples/program.go</url>
-            <bookmark id="3">
+            <url>src/samples/program.ivan</url>
+            <bookmark id="1">
                 <name/>
-                <line>81</line>
+                <line>32</line>
                 <key/>
             </bookmark>
         </file>
         <file>
-            <url>src/samples/program.ivan</url>
-            <bookmark id="1">
+            <url>src/samples/program.go</url>
+            <bookmark id="3">
                 <name/>
-                <line>32</line>
+                <line>91</line>
                 <key/>
             </bookmark>
         </file>
     </editor-bookmarks>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
         <group>
+            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/target/mips/TemplateMips.java</file>
+            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/target/mips/TListenerMips.java</file>
+            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/target/mips/Mips.java</file>
+            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/IntermediaryCode/CodeOtimizadorProcessor.java</file>
             <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/IntermediaryCode/BaseTacGen.java</file>
-            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/tools/mips/memory/mips.code</file>
-            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/IntermediaryCode/Code.java</file>
+            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/tools/mips/memory/md.memory</file>
+            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/tools/mips/MipsProcessor.java</file>
             <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/target/mips/UpdateAddressProcessor.java</file>
             <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/target/mips/Gen.java</file>
+            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/compiler/IVANNOSYS.java</file>
             <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/samples/program.go</file>
-            <file>file:/C:/Users/EUGENIO%20CARVALHO/Desktop/projects/Ivannosys/src/API/Instruction.java</file>
         </group>
     </open-files>
 </project-private>

+ 2 - 2
src/compiler/IVANNOSYS.java

@@ -34,9 +34,9 @@ public class IVANNOSYS {
                     break;
                 default:
                     compiler = new IvannosysCompiler(
+                            "src\\samples\\program.go",
 //                            "src\\samples\\program.go",
-//                            "src\\samples\\program.go",
-                            "src\\samples\\program_mult.go",
+//                            "src\\samples\\program_mult.go",
                             "UTF-8",
                             IvannosysCompiler.INPUT_FILE)
                             // Especifica a classe de geração de codigo de tres enderecos

+ 7 - 3
src/target/mips/TListenerMips.java

@@ -74,7 +74,7 @@ class TListenerMips extends template.TListener {
                 // Corresponde a posicao do label destino (decimal)
                 laddress = gctx.G(label);
 
-//        System.out.printf("TemplateListener:{%s\n %s\n %s\n %s\n}\n", base, baseAddress, label, laddress);
+        System.out.printf("TemplateListener:{%s\n %s\n %s\n %s\n}\n", base, baseAddress, label, laddress);
         int value = Integer.parseInt(laddress);
         int fromStart = value - Integer.parseInt(baseAddress);
 
@@ -157,6 +157,7 @@ class TListenerMips extends template.TListener {
             return "";
         }
 
+        long shift;
         //
         switch (type) {
             case "S": // (j | jal) Salta para o endereco de destino
@@ -166,10 +167,13 @@ class TListenerMips extends template.TListener {
 //                System.out.println("JUMP:" + gctx.G(ctx.G("label")) + ":"
 //                        + (Long.parseLong(gctx.G(ctx.G("label")), 10) >> 2));
 
-                long shift = (Long.parseLong(gctx.G(ctx.G("label")), 10) >> 2);
+                shift = (Long.parseLong(gctx.G(ctx.G("label")), 10) >> 2);
                 ctx.Set("target", BIN("" + shift, 26));
                 break;
-            case "I": // (bne...) Salta para posicao em relacao ao pc atual
+            case "I": // (bne...) Salta para posicao em relacao ao pc atual + 4
+//                System.out.println("BIN iiiiii" + ctx);
+//                shift = (Long.parseLong(gctx.G(ctx.G("label")), 10) >> 2);
+//                ctx.Set("target", BIN("" + shift, 26));
 
 //                if (ctx.G("offset").equals("") && !ctx.G("label").equals("")) {
 //

+ 3 - 2
src/target/mips/UpdateAddressProcessor.java

@@ -61,8 +61,9 @@ class UpdateAddressProcessor implements CodeProcessing {
                 if (updateOffsetShift.containsKey(y.G("inst"))) {
 //                    System.out.println("UPDATE ADDRESS:" + y + c.labels);
                     offset = Integer.parseInt(c.labels.get(y.G("label")).get(0)) * 4;
-                    offset = (offset - y.getInt("global.position")) / 4;
-//                    System.out.println("Offset:" + offset);
+//                    System.out.println("Offset:" + offset + "--" + y.getInt("global.position"));
+                    offset = ((offset - y.getInt("global.position")) / 4) - 1;
+//                    System.out.println("OffsetCalculado:" + offset);
                     y.S("offset", offset);
                 }
             }

+ 6 - 6
src/tools/mips/MipsProcessor.java

@@ -320,39 +320,39 @@ public class MipsProcessor {
 //            // I
             case "beq":
                 if (RBank.R(rs) == RBank.R(rt)) {
-                    PC += imm << 2;
+                    PC += ((imm + 1) << 2);
                     return;
                 }
                 break;
             case "bgez":
                 if (RBank.R(rs) >= 0) {
-                    PC += imm << 2;
+                    PC += ((imm + 1) << 2);
                     return;
                 }
                 break;
             case "bgtz":
                 if (RBank.R(rs) > 0) {
-                    PC += imm << 2;
+                    PC += ((imm + 1) << 2);
                     return;
                 }
                 break;
 
             case "blez":
                 if (RBank.R(rs) <= 0) {
-                    PC += imm << 2;
+                    PC += ((imm + 1) << 2);
                     return;
                 }
                 break;
             case "bltz":
 //                System.out.println("BLTZ:" + rs);
                 if (RBank.R(rs) < 0) {
-                    PC += imm << 2;
+                    PC += ((imm + 1) << 2);
                     return;
                 }
                 break;
             case "bne":
                 if (RBank.R(rs) != RBank.R(rt)) {
-                    PC += imm << 2;
+                    PC += ((imm + 1) << 2);
                     return;
                 }
                 break;

+ 27 - 27
src/tools/mips/memory/md.memory

@@ -1,22 +1,22 @@
-0000:	1
-0004:	2
-0008:	3
-0012:	4
-0016:	1
-0020:	2
-0024:	3
-0028:	4
-0032:	7
-0036:	10
-0040:	15
-0044:	22
-0048:	0
-0052:	0
+0000:	0
+0004:	0
+0008:	0
+0012:	0
+0016:	0
+0020:	0
+0024:	1
+0028:	2
+0032:	3
+0036:	0
+0040:	0
+0044:	4
+0048:	5
+0052:	6
 0056:	0
 0060:	0
-0064:	0
-0068:	0
-0072:	0
+0064:	7
+0068:	8
+0072:	9
 0076:	0
 0080:	0
 0084:	0
@@ -29,19 +29,19 @@
 0112:	0
 0116:	0
 0120:	0
-0124:	0
-0128:	0
-0132:	0
+0124:	2
+0128:	1
+0132:	-4
 0136:	0
 0140:	0
-0144:	0
+0144:	-3
 0148:	0
-0152:	0
+0152:	-7
 0156:	0
 0160:	0
-0164:	0
-0168:	0
-0172:	0
+0164:	-16
+0168:	-11
+0172:	-22
 0176:	0
 0180:	0
 0184:	0
@@ -4088,9 +4088,9 @@
 16348:	0
 16352:	0
 16356:	0
-16360:	0
+16360:	10
 16364:	0
 16368:	0
-16372:	5
+16372:	0
 16376:	0
 16380:	0

+ 112 - 74
src/tools/mips/memory/mi.memory

@@ -1,89 +1,127 @@
 0666697728
 0001962017
 0201326597
-0201326630
+0201326637
 4294967295
-0666763252
+0666763240
 0001962017
 0605028353
-0605093888
-0134217761
-0605159424
-0134217757
-0001136673
-0000745536
-0001206305
-0026042401
-0000815232
-0059666465
-2916089856
-0001144865
-0001032256
-0001196065
-0050905121
-0001591424
-0059328545
-2905604112
+0605093892
+0605159428
+0605224960
+0134217768
+0605290496
+0134217764
+0604831744
+0309133313
+0376504322
+0605356032
+0134217755
+0604962816
+0311361537
+0378667010
+0605356032
+0134217755
+0001091617
 0638582785
 2949644288
-0642908161
-0604831746
-0038604835
-0071368685
-0640745473
-0604897282
-0036573219
+0001263649
+0000610432
+0019548193
+0001333281
+0019613729
+0000614528
+0059531297
+2912223232
+0647233537
+0604897285
+0042864675
 0071368679
-0666697740
+0645070849
+0605552645
+0041422883
+0071368673
+0666697752
 0065011720
-0666763248
+0666763228
 0001962017
-0605028352
-0605093888
-0134217812
-0605159424
-0134217808
-0605224960
-0134217795
-0001138721
-0000813120
-0001273889
-0028207137
-0000882816
-0059734049
-2381578240
-0001359905
-0001261601
-0000542784
-0001200161
+0605028356
+0605093892
+0605159425
+0134217851
+0605224961
+0134217848
+0604831745
+0038625315
+0000815232
+0026107937
+0001275937
+0026173473
+0000835712
+0060342305
+2400452608
+0001327137
+0001198113
+0000610432
 0019548193
-0000612480
-0059463713
-2373255184
-0001400865
-0051146776
-0000028690
-0034504737
+0604831745
+0040720419
+0019613729
+0000618624
+0059666465
+2379546624
+0001407009
+0017784865
+0001228833
+0001593472
+0051036193
+0644677633
+0051232801
+0001591424
+0059328545
+2369126400
+0001470497
+0026099745
+0642711553
+0001005696
+0032208929
+0001271841
+0032340001
+0001032320
+0060342305
+2400649216
+0001525793
+0017391649
+0001208353
+0000938112
+0030044193
+0001267745
+0030109729
+0000944256
+0059598881
+2377383936
+0001341473
+0604504068
+0032030744
+0000049170
+0026781731
+0604569855
+0044634147
+0406847489
+0605356287
+0001202209
+0000749696
+0024008737
+0001271841
+0023943201
+0000751744
+0059734049
+2918514788
 0645070849
-0604962818
-0040833059
-0071368682
-0001130529
-0000544832
-0001198113
-0021581857
-0000678016
-0059463713
-2909798432
-0605028352
-2949644288
+0040964131
+0071368635
 0642908161
-0604897282
-0038670371
-0071368667
-0640745473
-0604962818
-0036638755
-0071368661
-0666697744
+0038801443
+0071368630
+0666697764
 0065011720