Browse Source

fix jump in if stmt

eugeniucarvalho 5 years ago
parent
commit
41d508fbba

BIN
build/classes/API/Api.class


BIN
build/classes/compiler/IVANNOSYS.class


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


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


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

@@ -23,33 +23,33 @@ DATA_RADIX = BIN;
 
 CONTENT
 BEGIN
-00000:	00000000000000000000000000000001;	% dec 1 %
-00004:	00000000000000000000000000000010;	% dec 2 %
-00008:	00000000000000000000000000000011;	% dec 3 %
-00012:	00000000000000000000000000000100;	% dec 4 %
-00016:	00000000000000000000000000000001;	% dec 1 %
-00020:	00000000000000000000000000000010;	% dec 2 %
-00024:	00000000000000000000000000000011;	% dec 3 %
-00028:	00000000000000000000000000000100;	% dec 4 %
-00032:	00000000000000000000000000000111;	% dec 7 %
-00036:	00000000000000000000000000001010;	% dec 10 %
-00040:	00000000000000000000000000001111;	% dec 15 %
-00044:	00000000000000000000000000010110;	% dec 22 %
+00000:	00000000000000000000000000000000;	% dec 0 %
+00004:	00000000000000000000000000000000;	% dec 0 %
+00008:	00000000000000000000000000000000;	% dec 0 %
+00012:	00000000000000000000000000000000;	% dec 0 %
+00016:	00000000000000000000000000000000;	% dec 0 %
+00020:	00000000000000000000000000000001;	% dec 1 %
+00024:	00000000000000000000000000000010;	% dec 2 %
+00028:	00000000000000000000000000000000;	% dec 0 %
+00032:	00000000000000000000000000000000;	% dec 0 %
+00036:	00000000000000000000000000000011;	% dec 3 %
+00040:	00000000000000000000000000000100;	% dec 4 %
+00044:	00000000000000000000000000000000;	% dec 0 %
 00048:	00000000000000000000000000000000;	% dec 0 %
 00052:	00000000000000000000000000000000;	% dec 0 %
 00056:	00000000000000000000000000000000;	% dec 0 %
 00060:	00000000000000000000000000000000;	% dec 0 %
 [64..80]:	00000000000000000000000000000000;
 00084:	00000000000000000000000000000001;	% dec 1 %
-00088:	11111111111111111111111111111111;	% dec 4294967295 %
+00088:	00000000000000000000000000000000;	% dec 0 %
 [92..96]:	00000000000000000000000000000000;
-00100:	11111111111111111111111111111111;	% dec 4294967295 %
-00104:	11111111111111111111111111111111;	% dec 4294967295 %
+00100:	00000000000000000000000000000000;	% dec 0 %
+00104:	00000000000000000000000000000000;	% dec 0 %
 [108..16356]:	00000000000000000000000000000000;
 16360:	00000000000000000000000000000101;	% dec 5 %
 16364:	00000000000000000000000000000011;	% dec 3 %
-16368:	00000000000000000000000000000000;	% dec 0 %
-16372:	00000000000000000000000000000010;	% dec 2 %
-16376:	00000000000000000000000000000010;	% dec 2 %
-16380:	00000000000000000000000000000010;	% dec 2 %
+16368:	00000000000000000000000000000011;	% dec 3 %
+16372:	00000000000000000000000000000011;	% dec 3 %
+16376:	00000000000000000000000000000011;	% dec 3 %
+16380:	00000000000000000000000000000000;	% dec 0 %
 END;

+ 219 - 146
build/classes/tools/mips/memory/mi.memory

@@ -25,166 +25,239 @@ CONTENT
 BEGIN
 000:	00001100000000000000000000000101;	% dec 201326597 %
 004:	00000000000000000000000000000000;	% dec 0 %
-008:	00001100000000000000000001000110;	% dec 201326662 %
+008:	00001100000000000000000001011011;	% dec 201326683 %
 012:	00000000000000000000000000000000;	% dec 0 %
-016:	11111111111111111111111111111111;	% dec 4294967295 %
-020:	00100111101111011111111111110100;	% dec 666763252 %
+016:	11111111111111111111111111111111;	% dec -1 %
+020:	00100111101111011111111111101000;	% dec 666763240 %
 024:	00000000000111011111000000100001;	% dec 1962017 %
 028:	00100100000100000000000000000001;	% dec 605028353 %
-032:	10101111110100000000000000000000;	% dec 2949644288 %
-036:	00100100000100010000000000000000;	% dec 605093888 %
-040:	10101111110100010000000000000100;	% dec 2949709828 %
-044:	00001000000000000000000000111101;	% dec 134217789 %
-048:	00000000000000000000000000000000;	% dec 0 %
-052:	00100100000100100000000000000000;	% dec 605159424 %
-056:	10101111110100100000000000001000;	% dec 2949775368 %
-060:	00001000000000000000000000110011;	% dec 134217779 %
+032:	10101111110100000000000000000000;	% dec -1345323008 %
+036:	00100100000100010000000000000011;	% dec 605093891 %
+040:	10101111110100010000000000000100;	% dec -1345257468 %
+044:	00100100000100100000000000000011;	% dec 605159427 %
+048:	10101111110100100000000000001000;	% dec -1345191928 %
+052:	00100100000100110000000000000000;	% dec 605224960 %
+056:	10101111110100110000000000001100;	% dec -1345126388 %
+060:	00001000000000000000000001010010;	% dec 134217810 %
 064:	00000000000000000000000000000000;	% dec 0 %
-068:	10001111110100110000000000000100;	% dec 2412969988 %
-072:	00000000000000000000000000000000;	% dec 0 %
-076:	00000000000100110101100000100001;	% dec 1267745 %
-080:	00000000000010110110000001000000;	% dec 745536 %
-084:	10001111110101000000000000001000;	% dec 2413035528 %
+068:	00100100000101000000000000000000;	% dec 605290496 %
+072:	10101111110101000000000000010000;	% dec -1345060848 %
+076:	00001000000000000000000001001000;	% dec 134217800 %
+080:	00000000000000000000000000000000;	% dec 0 %
+084:	10001111110101010000000000001100;	% dec -1881866228 %
 088:	00000000000000000000000000000000;	% dec 0 %
-092:	00000000000101000110100000100001;	% dec 1337377 %
-096:	00000001100011010110000000100001;	% dec 26042401 %
-100:	00000000000011000111000010000000;	% dec 815232 %
-104:	10001111110101010000000000000000;	% dec 2413101056 %
+092:	00010010101000000000000000000110;	% dec 312475654 %
+096:	00000000000000000000000000000000;	% dec 0 %
+100:	10001111110101100000000000001100;	% dec -1881800692 %
+104:	10001111110101110000000000000100;	% dec -1881735164 %
 108:	00000000000000000000000000000000;	% dec 0 %
-112:	00000011100011100111000000100001;	% dec 59666465 %
-116:	10101101110101010000000000000000;	% dec 2916417536 %
-120:	10001111110100110000000000000100;	% dec 2412969988 %
-124:	00000000000000000000000000000000;	% dec 0 %
-128:	00000000000100110111100000100001;	% dec 1275937 %
-132:	00000000000011111100000001000000;	% dec 1032256 %
-136:	10001111110101000000000000001000;	% dec 2413035528 %
+112:	00010110110101110000000000000101;	% dec 383188997 %
+116:	00000000000000000000000000000000;	% dec 0 %
+120:	00100100000100000000000000000000;	% dec 605028352 %
+124:	10101111110100000000000000010100;	% dec -1345322988 %
+128:	00001000000000000000000000110111;	% dec 134217783 %
+132:	00000000000000000000000000000000;	% dec 0 %
+136:	10001111110100010000000000010000;	% dec -1882128368 %
 140:	00000000000000000000000000000000;	% dec 0 %
-144:	00000000000101000100000000100001;	% dec 1327137 %
-148:	00000011000010001100000000100001;	% dec 50905121 %
-152:	00000000000110000100100010000000;	% dec 1591424 %
-156:	10001111110101010000000000000000;	% dec 2413101056 %
+144:	00010010001000000000000000000110;	% dec 304087046 %
+148:	00000000000000000000000000000000;	% dec 0 %
+152:	10001111110100100000000000010000;	% dec -1882062832 %
+156:	10001111110100110000000000001000;	% dec -1881997304 %
 160:	00000000000000000000000000000000;	% dec 0 %
-164:	00000011100010010100100000100001;	% dec 59328545 %
-168:	10101101001101010000000000010000;	% dec 2905931792 %
-172:	10001111110101010000000000000000;	% dec 2413101056 %
-176:	00000000000000000000000000000000;	% dec 0 %
-180:	00100110101101010000000000000001;	% dec 649396225 %
-184:	10101111110101010000000000000000;	% dec 2949971968 %
-188:	10001111110100000000000000001000;	% dec 2412773384 %
+164:	00010110010100110000000000000101;	% dec 374538245 %
+168:	00000000000000000000000000000000;	% dec 0 %
+172:	00100100000101000000000000000000;	% dec 605290496 %
+176:	10101111110101000000000000010100;	% dec -1345060844 %
+180:	00001000000000000000000000110111;	% dec 134217783 %
+184:	00000000000000000000000000000000;	% dec 0 %
+188:	10001111110101010000000000000000;	% dec -1881866240 %
 192:	00000000000000000000000000000000;	% dec 0 %
-196:	00100110000100000000000000000001;	% dec 638582785 %
-200:	10101111110100000000000000001000;	% dec 2949644296 %
-204:	10001111110100010000000000001000;	% dec 2412838920 %
+196:	00000000000101011011000000100001;	% dec 1421345 %
+200:	10101111110101100000000000010100;	% dec -1344929772 %
+204:	10001111110101010000000000000000;	% dec -1881866240 %
 208:	00000000000000000000000000000000;	% dec 0 %
-212:	00100100000011010000000000000010;	% dec 604831746 %
-216:	00000010001011010001000000100011;	% dec 36507683 %
-220:	00000100010000001111111111011001;	% dec 71368665 %
+212:	00100110101101010000000000000001;	% dec 649396225 %
+216:	10101111110101010000000000000000;	% dec -1344995328 %
+220:	10001111110101110000000000001100;	% dec -1881735156 %
 224:	00000000000000000000000000000000;	% dec 0 %
-228:	10001111110100100000000000000100;	% dec 2412904452 %
-232:	00000000000000000000000000000000;	% dec 0 %
-236:	00100110010100100000000000000001;	% dec 642908161 %
-240:	10101111110100100000000000000100;	% dec 2949775364 %
-244:	10001111110101100000000000000100;	% dec 2413166596 %
-248:	00000000000000000000000000000000;	% dec 0 %
-252:	00100100000011100000000000000010;	% dec 604897282 %
-256:	00000010110011100001000000100011;	% dec 47058979 %
-260:	00000100010000001111111111001011;	% dec 71368651 %
-264:	00000000000000000000000000000000;	% dec 0 %
-268:	00100111101111010000000000001100;	% dec 666697740 %
-272:	00000000000111011111000000100001;	% dec 1962017 %
-276:	00000011111000000000000000001000;	% dec 65011720 %
-280:	00100111101111011111111111110000;	% dec 666763248 %
-284:	00000000000111011111000000100001;	% dec 1962017 %
-288:	00100100000100000000000000000000;	% dec 605028352 %
-292:	10101111110100000000000000000000;	% dec 2949644288 %
-296:	00100100000100010000000000000000;	% dec 605093888 %
-300:	10101111110100010000000000000100;	% dec 2949709828 %
-304:	00001000000000000000000010011011;	% dec 134217883 %
+228:	00000000000101110100100000100001;	% dec 1525793 %
+232:	00000000000010010101000010000000;	% dec 610432 %
+236:	10001111110100000000000000010000;	% dec -1882193904 %
+240:	00000000000000000000000000000000;	% dec 0 %
+244:	00000000000100000101100000100001;	% dec 1071137 %
+248:	00000001010010110101000000100001;	% dec 21712929 %
+252:	00000000000010100110000010000000;	% dec 680064 %
+256:	10001111110100010000000000010100;	% dec -1882128364 %
+260:	00000000000000000000000000000000;	% dec 0 %
+264:	00000011100011000110000000100001;	% dec 59531297 %
+268:	10101101100100010000000000000000;	% dec -1383006208 %
+272:	10001111110100000000000000010000;	% dec -1882193904 %
+276:	00000000000000000000000000000000;	% dec 0 %
+280:	00100110000100000000000000000001;	% dec 638582785 %
+284:	10101111110100000000000000010000;	% dec -1345322992 %
+288:	10001111110100110000000000010000;	% dec -1881997296 %
+292:	00000000000000000000000000000000;	% dec 0 %
+296:	00100100000011100000000000000100;	% dec 604897284 %
+300:	00000010011011100001000000100011;	% dec 40767523 %
+304:	00000100010000001111111111001000;	% dec 71368648 %
 308:	00000000000000000000000000000000;	% dec 0 %
-312:	00100100000100100000000000000000;	% dec 605159424 %
-316:	10101111110100100000000000001000;	% dec 2949775368 %
-320:	00001000000000000000000010010001;	% dec 134217873 %
-324:	00000000000000000000000000000000;	% dec 0 %
-328:	00100100000100110000000000000000;	% dec 605224960 %
-332:	10101111110100110000000000001100;	% dec 2949840908 %
-336:	00001000000000000000000001111000;	% dec 134217848 %
-340:	00000000000000000000000000000000;	% dec 0 %
-344:	10001111110101000000000000000100;	% dec 2413035524 %
+312:	10001111110101000000000000001100;	% dec -1881931764 %
+316:	00000000000000000000000000000000;	% dec 0 %
+320:	00100110100101000000000000000001;	% dec 647233537 %
+324:	10101111110101000000000000001100;	% dec -1345060852 %
+328:	10001111110101100000000000001100;	% dec -1881800692 %
+332:	00000000000000000000000000000000;	% dec 0 %
+336:	00100100000110000000000000000100;	% dec 605552644 %
+340:	00000010110110000001000000100011;	% dec 47714339 %
+344:	00000100010000001111111110111010;	% dec 71368634 %
 348:	00000000000000000000000000000000;	% dec 0 %
-352:	00000000000101000110000000100001;	% dec 1335329 %
-356:	00000000000011000110100001000000;	% dec 813120 %
-360:	10001111110101010000000000001100;	% dec 2413101068 %
-364:	00000000000000000000000000000000;	% dec 0 %
-368:	00000000000101010111000000100001;	% dec 1404961 %
-372:	00000001101011100110100000100001;	% dec 28207137 %
-376:	00000000000011010111100010000000;	% dec 882816 %
-380:	00000011100011110111100000100001;	% dec 59734049 %
-384:	10001101111110000000000000000000;	% dec 2381840384 %
-388:	10001111110101010000000000001100;	% dec 2413101068 %
-392:	00000000000000000000000000000000;	% dec 0 %
-396:	00000000000101010100000000100001;	% dec 1392673 %
-400:	00000000000010000100100001000000;	% dec 542784 %
-404:	10001111110101110000000000001000;	% dec 2413232136 %
-408:	00000000000000000000000000000000;	% dec 0 %
-412:	00000000000101110101000000100001;	% dec 1527841 %
-416:	00000001001010100100100000100001;	% dec 19548193 %
-420:	00000000000010010101100010000000;	% dec 612480 %
-424:	00000011100010110101100000100001;	% dec 59463713 %
-428:	10001101011100000000000000010000;	% dec 2372927504 %
-432:	00000000000000000000000000000000;	% dec 0 %
-436:	00000000000100000110000000100001;	% dec 1073185 %
-440:	00000011000011000111000000011000;	% dec 51146776 %
-444:	00000000000000000111000000010010;	% dec 28690 %
-448:	10001111110100010000000000000000;	% dec 2412838912 %
-452:	00000000000000000000000000000000;	% dec 0 %
-456:	00000010001011101000100000100001;	% dec 36603937 %
-460:	10101111110100010000000000000000;	% dec 2949709824 %
-464:	10001111110100100000000000001100;	% dec 2412904460 %
-468:	00000000000000000000000000000000;	% dec 0 %
-472:	00100110010100100000000000000001;	% dec 642908161 %
-476:	10101111110100100000000000001100;	% dec 2949775372 %
-480:	10001111110100110000000000001100;	% dec 2412969996 %
-484:	00000000000000000000000000000000;	% dec 0 %
-488:	00100100000011110000000000000010;	% dec 604962818 %
-492:	00000010011011110001000000100011;	% dec 40833059 %
-496:	00000100010000001111111111011001;	% dec 71368665 %
-500:	00000000000000000000000000000000;	% dec 0 %
-504:	10001111110101000000000000000100;	% dec 2413035524 %
-508:	00000000000000000000000000000000;	% dec 0 %
-512:	00000000000101000100000000100001;	% dec 1327137 %
-516:	00000000000010000101000001000000;	% dec 544832 %
-520:	10001111110101100000000000001000;	% dec 2413166600 %
+352:	00100111101111010000000000011000;	% dec 666697752 %
+356:	00000000000111011111000000100001;	% dec 1962017 %
+360:	00000011111000000000000000001000;	% dec 65011720 %
+364:	00100111101111011111111111101100;	% dec 666763244 %
+368:	00000000000111011111000000100001;	% dec 1962017 %
+372:	00100100000100000000000000000011;	% dec 605028355 %
+376:	10101111110100000000000000000000;	% dec -1345323008 %
+380:	00100100000100010000000000000011;	% dec 605093891 %
+384:	10101111110100010000000000000100;	% dec -1345257468 %
+388:	00100100000100100000000000000001;	% dec 605159425 %
+392:	10101111110100100000000000001000;	% dec -1345191928 %
+396:	00001000000000000000000011100100;	% dec 134217956 %
+400:	00000000000000000000000000000000;	% dec 0 %
+404:	00100100000100110000000000000001;	% dec 605224961 %
+408:	10101111110100110000000000001100;	% dec -1345126388 %
+412:	00001000000000000000000011011010;	% dec 134217946 %
+416:	00000000000000000000000000000000;	% dec 0 %
+420:	10001111110101000000000000001000;	% dec -1881931768 %
+424:	00000000000000000000000000000000;	% dec 0 %
+428:	00100110100011011111111111111111;	% dec 646840319 %
+432:	00000000000011010111000010000000;	% dec 880768 %
+436:	10001111110101010000000000001100;	% dec -1881866228 %
+440:	00000000000000000000000000000000;	% dec 0 %
+444:	00000000000101010111100000100001;	% dec 1407009 %
+448:	00000001110011110111000000100001;	% dec 30371873 %
+452:	00000000000011101100000010000000;	% dec 966784 %
+456:	00000011100110001100000000100001;	% dec 60342305 %
+460:	10001111000101100000000000000000;	% dec -1894383616 %
+464:	00000000000000000000000000000000;	% dec 0 %
+468:	00000000000101101011100000100001;	% dec 1488929 %
+472:	10101111110101110000000000010000;	% dec -1344864240 %
+476:	10001111110101000000000000001000;	% dec -1881931768 %
+480:	00000000000000000000000000000000;	% dec 0 %
+484:	00000000000101000100000000100001;	% dec 1327137 %
+488:	00000000000010000100100010000000;	% dec 542848 %
+492:	10001111110101010000000000001100;	% dec -1881866228 %
+496:	00000000000000000000000000000000;	% dec 0 %
+500:	00100110101010111111111111111111;	% dec 648806399 %
+504:	00000001001010110100100000100001;	% dec 19613729 %
+508:	00000000000010010110000010000000;	% dec 614528 %
+512:	00000011100011000110000000100001;	% dec 59531297 %
+516:	10001101100011010000000000000000;	% dec -1920139264 %
+520:	10001111110101110000000000010000;	% dec -1881735152 %
 524:	00000000000000000000000000000000;	% dec 0 %
-528:	00000000000101100100100000100001;	% dec 1460257 %
-532:	00000001010010010101000000100001;	% dec 21581857 %
-536:	00000000000010100101100010000000;	% dec 678016 %
-540:	10001111110101010000000000000000;	% dec 2413101056 %
-544:	00000000000000000000000000000000;	% dec 0 %
-548:	00000011100010110101100000100001;	% dec 59463713 %
-552:	10101101011101010000000000100000;	% dec 2910126112 %
-556:	00100100000101010000000000000000;	% dec 605356032 %
-560:	10101111110101010000000000000000;	% dec 2949971968 %
-564:	10001111110100000000000000001000;	% dec 2412773384 %
-568:	00000000000000000000000000000000;	% dec 0 %
-572:	00100110000100000000000000000001;	% dec 638582785 %
-576:	10101111110100000000000000001000;	% dec 2949644296 %
-580:	10001111110100010000000000001000;	% dec 2412838920 %
+528:	00000010111011011011100000100001;	% dec 49133601 %
+532:	10101111110101110000000000010000;	% dec -1344864240 %
+536:	10001111110101000000000000001000;	% dec -1881931768 %
+540:	00000000000000000000000000000000;	% dec 0 %
+544:	00000000000101000111100000100001;	% dec 1341473 %
+548:	00000000000011110111000010000000;	% dec 1011840 %
+552:	10001111110101010000000000001100;	% dec -1881866228 %
+556:	00000000000000000000000000000000;	% dec 0 %
+560:	00100110101010000000000000000001;	% dec 648544257 %
+564:	00000001110010000111000000100001;	% dec 29913121 %
+568:	00000000000011100101000010000000;	% dec 938112 %
+572:	00000011100010100101000000100001;	% dec 59396129 %
+576:	10001101010010110000000000000000;	% dec -1924464640 %
+580:	10001111110101110000000000010000;	% dec -1881735152 %
 584:	00000000000000000000000000000000;	% dec 0 %
-588:	00100100000011100000000000000010;	% dec 604897282 %
-592:	00000010001011100001000000100011;	% dec 36573219 %
-596:	00000100010000001111111110111100;	% dec 71368636 %
+588:	00000010111010111011100000100001;	% dec 49002529 %
+592:	10101111110101110000000000010000;	% dec -1344864240 %
+596:	10001111110101000000000000001000;	% dec -1881931768 %
 600:	00000000000000000000000000000000;	% dec 0 %
-604:	10001111110100100000000000000100;	% dec 2412904452 %
-608:	00000000000000000000000000000000;	% dec 0 %
-612:	00100110010100100000000000000001;	% dec 642908161 %
-616:	10101111110100100000000000000100;	% dec 2949775364 %
-620:	10001111110100110000000000000100;	% dec 2412969988 %
-624:	00000000000000000000000000000000;	% dec 0 %
-628:	00100100000011110000000000000010;	% dec 604962818 %
-632:	00000010011011110001000000100011;	% dec 40833059 %
-636:	00000100010000001111111110101110;	% dec 71368622 %
-640:	00000000000000000000000000000000;	% dec 0 %
-644:	00100111101111010000000000010000;	% dec 666697744 %
-648:	00000000000111011111000000100001;	% dec 1962017 %
-652:	00000011111000000000000000001000;	% dec 65011720 %
+604:	00100110100011000000000000000001;	% dec 646709249 %
+608:	00000000000011000110100010000000;	% dec 813184 %
+612:	10001111110101010000000000001100;	% dec -1881866228 %
+616:	00000000000000000000000000000000;	% dec 0 %
+620:	00000000000101010111100000100001;	% dec 1407009 %
+624:	00000001101011110110100000100001;	% dec 28272673 %
+628:	00000000000011011100000010000000;	% dec 901248 %
+632:	00000011100110001100000000100001;	% dec 60342305 %
+636:	10001111000010000000000000000000;	% dec -1895301120 %
+640:	10001111110101110000000000010000;	% dec -1881735152 %
+644:	00000000000000000000000000000000;	% dec 0 %
+648:	00000010111010001011100000100001;	% dec 48805921 %
+652:	10101111110101110000000000010000;	% dec -1344864240 %
+656:	10001111110101000000000000001000;	% dec -1881931768 %
+660:	00000000000000000000000000000000;	% dec 0 %
+664:	00000000000101000111000000100001;	% dec 1339425 %
+668:	00000000000011100101000010000000;	% dec 938112 %
+672:	10001111110101010000000000001100;	% dec -1881866228 %
+676:	00000000000000000000000000000000;	% dec 0 %
+680:	00000000000101010101100000100001;	% dec 1398817 %
+684:	00000001010010110101000000100001;	% dec 21712929 %
+688:	00000000000010100100100010000000;	% dec 673920 %
+692:	00000011100010010100100000100001;	% dec 59328545 %
+696:	10001101001100110000000000000000;	% dec -1926037504 %
+700:	00000000000000000000000000000000;	% dec 0 %
+704:	00000000000100110110000000100001;	% dec 1269793 %
+708:	00100100000011110000000000000100;	% dec 604962820 %
+712:	00000001100011110110100000011000;	% dec 26175512 %
+716:	00000000000000000110100000010010;	% dec 26642 %
+720:	10001111110101110000000000010000;	% dec -1881735152 %
+724:	00000000000000000000000000000000;	% dec 0 %
+728:	00000010111011011011100000100011;	% dec 49133603 %
+732:	10101111110101110000000000010000;	% dec -1344864240 %
+736:	10001111110101110000000000010000;	% dec -1881735152 %
+740:	00000000000000000000000000000000;	% dec 0 %
+744:	00100100000110000000000011111111;	% dec 605552895 %
+748:	00000010111110000001000000100011;	% dec 49811491 %
+752:	00011000010000000000000000000101;	% dec 406847493 %
+756:	00000000000000000000000000000000;	% dec 0 %
+760:	00100100000101100000000011111111;	% dec 605421823 %
+764:	10101111110101100000000000010000;	% dec -1344929776 %
+768:	00001000000000000000000011001001;	% dec 134217929 %
+772:	00000000000000000000000000000000;	% dec 0 %
+776:	10001111110100000000000000010000;	% dec -1882193904 %
+780:	00000000000000000000000000000000;	% dec 0 %
+784:	00000010000000000001000000100011;	% dec 33558563 %
+788:	00000100010000010000000000000011;	% dec 71368707 %
+792:	00000000000000000000000000000000;	% dec 0 %
+796:	00100100000100010000000000000000;	% dec 605093888 %
+800:	10101111110100010000000000010000;	% dec -1345257456 %
+804:	10001111110100100000000000001000;	% dec -1882062840 %
+808:	00000000000000000000000000000000;	% dec 0 %
+812:	00000000000100100101000000100001;	% dec 1200161 %
+816:	00000000000010100100100010000000;	% dec 673920 %
+820:	10001111110101000000000000001100;	% dec -1881931764 %
+824:	00000000000000000000000000000000;	% dec 0 %
+828:	00000000000101000110000000100001;	% dec 1335329 %
+832:	00000001001011000100100000100001;	% dec 19679265 %
+836:	00000000000010010111100010000000;	% dec 620672 %
+840:	10001111110101010000000000010000;	% dec -1881866224 %
+844:	00000000000000000000000000000000;	% dec 0 %
+848:	00000011100011110111100000100001;	% dec 59734049 %
+852:	10101101111101010000000001000000;	% dec -1376452544 %
+856:	10001111110101000000000000001100;	% dec -1881931764 %
+860:	00000000000000000000000000000000;	% dec 0 %
+864:	00100110100101000000000000000001;	% dec 647233537 %
+868:	10101111110101000000000000001100;	% dec -1345060852 %
+872:	10001111110101110000000000001100;	% dec -1881735156 %
+876:	10001111110101100000000000000100;	% dec -1881800700 %
+880:	00000000000000000000000000000000;	% dec 0 %
+884:	00000010111101100001000000100011;	% dec 49680419 %
+888:	00000100010000001111111110001010;	% dec 71368586 %
+892:	00000000000000000000000000000000;	% dec 0 %
+896:	10001111110100000000000000001000;	% dec -1882193912 %
+900:	00000000000000000000000000000000;	% dec 0 %
+904:	00100110000100000000000000000001;	% dec 638582785 %
+908:	10101111110100000000000000001000;	% dec -1345323000 %
+912:	10001111110100010000000000001000;	% dec -1882128376 %
+916:	10001111110100100000000000000000;	% dec -1882062848 %
+920:	00000000000000000000000000000000;	% dec 0 %
+924:	00000010001100100001000000100011;	% dec 36835363 %
+928:	00000100010000001111111101111100;	% dec 71368572 %
+932:	00000000000000000000000000000000;	% dec 0 %
+936:	00100111101111010000000000010100;	% dec 666697748 %
+940:	00000000000111011111000000100001;	% dec 1962017 %
+944:	00000011111000000000000000001000;	% dec 65011720 %
 END;

+ 2 - 2
nbproject/private/private.properties

@@ -1,7 +1,7 @@
 compile.on.save=true
 do.depend=false
 do.jar=true
-file.reference.antlr-4.7-complete.jar=C:\\Users\\lucas\\ivanosys\\ivannosys3\\antlr-4.7-complete.jar
+file.reference.antlr-4.7-complete.jar=C:\\Users\\EUGENIO CARVALHO\\Desktop\\projects\\Ivannosys\\antlr-4.7-complete.jar
 javac.debug=true
 javadoc.preview=true
-user.properties.file=C:\\Users\\lucas\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
+user.properties.file=C:\\Users\\EUGENIO CARVALHO\\AppData\\Roaming\\NetBeans\\8.2\\build.properties

+ 12 - 14
src/API/Api.java

@@ -48,28 +48,26 @@ public class Api {
         Middleware.Add("mips.o.L1", new targets.mips.MipsOtimizationMiddleware());
         Middleware.Add("mips.update.address", new targets.mips.MipsUpdateAddressMiddleware());
 
-        Middleware.Add("print.data", (c, cp) -> {
-
-            System.out.println("@@@@@@DATA_LAYOUT:\n\n"
-                    + c.Block().GlobalContext()
-                    + c.Block().Context().toString());
-
-        });
-
-        Middleware.On("IR", "close.block", "print.data");
-
+//        Middleware.Add("print.data", (c, cp) -> {
+//
+//            System.out.println("@@@@@@DATA_LAYOUT:\n\n"
+//                    + c.Block().GlobalContext()
+//                    + c.Block().Context().toString());
+//
+//        });
+//        Middleware.On("IR", "close.block", "print.data");
         String middlelist = Utils.Join(new String[]{
             // Remove labels não referenciadas
-            //            "ir.clear.labels",
+            "ir.clear.labels",
             // Remove copias
             "ir.o.copies",
             // Propagacao de constantes
             //                + "ir.o.VariablesConstants,"
             // Remove instruções que não tem impacto algum na execusao
             //                + "ir.o.DeadInstructions,"
-            // Extrai os blocos basicos de uma subrotina
-            "ir.basic.blocks", // Remove loads e stores desnecessarios
-        //                + "ir.o.load_store"
+            "ir.basic.blocks", // Extrai os blocos basicos de uma subrotina
+//            "ir.o.load_store", // Remove loads e stores desnecessarios
+//            "ir.basic.blocks", // Extrai os blsocos basicos de uma subrotina
         }, ",");
 
         // Define os processadores padrão da IR

+ 1 - 1
src/API/TargetGen.java

@@ -123,7 +123,7 @@ public abstract class TargetGen implements IvannosysTargetArch {
         return this;
     }
 
-    protected Instruction Add(Instruction inst) {
+    protected Instruction Add(Instruction inst) throws Exception {
         if (currentIrInstruction != null) {
             inst.Set("tac.position", currentIrInstruction.Get("block.position"));
         }

+ 20 - 20
src/Export/MemoryInitializationFile.java

@@ -21,11 +21,11 @@ import tools.mips.MemoryImportExportInterface;
  * @author Eugenio
  */
 public class MemoryInitializationFile implements MemoryImportExportInterface {
-
+    
     public MemoryInitializationFile() {
-
+        
     }
-
+    
     @Override
     public void FromFile(Memory memory) throws Exception {
         String value;
@@ -39,7 +39,7 @@ public class MemoryInitializationFile implements MemoryImportExportInterface {
         } catch (FileNotFoundException e) {
             throw new Exception(String.format("O arquivo da memoria não foi encontrado. %s", memory.File()));
         }
-
+        
         while (sc.hasNextLine()) {
             value = sc.nextLine();
             if (value.equals("")) {
@@ -60,26 +60,26 @@ public class MemoryInitializationFile implements MemoryImportExportInterface {
             }
             // trata e escreve o valor na memória
             parts = value.replaceAll("\\s+", "").split(":");
-            memory.W(Long.parseLong(parts[0], 10), parts[1], 4);
+            memory.W(Long.parseLong(parts[0], 10), parts[1].split(";")[0], 4);
         }
     }
-
+    
     @Override
     public String DumpFile(Memory memory) throws Exception {
-
+        
         String out = Header(memory);
-
+        
         Long address, base = 0L;
         ArrayList<String> buffer = new ArrayList<>();
         TreeMap<Long, String> data = memory.Data();
         Integer pad = data.lastKey().toString().length();
-
+        
         for (Map.Entry<Long, String> o : data.entrySet()) {
             address = o.getKey();
-
+            
             if (address % memory.WORD_BYTES_COUNT == 0) {
                 out += Append(base, buffer, pad);
-
+                
                 if ((address - base) > memory.WORD_BYTES_COUNT) {
                     out += String.format(
                             "[%d..%d]:\t00000000000000000000000000000000;\n",
@@ -91,16 +91,16 @@ public class MemoryInitializationFile implements MemoryImportExportInterface {
                 buffer = new ArrayList<>();
             }
             buffer.add(o.getValue());
-
+            
         }
-
+        
         out += Append(base, buffer, pad);
-
+        
         out += Footer(memory);
-
+        
         return out;
     }
-
+    
     protected static String Append(Long base, ArrayList<String> buffer, Integer pad) {
         String out = "", bin;
         if (!buffer.isEmpty()) {
@@ -109,12 +109,12 @@ public class MemoryInitializationFile implements MemoryImportExportInterface {
                     + ":\t"
                     + bin
                     + ";\t% dec "
-                    + Long.parseLong(bin, 2)
+                    + Long.parseUnsignedLong(Utils.padPreserveSignal(64, bin), 2)
                     + " %\n";
         }
         return out;
     }
-
+    
     protected static String Header(Memory m) {
         return "-- Copyright (C) 1991-2014 Altera Corporation. All rights reserved.\n"
                 .concat("-- Your use of Altera Corporation's design tools, logic functions\n")
@@ -139,7 +139,7 @@ public class MemoryInitializationFile implements MemoryImportExportInterface {
                 .concat("DATA_RADIX = BIN;\n\n")
                 .concat("CONTENT\nBEGIN\n");
     }
-
+    
     protected static String Footer(Memory m) {
 //        String inst = Utils.Pad(wordSize, "");
 //
@@ -147,5 +147,5 @@ public class MemoryInitializationFile implements MemoryImportExportInterface {
 //                + ".." + seHex(size - 1, 0) + "]\t:\t" + seHex(inst, 8) + ";");
         return "END;";
     }
-
+    
 }

+ 1 - 2
src/Export/MultCoreJun.java

@@ -216,7 +216,6 @@ public class MultCoreJun implements ExportInterface {
 
     protected Long MaxStackSize(Block blk) {
         HashMap<String, Block> tb = target.Blocks();
-        int size = blk.Context().Size();
 //        System.out.println("data:" + blk.Context());
         Long childSize = 0L, tmpChildSize;
 
@@ -230,6 +229,6 @@ public class MultCoreJun implements ExportInterface {
             }
         }
 //        System.out.println("MaxStackSize:" + size + "|" + childSize);
-        return size + childSize;
+        return blk.Context().Size() + childSize;
     }
 }

+ 0 - 142
src/Export/Simulation.java

@@ -29,8 +29,6 @@ public class Simulation implements ExportInterface {
 
     @Override
     public void Exec(Code IR, Code Target) throws Exception {
-//        Integer index;
-//        System.out.println(Target.GlobalContext());
         String bin;
 
         Memory memory = new Memory(
@@ -64,143 +62,3 @@ public class Simulation implements ExportInterface {
     }
 
 }
-/**
- 		<laplaciano>:
-16c:  0666763244	addiu sp,sp,-20		 -- prolog| push stack frame
-170:  0001962017	addu fp,zero,sp		 -- prolog|copy fp ← sp
-174:  0605028355	addiu s0,zero,3		.0 -- copy _V20 ← 3
-178:  2949644288	sw s0,fp,0		.1 -- store content of s0 in _V20
-17c:  0605093891	addiu s1,zero,3		.2 -- copy _V22 ← 3
-180:  2949709828	sw s1,fp,4		.3 -- store content of s1 in _V22
-184:  0605159425	addiu s2,zero,1		.4 -- copy _V23 ← 1
-188:  2949775368	sw s2,fp,8		.5 -- store content of s2 in _V23
-18c:  0134217947	j 36c <laplaciano+0x200>		.6 -- jump to laplaciano+_i20
-190:  0000000000	sll zero,zero,0		.6 -- Nop
-194:  0605224961	addiu s3,zero,1		.7 -- copy _V24 ← 1
-198:  2949840908	sw s3,fp,12		.8 -- store content of s3 in _V24
-19c:  0134217937	j 344 <laplaciano+0x1d8>		.9 -- jump to laplaciano+_i24
-1a0:  0000000000	sll zero,zero,0		.9 -- Nop
-1a4:  2413035528	lw s4,fp,8		.10 -- load content from _V23 in s4
-1a8:  0000000000	sll zero,zero,0		.10 -- Nop
-1ac:  0646840319	addiu t5,s4,-1		.11 -- _T26 = _V23 - 1
-1b0:  0000880768	sll t6,t5,2		.12 -- _T27 = _T26 << 2
-1b4:  2413101068	lw s5,fp,12		.13 -- load content from _V24 in s5
-1b8:  0000000000	sll zero,zero,0		.13 -- Nop
-1bc:  0001407009	addu t7,zero,s5		.14 -- copy _T29 ← _V24
-1c0:  0030371873	addu t6,t6,t7		.15 -- _T27 = _T27 + _T29
-1c4:  0000966784	sll t8,t6,2		.16 -- _T33 = _T27 << 2
-1c8:  0060342305	addu t8,gp,t8		.17
-1cc:  2400583680	lw s6,t8,0		.17
-1d0:  0000000000	sll zero,zero,0		.17 -- Nop
-1d4:  0001488929	addu s7,zero,s6		.17 -- copy s7 ← s6
-1d8:  2950103056	sw s7,fp,16		.18 -- store content of s7 in _V36
-1dc:  2413035528	lw s4,fp,8		.19 -- load content from _V23 in s4
-1e0:  0000000000	sll zero,zero,0		.19 -- Nop
-1e4:  0001327137	addu t0,zero,s4		.20 -- copy _T37 ← _V23
-1e8:  0000542848	sll t1,t0,2		.21 -- _T38 = _T37 << 2
-1ec:  2413101068	lw s5,fp,12		.22 -- load content from _V24 in s5
-1f0:  0000000000	sll zero,zero,0		.22 -- Nop
-1f4:  0648806399	addiu t3,s5,-1		.23 -- _T41 = _V24 - 1
-1f8:  0019613729	addu t1,t1,t3		.24 -- _T38 = _T38 + _T41
-1fc:  0000614528	sll t4,t1,2		.25 -- _T45 = _T38 << 2
-200:  0059531297	addu t4,gp,t4		.26
-204:  2374828032	lw t5,t4,0		.26
-208:  2413232144	lw s7,fp,16		.27 -- load content from _V36 in s7
-20c:  0000000000	sll zero,zero,0		.27 -- Nop
-210:  0049133601	addu s7,s7,t5		.28 -- _V36 = _V36 + _T47
-214:  2950103056	sw s7,fp,16		.29 -- store content of s7 in _V36
-218:  2413035528	lw s4,fp,8		.30 -- load content from _V23 in s4
-21c:  0000000000	sll zero,zero,0		.30 -- Nop
-220:  0001341473	addu t7,zero,s4		.31 -- copy _T48 ← _V23
-224:  0001011840	sll t6,t7,2		.32 -- _T49 = _T48 << 2
-228:  2413101068	lw s5,fp,12		.33 -- load content from _V24 in s5
-22c:  0000000000	sll zero,zero,0		.33 -- Nop
-230:  0648544257	addiu t0,s5,1		.34 -- _T52 = _V24 + 1
-234:  0029913121	addu t6,t6,t0		.35 -- _T49 = _T49 + _T52
-238:  0000938112	sll t2,t6,2		.36 -- _T56 = _T49 << 2
-23c:  0059396129	addu t2,gp,t2		.37
-240:  2370502656	lw t3,t2,0		.37
-244:  2413232144	lw s7,fp,16		.38 -- load content from _V36 in s7
-248:  0000000000	sll zero,zero,0		.38 -- Nop
-24c:  0049002529	addu s7,s7,t3		.39 -- _V36 = _V36 + _T58
-250:  2950103056	sw s7,fp,16		.40 -- store content of s7 in _V36
-254:  2413035528	lw s4,fp,8		.41 -- load content from _V23 in s4
-258:  0000000000	sll zero,zero,0		.41 -- Nop
-25c:  0646709249	addiu t4,s4,1		.42 -- _T60 = _V23 + 1
-260:  0000813184	sll t5,t4,2		.43 -- _T61 = _T60 << 2
-264:  2413101068	lw s5,fp,12		.44 -- load content from _V24 in s5
-268:  0000000000	sll zero,zero,0		.44 -- Nop
-26c:  0001407009	addu t7,zero,s5		.45 -- copy _T63 ← _V24
-270:  0028272673	addu t5,t5,t7		.46 -- _T61 = _T61 + _T63
-274:  0000901248	sll t8,t5,2		.47 -- _T67 = _T61 << 2
-278:  0060342305	addu t8,gp,t8		.48
-27c:  2399666176	lw t0,t8,0		.48
-280:  2413232144	lw s7,fp,16		.49 -- load content from _V36 in s7
-284:  0000000000	sll zero,zero,0		.49 -- Nop
-288:  0048805921	addu s7,s7,t0		.50 -- _V36 = _V36 + _T69
-28c:  2950103056	sw s7,fp,16		.51 -- store content of s7 in _V36
-290:  2413035528	lw s4,fp,8		.52 -- load content from _V23 in s4
-294:  0000000000	sll zero,zero,0		.52 -- Nop
-298:  0001339425	addu t6,zero,s4		.53 -- copy _T70 ← _V23
-29c:  0000938112	sll t2,t6,2		.54 -- _T71 = _T70 << 2
-2a0:  2413101068	lw s5,fp,12		.55 -- load content from _V24 in s5
-2a4:  0000000000	sll zero,zero,0		.55 -- Nop
-2a8:  0001398817	addu t3,zero,s5		.56 -- copy _T73 ← _V24
-2ac:  0021712929	addu t2,t2,t3		.57 -- _T71 = _T71 + _T73
-2b0:  0000673920	sll t1,t2,2		.58 -- _T77 = _T71 << 2
-2b4:  0059328545	addu t1,gp,t1		.59
-2b8:  2368929792	lw s3,t1,0		.59
-2bc:  0000000000	sll zero,zero,0		.59 -- Nop
-2c0:  0001269793	addu t4,zero,s3		.59 -- copy t4 ← s3
-2c4:  0604962820	addiu t7,zero,4		.60
-2c8:  0026175512	mult t4,t7		.60 -- _T80 = _T79 * 4
-2cc:  0000026642	mflo t5		.60
-2d0:  2413232144	lw s7,fp,16		.61 -- load content from _V36 in s7
-2d4:  0000000000	sll zero,zero,0		.61 -- Nop
-2d8:  0049133603	subu s7,s7,t5		.62 -- _V36 = _V36 - _T80
-2dc:  2950103056	sw s7,fp,16		.63 -- store content of s7 in _V36
-2e0:  2413232144	lw s7,fp,16		.64 -- load content from _V36 in s7
-2e4:  0000000000	sll zero,zero,0		.64 -- Nop
-2e8:  0605552895	addiu t8,zero,255		.65
-2ec:  0049811491	subu v0,s7,t8		.65
-2f0:  0406847491	blez v0,300 <laplaciano+0x194>		.65 -- branch if register <= 0
-2f4:  0000000000	sll zero,zero,0		.65 -- Nop
-2f8:  0605421823	addiu s6,zero,255		.66 -- copy _V36 ← 255
-2fc:  2950037520	sw s6,fp,16		.67 -- store content of s6 in _V36
-300:  2412773384	lw s0,fp,8		.68 -- load content from _V23 in s0
-304:  0000000000	sll zero,zero,0		.68 -- Nop
-308:  0001077281	addu t6,zero,s0		.69 -- copy _T81 ← _V23
-30c:  0000940160	sll t3,t6,2		.70 -- _T82 = _T81 << 2
-310:  2412838924	lw s1,fp,12		.71 -- load content from _V24 in s1
-314:  0000000000	sll zero,zero,0		.71 -- Nop
-318:  0001134625	addu t2,zero,s1		.72 -- copy _T84 ← _V24
-31c:  0023746593	addu t3,t3,t2		.73 -- _T82 = _T82 + _T84
-320:  0000739456	sll t1,t3,2		.74 -- _T88 = _T82 << 2
-324:  2412904464	lw s2,fp,16		.75 -- load content from _V36 in s2
-328:  0000000000	sll zero,zero,0		.75 -- Nop
-32c:  0059328545	addu t1,gp,t1		.76
-330:  2905735232	sw s2,t1,64		.76 -- store content of t1 in _G90[_T88]
-334:  2413101068	lw s5,fp,12		.77 -- load content from _V24 in s5
-338:  0000000000	sll zero,zero,0		.77 -- Nop
-33c:  0649396225	addiu s5,s5,1		.78 -- _V24 = _V24 + 1
-340:  2949971980	sw s5,fp,12		.79 -- store content of s5 in _V24
-344:  2412969996	lw s3,fp,12		.80 -- load content from _V24 in s3
-348:  2413232132	lw s7,fp,4		.81 -- load content from _V22 in s7
-34c:  0000000000	sll zero,zero,0		.81 -- Nop
-350:  0041357347	subu v0,s3,s7		.82
-354:  0071368595	bltz v0,1a4 <laplaciano+0x38>		.82 -- branch if register < 0
-358:  0000000000	sll zero,zero,0		.82 -- Nop
-35c:  2413166600	lw s6,fp,8		.83 -- load content from _V23 in s6
-360:  0000000000	sll zero,zero,0		.83 -- Nop
-364:  0651558913	addiu s6,s6,1		.84 -- _V23 = _V23 + 1
-368:  2950037512	sw s6,fp,8		.85 -- store content of s6 in _V23
-36c:  2412773384	lw s0,fp,8		.86 -- load content from _V23 in s0
-370:  2412838912	lw s1,fp,0		.87 -- load content from _V20 in s1
-374:  0000000000	sll zero,zero,0		.87 -- Nop
-378:  0034672675	subu v0,s0,s1		.88
-37c:  0071368581	bltz v0,194 <laplaciano+0x28>		.88 -- branch if register < 0
-380:  0000000000	sll zero,zero,0		.88 -- Nop
-384:  0666697748	addiu sp,sp,20		 -- epilog| pop stack frame
-388:  0001962017	addu fp,zero,sp		 -- epilog| pop stack frame
-38c:  0065011720	jr ra		 -- epilog| return
- */

File diff suppressed because it is too large
+ 264 - 249
src/IntermediaryCode/IRGenerator.java


+ 1 - 0
src/IntermediaryCode/IRTemplate.java

@@ -35,6 +35,7 @@ public class IRTemplate implements templates.TemplateDescription {
                 put("assign", base + "{[dst]}' := '{[p1]' '}{[op]' '}{[p2]}" + end);
                 put("pointer_assign", base + "{[dst.pointer]}{[dst]' := '}{[op]' '}{[p1]}" + end);
                 put("unary", base + " {[dst]} ' := '{[op]' '}{[p1]}" + end);
+//                put("copy", base + "{'('[dst.type]')'} {[dst]} ' := '{[p1]}" + end);
                 put("copy", base + " {[dst]} ' := '{[p1]}" + end);
                 put("memory", base + " {[type]' '}{[TYPE('p1')]' '}{[p1]}" + end);
                 put("jump", base + " 'goto ' {'<'[label]'>'}" + end);

+ 2 - 2
src/common/DataLayout.java

@@ -40,7 +40,7 @@ public class DataLayout {
 //    protected DataLayout global = null;
     // Guarda a quantidade de palavras do frame
     // É atualizado sempre que o mapeamento dos endereços sofre alteração.
-    protected int FrameSize = 0;
+    protected Long FrameSize = 0L;
     protected Long FP = 0L;
 
     public DataLayout(String ID) {
@@ -51,7 +51,7 @@ public class DataLayout {
         initialized = init;
     }
 
-    public int Size() {
+    public Long Size() {
         return FrameSize;
     }
 

+ 6 - 1
src/common/Instruction.java

@@ -5,8 +5,8 @@
  */
 package common;
 
-import java.util.ArrayList;
 import java.util.Map;
+import java.util.regex.Pattern;
 
 /**
  *
@@ -127,5 +127,10 @@ public class Instruction extends RegistroBase {
         return rb;
     }
 
+    protected static Pattern NUMBER_EXPR = Pattern.compile("-?\\d+(\\.\\d+)?");
+
+    public boolean IsValue(String attr) {
+        return NUMBER_EXPR.matcher(Get(attr)).matches();
+    }
 
 }

+ 14 - 8
src/compiler/IVANNOSYS.java

@@ -41,8 +41,8 @@ public class IVANNOSYS {
                 case "create":
                     break;
                 default:
-                    Middleware.Add("mips.analise", new analise.AnaliseDependenciaMiddleware());
-                    Middleware.Add("mips.module.scheduling", new analise.ModuleSchedulingMiddleware());
+//                    Middleware.Add("mips.analise", new analise.AnaliseDependenciaMiddleware());
+//                    Middleware.Add("mips.module.scheduling", new analise.ModuleSchedulingMiddleware());
 
                     COM = new IvannosysCompiler(
                             "UTF-8",
@@ -70,13 +70,16 @@ public class IVANNOSYS {
                     Mips.AddExportOption("simulation", new Simulation(new tools.mips.MipsSettings() {
                         {
                             // Não executar passo a passo
-                            Set("step.by.step", "true");
+                            Set("step.by.step", "false");
                             // Necessario para poder usar os breakpoints
-                            Set("mode", "debug");
+//                            Set("mode", "debug");
                             // Determina os pontos de para no codigo alvo
 //                            Set("breakpoints", "94-9c");
 //                            Set("breakpoints", "1d8,214,2e0,28c,2f0,250,330");
-//                            Set("breakpoints", "1d8,214,250,2e0,28c,2dc,2d8,2f0,330");
+//                            Set("breakpoints", "1d8,214,250,28c,2dc,2e0,2d8,2f0,300,314,324,350,35c");
+//                            Set("breakpoints", "2e8-350,35c");
+//                            Set("breakpoints", "314,35c");
+//                            Set("breakpoints", "350,35c");
                             // Caminho do arquivo de memoria de instrucoes
                             Set("memory.instruction", "\\src\\tools\\mips\\memory\\mi.memory");
                             // Tamanho da memorua de instrucoes 16 kb
@@ -85,6 +88,7 @@ public class IVANNOSYS {
                             Set("memory.data", "\\src\\tools\\mips\\memory\\md.memory");
                             // Tamanho da memorua de dados 16 kb
                             Set("memory.data.size", 16 * 1024);
+                            Set("memory.data.reset", "true");
                         }
                     }));
 
@@ -99,14 +103,16 @@ public class IVANNOSYS {
                     Middleware.On("mips", "after.translate.block", "mips.o.L1,mips.copy.dep");
                     // Atualiza os enderecos de saltos e set no campo offset
 //                    Middleware.On("mips", "after.translate", "mips.update.address,mips.analise,mips.module.scheduling");
-                    Middleware.On("mips", "after.translate", "mips.update.address,mips.module.scheduling");
+//                    Middleware.On("mips", "after.translate", "mips.update.address,mips.module.scheduling");
+                    Middleware.On("mips", "after.translate", "mips.update.address");
 
                     // file = "src\\samples\\program.go";
                     // file = "src\\samples\\program.go";
                     // file = "src\\samples\\program_mult_jon.go";
-                    file = "src\\samples\\program_mult.go";
+//                    file = "src\\samples\\program_mult.go";
 //                    file = "src\\samples\\program_jun_bit_count.go";
-//                    file = "src\\samples\\program_jun_laplaciano.go";
+                    file = "src\\samples\\program_jun_laplaciano.go";
+//                    file = "src\\samples\\program_jun_bytes.go";
 //                    file = "src\\samples\\program_jun_mult_manycore.go";
 
                     // Compila o arquivo de entrada

+ 14 - 12
src/middlewares/LoadStoreMiddleware.java

@@ -5,6 +5,7 @@
  */
 package middlewares;
 
+import API.MiddlewareInterface;
 import common.Block;
 import common.Code;
 import common.Instruction;
@@ -12,7 +13,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
-import API.MiddlewareInterface;
 
 /**
  *
@@ -30,7 +30,7 @@ public class LoadStoreMiddleware implements MiddlewareInterface {
     @Override
     public void Exec(Code c, LinkedHashMap<String, MiddlewareInterface> cp) throws Exception {
         this.basicBlocks = (BasicBlockMiddleware) cp.get("ir.basic.blocks");
-        
+
         BlockBaseOcorrences g;
         Integer leader, limit, lposition;
         Block block = c.Block();
@@ -53,7 +53,7 @@ public class LoadStoreMiddleware implements MiddlewareInterface {
             if (g == null) {
                 break;
             }
-            System.out.println("------------------------------>:" + g);
+            System.out.println("------------------------------>:");
 
             // Corrige o endereco inicial do leader caso alguma instrucao tenha sido removida
             leader = g.getLeader() - fix;
@@ -90,15 +90,17 @@ public class LoadStoreMiddleware implements MiddlewareInterface {
                 // * A instrucao é um store
                 // * O endereco carregado é uma variavel da pilha
                 // Variaveis globais sempre são gravadas
-                if (IS.eq("type", "store") && varS.contains("_V")) {
-//                    System.out.println("Looad:" + instruction);
-                    if (stored.containsKey(varS)) {
-                        remove.add(IS);
-                        fix++;
-                    } else {
-                        stored.put(varS, Boolean.TRUE);
-                    }
-                }
+//                if (IS.eq("type", "store") && varS.contains("_V")) {
+//                    if (varS.equals("_V8")) {
+//                        System.out.println("Looad:" + IS + " > " + stored.containsKey(varS));
+//                    }
+//                    if (stored.containsKey(varS)) {
+//                        remove.add(IS);
+//                        fix++;
+//                    } else {
+//                        stored.put(varS, Boolean.TRUE);
+//                    }
+//                }
             }
             // Corrige o endereco final do bloco caso alguma instrucao tenha sido removida
             g.setLeader(leader);

+ 28 - 24
src/middlewares/RemoveUnusedLabelsMiddleware.java

@@ -6,7 +6,6 @@
 package middlewares;
 
 import API.MiddlewareInterface;
-import API.Utils;
 import common.Block;
 import common.Code;
 import common.Instruction;
@@ -48,7 +47,7 @@ public class RemoveUnusedLabelsMiddleware implements MiddlewareInterface {
 //        System.out.println("\n\n####referenceCount:" + referenceCount + "\n\n");
         // Salta o primeiro label
         if (interator.hasNext()) {
-            interator.next();
+            last = interator.next();
         }
         // Remove todos os labels não referenciados
         while (interator.hasNext()) {
@@ -56,27 +55,26 @@ public class RemoveUnusedLabelsMiddleware implements MiddlewareInterface {
             last = instruction;
             instruction = interator.next();
 
-            if (instruction.eq("type", "branch")) {
-                branch = instruction;
-//                position = 0;
-            }
-
-            // Quando salta um jump altera o enredeco para o endereco do jump e inverte o teste
-            if (branch != null && last.eq("type", "jump")) {
-                if (instruction.eq("label", branch.Get("label"))) {
-                    //                position == 3 &&
-
-                    branch.Set("op", Utils.ComplementOperation(branch.Get("op")))
-                            .Set("label", last.Get("label"));
-                    branch = null;
-
-                    remover.add(last);
-                    remover.add(instruction);
-
-                    continue;
-                }
-            }
-
+            //            if (instruction.eq("type", "branch")) {
+            //                branch = instruction;
+            ////                position = 0;
+            //            }
+            //
+            //            // Quando salta um jump altera o enredeco para o endereco do jump e inverte o teste
+            //            if (branch != null && last.eq("type", "jump")) {
+            //                if (instruction.eq("label", branch.Get("label"))) {
+            //                    //                position == 3 &&
+            //
+            //                    branch.Set("op", Utils.ComplementOperation(branch.Get("op")))
+            //                            .Set("label", last.Get("label"));
+            //                    branch = null;
+            //
+            //                    remover.add(last);
+            //                    remover.add(instruction);
+            //
+            //                    continue;
+            //                }
+            //            }
             if (!instruction.eq("type", "label") || instruction.in("label_type", ignore)) {
                 continue;
                 // Unifica labels sequenciais e atualiza as chamadas dos outros labels
@@ -84,6 +82,13 @@ public class RemoveUnusedLabelsMiddleware implements MiddlewareInterface {
 
             // A instrucão é um label
             label = instruction.Get("label");
+
+//            System.out.println("Last:(label:" + label + ")" + last);
+
+            if (last != null && last.eq("label", instruction.Get("label"))) {
+                remover.add(last);
+            }
+
             // Se o label não existe ou não foi referenciado remove
             if (!referenceCount.containsKey(label) || referenceCount.get(label) == 0) {
 //                System.out.println("Removendo o label " + label);
@@ -91,7 +96,6 @@ public class RemoveUnusedLabelsMiddleware implements MiddlewareInterface {
             }
         }
 
-        Instruction r;
         // Remove as instruções sinalizadas
         while (!remover.isEmpty()) {
             block.Remove(remover.remove(0));

+ 295 - 0
src/samples/program_jun_bytes.go

@@ -0,0 +1,295 @@
+// Aplica o back-end do juninho
+@target          : mips 
+// Especifica o tipo de metodo empregado para salvar o resultado da compilação
+@export          : simulation //MultCoreJun
+
+// Diretorio onde o resultado da compilação será gravado
+@outputDirectory : `C:\Users\EUGENIO CARVALHO\Desktop\tmp\bytes`
+
+// Quantidade de palavras de um bloco 32 palavras de 4bytes
+@cacheBlockSize: `32`
+/**
+    Profile de compilacao do back-end
+    O formato da string é um json que descreve um array de definições de cada core
+    {
+        "stackBaseAddress"   : 5888,     -> endereço da base da pilha do core em questão
+        "initFunction": "multiplica(0)", -> define a main de cada core. aceita ate 4 parametros com valores de constantes
+        "id": "core0"                    -> label que define o codigo de cada core
+    },
+
+    Se "stackBaseAddress" não for definido o compilador irá inferir o valor iniciando do ultimo endereço da memoria    
+*/
+
+@profile: `[
+    {
+        "id"               : "core0",
+        "initFunction"     : "multiplica(0)",
+        "filename"         : "%s_core_0.txt"
+    },
+    {
+        "id"               : "core1",
+        "initFunction"     : "multiplica(5)",
+        "filename"         : "%s_core_1.txt"
+    },
+    {
+        "id"               : "core2",
+        "initFunction"     : "multiplica(10)",
+        "filename"         : "%s_core_2.txt"
+    },
+    {
+        "id"               : "core3",
+        "initFunction"     : "multiplica(15)",
+        "filename"         : "%s_core_3.txt"
+    }
+]`
+
+
+package main;
+
+const (
+    LIN = 4
+)
+
+var (
+    origin [LIN]byte
+)
+
+func main() {
+    for i:=0; i < LIN ; i++  {
+        origin[i] = i
+    }
+}
+
+/**
+main.@preenche_matriz.main.@preenche_matriz.value : _V8
+main.@preenche_matriz.@for_0.main.@preenche_matriz.@for_0.i : _V6
+main.@preenche_matriz.@for_0.@for_1.COL : 4
+main.@preenche_matriz.main.@preenche_matriz.LM1 : _V3
+main.@preenche_matriz.@for_0.@for_1.LM1 : _V3
+main.main.result : _G90
+main.@preenche_matriz.w : _V1
+main.@preenche_matriz.@for_0.@for_1.main.@preenche_matriz.@for_0.@for_1.j : _V7
+main.@preenche_matriz.@for_0.@for_1.CM1 : _V5
+main.@preenche_matriz.@for_0.@for_1.value : _V8
+main.@preenche_matriz.@for_0.LIN : 4
+_V1 : main.@preenche_matriz.w
+_V3 : main.@preenche_matriz.LM1
+_V6 : main.@preenche_matriz.@for_0.i
+_V5 : main.@preenche_matriz.CM1
+main.@preenche_matriz.@for_0.i : _V6
+_V8 : main.@preenche_matriz.@for_0.@for_1.value
+_V7 : main.@preenche_matriz.@for_0.@for_1.j
+_G18 : main.main.origin
+main.@preenche_matriz.@for_0.@for_1.i : _V6
+main.@preenche_matriz.CM1 : _V5
+main.@preenche_matriz.LIN : 4
+main.@preenche_matriz.main.@preenche_matriz.CM1 : _V5
+main.@preenche_matriz.COL : 4
+main.@preenche_matriz.main.@preenche_matriz.w : _V1
+main.@preenche_matriz.@for_0.@for_1.origin : _G18
+main.main.origin : _G18
+_G90 : main.main.result
+main.@preenche_matriz.@for_0.@for_1.w : _V1
+main.@preenche_matriz.LM1 : _V3
+main.@preenche_matriz.@for_0.@for_1.j : _V7
+
+
+
+4 : main.@laplaciano.LIN
+main.@laplaciano.LIN : 4
+
+main.@laplaciano.COL : 4
+
+_V22 : main.@laplaciano.CM1
+main.@laplaciano.CM1 : _V22
+main.@laplaciano.main.@laplaciano.CM1 : _V22
+main.@laplaciano.@for_3.@for_4.CM1 : _V22
+
+_V20 : main.@laplaciano.LM1
+main.@laplaciano.LM1 : _V20
+main.@laplaciano.@for_3.LM1 : _V20
+main.@laplaciano.main.@laplaciano.LM1 : _V20
+
+main.@laplaciano.@for_3.i : _V23
+_V23 : main.@laplaciano.@for_3.i
+main.@laplaciano.@for_3.@for_4.i : _V23
+main.@laplaciano.@for_3.main.@laplaciano.@for_3.i : _V23
+
+main.@laplaciano.main.@laplaciano.l : _V36
+main.@laplaciano.@for_3.@for_4.l : _V36
+_V36 : main.@laplaciano.@for_3.@for_4.l
+
+_V24 : main.@laplaciano.@for_3.@for_4.j
+main.@laplaciano.@for_3.@for_4.j : _V24
+main.@laplaciano.@for_3.@for_4.main.@laplaciano.@for_3.@for_4.j : _V24
+
+main.@laplaciano.@for_3.@for_4.origin : _G18
+main.@laplaciano.@for_3.@for_4.result : _G90
+
+		<laplaciano>:
+16c:  0666763244	addiu sp,sp,-20		 -- prolog| push stack frame
+170:  0001962017	addu fp,zero,sp		 -- prolog|copy fp ← sp
+174:  0605028355	addiu s0,zero,3		.0 -- copy _V20 ← 3
+178:  2949644288	sw s0,fp,0		.1 -- store content of s0 in _V20
+17c:  0605093891	addiu s1,zero,3		.2 -- copy _V22 ← 3
+180:  2949709828	sw s1,fp,4		.3 -- store content of s1 in _V22
+184:  0605159425	addiu s2,zero,1		.4 -- copy _V23 ← 1
+188:  2949775368	sw s2,fp,8		.5 -- store content of s2 in _V23
+18c:  0134217958	j 398 <laplaciano+0x22c>		.6 -- jump to laplaciano+_i20
+190:  0000000000	sll zero,zero,0		.6 -- Nop
+194:  0605224961	addiu s3,zero,1		.7 -- copy _V24 ← 1
+198:  2949840908	sw s3,fp,12		.8 -- store content of s3 in _V24
+19c:  0134217948	j 370 <laplaciano+0x204>		.9 -- jump to laplaciano+_i24
+1a0:  0000000000	sll zero,zero,0		.9 -- Nop
+1a4:  2413035528	lw s4,fp,8		.10 -- load content from _V23 in s4
+1a8:  0000000000	sll zero,zero,0		.10 -- Nop
+1ac:  0646840319	addiu t5,s4,-1		.11 -- _T26 = _V23 - 1
+1b0:  0000880768	sll t6,t5,2		.12 -- _T27 = _T26 << 2
+1b4:  2413101068	lw s5,fp,12		.13 -- load content from _V24 in s5
+1b8:  0000000000	sll zero,zero,0		.13 -- Nop
+1bc:  0001407009	addu t7,zero,s5		.14 -- copy _T29 ← _V24
+1c0:  0030371873	addu t6,t6,t7		.15 -- _T27 = _T27 + _T29
+1c4:  0000966784	sll t8,t6,2		.16 -- _T33 = _T27 << 2
+1c8:  0060342305	addu t8,gp,t8		.17
+1cc:  2400583680	lw s6,t8,0		.17
+1d0:  0000000000	sll zero,zero,0		.17 -- Nop
+1d4:  0001488929	addu s7,zero,s6		.17 -- copy s7 ← s6
+1d8:  2950103056	sw s7,fp,16		.18 -- store content of s7 in _V36
+1dc:  2413035528	lw s4,fp,8		.19 -- load content from _V23 in s4
+1e0:  0000000000	sll zero,zero,0		.19 -- Nop
+1e4:  0001327137	addu t0,zero,s4		.20 -- copy _T37 ← _V23
+1e8:  0000542848	sll t1,t0,2		.21 -- _T38 = _T37 << 2
+1ec:  2413101068	lw s5,fp,12		.22 -- load content from _V24 in s5
+1f0:  0000000000	sll zero,zero,0		.22 -- Nop
+1f4:  0648806399	addiu t3,s5,-1		.23 -- _T41 = _V24 - 1
+1f8:  0019613729	addu t1,t1,t3		.24 -- _T38 = _T38 + _T41
+1fc:  0000614528	sll t4,t1,2		.25 -- _T45 = _T38 << 2
+200:  0059531297	addu t4,gp,t4		.26
+204:  2374828032	lw t5,t4,0		.26
+208:  2413232144	lw s7,fp,16		.27 -- load content from _V36 in s7
+20c:  0000000000	sll zero,zero,0		.27 -- Nop
+210:  0049133601	addu s7,s7,t5		.28 -- _V36 = _V36 + _T47
+214:  2950103056	sw s7,fp,16		.29 -- store content of s7 in _V36
+218:  2413035528	lw s4,fp,8		.30 -- load content from _V23 in s4
+21c:  0000000000	sll zero,zero,0		.30 -- Nop
+220:  0001341473	addu t7,zero,s4		.31 -- copy _T48 ← _V23
+224:  0001011840	sll t6,t7,2		.32 -- _T49 = _T48 << 2
+228:  2413101068	lw s5,fp,12		.33 -- load content from _V24 in s5
+22c:  0000000000	sll zero,zero,0		.33 -- Nop
+230:  0648544257	addiu t0,s5,1		.34 -- _T52 = _V24 + 1
+234:  0029913121	addu t6,t6,t0		.35 -- _T49 = _T49 + _T52
+238:  0000938112	sll t2,t6,2		.36 -- _T56 = _T49 << 2
+23c:  0059396129	addu t2,gp,t2		.37
+240:  2370502656	lw t3,t2,0		.37
+244:  2413232144	lw s7,fp,16		.38 -- load content from _V36 in s7
+248:  0000000000	sll zero,zero,0		.38 -- Nop
+24c:  0049002529	addu s7,s7,t3		.39 -- _V36 = _V36 + _T58
+250:  2950103056	sw s7,fp,16		.40 -- store content of s7 in _V36
+254:  2413035528	lw s4,fp,8		.41 -- load content from _V23 in s4
+258:  0000000000	sll zero,zero,0		.41 -- Nop
+25c:  0646709249	addiu t4,s4,1		.42 -- _T60 = _V23 + 1
+260:  0000813184	sll t5,t4,2		.43 -- _T61 = _T60 << 2
+264:  2413101068	lw s5,fp,12		.44 -- load content from _V24 in s5
+268:  0000000000	sll zero,zero,0		.44 -- Nop
+26c:  0001407009	addu t7,zero,s5		.45 -- copy _T63 ← _V24
+270:  0028272673	addu t5,t5,t7		.46 -- _T61 = _T61 + _T63
+274:  0000901248	sll t8,t5,2		.47 -- _T67 = _T61 << 2
+278:  0060342305	addu t8,gp,t8		.48
+27c:  2399666176	lw t0,t8,0		.48
+280:  2413232144	lw s7,fp,16		.49 -- load content from _V36 in s7
+284:  0000000000	sll zero,zero,0		.49 -- Nop
+288:  0048805921	addu s7,s7,t0		.50 -- _V36 = _V36 + _T69
+28c:  2950103056	sw s7,fp,16		.51 -- store content of s7 in _V36
+290:  2413035528	lw s4,fp,8		.52 -- load content from _V23 in s4
+294:  0000000000	sll zero,zero,0		.52 -- Nop
+298:  0001339425	addu t6,zero,s4		.53 -- copy _T70 ← _V23
+29c:  0000938112	sll t2,t6,2		.54 -- _T71 = _T70 << 2
+2a0:  2413101068	lw s5,fp,12		.55 -- load content from _V24 in s5
+2a4:  0000000000	sll zero,zero,0		.55 -- Nop
+2a8:  0001398817	addu t3,zero,s5		.56 -- copy _T73 ← _V24
+2ac:  0021712929	addu t2,t2,t3		.57 -- _T71 = _T71 + _T73
+2b0:  0000673920	sll t1,t2,2		.58 -- _T77 = _T71 << 2
+2b4:  0059328545	addu t1,gp,t1		.59
+2b8:  2368929792	lw s3,t1,0		.59
+2bc:  0000000000	sll zero,zero,0		.59 -- Nop
+2c0:  0001269793	addu t4,zero,s3		.59 -- copy t4 ← s3
+2c4:  0604962820	addiu t7,zero,4		.60
+2c8:  0026175512	mult t4,t7		.60 -- _T80 = _T79 * 4
+2cc:  0000026642	mflo t5		.60
+2d0:  2413232144	lw s7,fp,16		.61 -- load content from _V36 in s7
+2d4:  0000000000	sll zero,zero,0		.61 -- Nop
+2d8:  0049133601	addu s7,s7,t5		.62 -- _V36 = _V36 + _T80
+2dc:  2950103056	sw s7,fp,16		.63 -- store content of s7 in _V36
+2e0:  2413232144	lw s7,fp,16		.64 -- load content from _V36 in s7
+2e4:  0000000000	sll zero,zero,0		.64 -- Nop
+2e8:  0605552895	addiu t8,zero,255		.65
+2ec:  0049811491	subu v0,s7,t8		.65
+2f0:  0406847493	blez v0,308 <laplaciano+0x19c>		.65 -- branch if register <= 0
+2f4:  0000000000	sll zero,zero,0		.65 -- Nop
+2f8:  0605421823	addiu s6,zero,255		.66 -- copy _V36 ← 255
+2fc:  2950037520	sw s6,fp,16		.67 -- store content of s6 in _V36
+300:  0134217931	j 32c <laplaciano+0x1c0>		.68 -- jump to laplaciano+_i25
+304:  0000000000	sll zero,zero,0		.68 -- Nop
+308:  2412773392	lw s0,fp,16		.69 -- load content from _V36 in s0
+30c:  0000000000	sll zero,zero,0		.69 -- Nop
+310:  0033558563	subu v0,s0,zero		.70
+314:  0071303173	bgez v0,32c <laplaciano+0x1c0>		.70 -- branch if register >= 0
+318:  0000000000	sll zero,zero,0		.70 -- Nop
+31c:  0605093888	addiu s1,zero,0		.71 -- copy _V36 ← 0
+320:  2949709840	sw s1,fp,16		.72 -- store content of s1 in _V36
+324:  0134217931	j 32c <laplaciano+0x1c0>		.73 -- jump to laplaciano+_i25
+328:  0000000000	sll zero,zero,0		.73 -- Nop
+32c:  2412904456	lw s2,fp,8		.74 -- load content from _V23 in s2
+330:  0000000000	sll zero,zero,0		.74 -- Nop
+334:  0001200161	addu t2,zero,s2		.75 -- copy _T81 ← _V23
+338:  0000673920	sll t1,t2,2		.76 -- _T82 = _T81 << 2
+33c:  2413035532	lw s4,fp,12		.77 -- load content from _V24 in s4
+340:  0000000000	sll zero,zero,0		.77 -- Nop
+344:  0001335329	addu t4,zero,s4		.78 -- copy _T84 ← _V24
+348:  0019679265	addu t1,t1,t4		.79 -- _T82 = _T82 + _T84
+34c:  0000620672	sll t7,t1,2		.80 -- _T88 = _T82 << 2
+350:  2413101072	lw s5,fp,16		.81 -- load content from _V36 in s5
+354:  0000000000	sll zero,zero,0		.81 -- Nop
+358:  0059734049	addu t7,gp,t7		.82
+35c:  2918514752	sw s5,t7,64		.82 -- store content of t7 in _G90[_T88]
+360:  2413232140	lw s7,fp,12		.83 -- load content from _V24 in s7
+364:  0000000000	sll zero,zero,0		.83 -- Nop
+368:  0653721601	addiu s7,s7,1		.84 -- _V24 = _V24 + 1
+36c:  2950103052	sw s7,fp,12		.85 -- store content of s7 in _V24
+370:  2413166604	lw s6,fp,12		.86 -- load content from _V24 in s6
+374:  2412773380	lw s0,fp,4		.87 -- load content from _V22 in s0
+378:  0000000000	sll zero,zero,0		.87 -- Nop
+37c:  0047190051	subu v0,s6,s0		.88
+380:  0071368584	bltz v0,1a4 <laplaciano+0x38>		.88 -- branch if register < 0
+384:  0000000000	sll zero,zero,0		.88 -- Nop
+388:  2412838920	lw s1,fp,8		.89 -- load content from _V23 in s1
+38c:  0000000000	sll zero,zero,0		.89 -- Nop
+390:  0640745473	addiu s1,s1,1		.90 -- _V23 = _V23 + 1
+394:  2949709832	sw s1,fp,8		.91 -- store content of s1 in _V23
+398:  2412904456	lw s2,fp,8		.92 -- load content from _V23 in s2
+39c:  2413035520	lw s4,fp,0		.93 -- load content from _V20 in s4
+3a0:  0000000000	sll zero,zero,0		.93 -- Nop
+3a4:  0039063587	subu v0,s2,s4		.94
+3a8:  0071368570	bltz v0,194 <laplaciano+0x28>		.94 -- branch if register < 0
+3ac:  0000000000	sll zero,zero,0		.94 -- Nop
+3b0:  0666697748	addiu sp,sp,20		 -- epilog| pop stack frame
+3b4:  0001962017	addu fp,zero,sp		 -- epilog| pop stack frame
+3b8:  0065011720	jr ra		 -- epilog| return
+
+
+load (int32) _V36		  T< load >		
+120:	 65:		if _V36 <= 255 goto <laplaciano+_i26>		  T< branch >		
+		<laplaciano+_i27>:
+121:	 66:		_V36 := 255		  T< copy >		
+122:	 67:		store (int32) _V36		  T< store >		
+123:	 68:		goto <laplaciano+_i25>		  T< jump >		
+		<laplaciano+_i26>:
+124:	 69:		load (int32) _V36		  T< load >		
+125:	 70:		if _V36 >= 0 goto <laplaciano+_i28>		  T< branch >		
+		<laplaciano+_i29>:
+126:	 71:		_V36 := 0		  T< copy >		
+127:	 72:		store (int32) _V36		  T< store >		
+128:	 73:		goto <laplaciano+_i25>		  T< jump >		
+		<laplaciano+_i28>:
+		<laplaciano+_i25>:
+*/

+ 1 - 208
src/samples/program_jun_laplaciano.go

@@ -98,6 +98,7 @@ func laplaciano() {
             l -= (4 * origin[i][j])
 
             if l > 255 { l = 255 }
+            else if l < 0 { l = 0 }
 
             result[i][j] = l
         }
@@ -108,211 +109,3 @@ func main() {
     preenche_matriz()
     laplaciano()
 }
-
-/**
-main.@preenche_matriz.main.@preenche_matriz.value : _V8
-main.@preenche_matriz.@for_0.main.@preenche_matriz.@for_0.i : _V6
-main.@preenche_matriz.@for_0.@for_1.COL : 4
-main.@preenche_matriz.main.@preenche_matriz.LM1 : _V3
-main.@preenche_matriz.@for_0.@for_1.LM1 : _V3
-main.main.result : _G90
-main.@preenche_matriz.w : _V1
-main.@preenche_matriz.@for_0.@for_1.main.@preenche_matriz.@for_0.@for_1.j : _V7
-main.@preenche_matriz.@for_0.@for_1.CM1 : _V5
-main.@preenche_matriz.@for_0.@for_1.value : _V8
-main.@preenche_matriz.@for_0.LIN : 4
-_V1 : main.@preenche_matriz.w
-_V3 : main.@preenche_matriz.LM1
-_V6 : main.@preenche_matriz.@for_0.i
-_V5 : main.@preenche_matriz.CM1
-main.@preenche_matriz.@for_0.i : _V6
-_V8 : main.@preenche_matriz.@for_0.@for_1.value
-_V7 : main.@preenche_matriz.@for_0.@for_1.j
-_G18 : main.main.origin
-main.@preenche_matriz.@for_0.@for_1.i : _V6
-main.@preenche_matriz.CM1 : _V5
-main.@preenche_matriz.LIN : 4
-main.@preenche_matriz.main.@preenche_matriz.CM1 : _V5
-main.@preenche_matriz.COL : 4
-main.@preenche_matriz.main.@preenche_matriz.w : _V1
-main.@preenche_matriz.@for_0.@for_1.origin : _G18
-main.main.origin : _G18
-_G90 : main.main.result
-main.@preenche_matriz.@for_0.@for_1.w : _V1
-main.@preenche_matriz.LM1 : _V3
-main.@preenche_matriz.@for_0.@for_1.j : _V7
-
-
-
-4 : main.@laplaciano.LIN
-main.@laplaciano.LIN : 4
-
-main.@laplaciano.COL : 4
-
-_V22 : main.@laplaciano.CM1
-main.@laplaciano.CM1 : _V22
-main.@laplaciano.main.@laplaciano.CM1 : _V22
-main.@laplaciano.@for_3.@for_4.CM1 : _V22
-
-_V20 : main.@laplaciano.LM1
-main.@laplaciano.LM1 : _V20
-main.@laplaciano.@for_3.LM1 : _V20
-main.@laplaciano.main.@laplaciano.LM1 : _V20
-
-main.@laplaciano.@for_3.i : _V23
-_V23 : main.@laplaciano.@for_3.i
-main.@laplaciano.@for_3.@for_4.i : _V23
-main.@laplaciano.@for_3.main.@laplaciano.@for_3.i : _V23
-
-main.@laplaciano.main.@laplaciano.l : _V36
-main.@laplaciano.@for_3.@for_4.l : _V36
-_V36 : main.@laplaciano.@for_3.@for_4.l
-
-_V24 : main.@laplaciano.@for_3.@for_4.j
-main.@laplaciano.@for_3.@for_4.j : _V24
-main.@laplaciano.@for_3.@for_4.main.@laplaciano.@for_3.@for_4.j : _V24
-
-main.@laplaciano.@for_3.@for_4.origin : _G18
-main.@laplaciano.@for_3.@for_4.result : _G90
-
-
-		<laplaciano>:
-16c:  0666763244	addiu sp,sp,-20		 -- prolog| push stack frame
-170:  0001962017	addu fp,zero,sp		 -- prolog|copy fp ← sp
-174:  0605028355	addiu s0,zero,3		.0 -- copy _V20 ← 3
-178:  2949644288	sw s0,fp,0		.1 -- store content of s0 in _V20
-17c:  0605093891	addiu s1,zero,3		.2 -- copy _V22 ← 3
-180:  2949709828	sw s1,fp,4		.3 -- store content of s1 in _V22
-184:  0605159425	addiu s2,zero,1		.4 -- copy _V23 ← 1
-188:  2949775368	sw s2,fp,8		.5 -- store content of s2 in _V23
-18c:  0134217947	j 36c <laplaciano+0x200>		.6 -- jump to laplaciano+_i20
-190:  0000000000	sll zero,zero,0		.6 -- Nop
-194:  0605224961	addiu s3,zero,1		.7 -- copy _V24 ← 1
-198:  2949840908	sw s3,fp,12		.8 -- store content of s3 in _V24
-19c:  0134217937	j 344 <laplaciano+0x1d8>		.9 -- jump to laplaciano+_i24
-1a0:  0000000000	sll zero,zero,0		.9 -- Nop
-1a4:  2413035528	lw s4,fp,8		.10 -- load content from _V23 in s4
-1a8:  0000000000	sll zero,zero,0		.10 -- Nop
-1ac:  0646840319	addiu t5,s4,-1		.11 -- _T26 = _V23 - 1
-1b0:  0000880768	sll t6,t5,2		.12 -- _T27 = _T26 << 2
-1b4:  2413101068	lw s5,fp,12		.13 -- load content from _V24 in s5
-1b8:  0000000000	sll zero,zero,0		.13 -- Nop
-1bc:  0001407009	addu t7,zero,s5		.14 -- copy _T29 ← _V24
-1c0:  0030371873	addu t6,t6,t7		.15 -- _T27 = _T27 + _T29
-1c4:  0000966784	sll t8,t6,2		.16 -- _T33 = _T27 << 2
-1c8:  0060342305	addu t8,gp,t8		.17
-1cc:  2400583680	lw s6,t8,0		.17
-1d0:  0000000000	sll zero,zero,0		.17 -- Nop
-1d4:  0001488929	addu s7,zero,s6		.17 -- copy s7 ← s6
-1d8:  2950103056	sw s7,fp,16		.18 -- store content of s7 in _V36
-1dc:  2413035528	lw s4,fp,8		.19 -- load content from _V23 in s4
-1e0:  0000000000	sll zero,zero,0		.19 -- Nop
-1e4:  0001327137	addu t0,zero,s4		.20 -- copy _T37 ← _V23
-1e8:  0000542848	sll t1,t0,2		.21 -- _T38 = _T37 << 2
-1ec:  2413101068	lw s5,fp,12		.22 -- load content from _V24 in s5
-1f0:  0000000000	sll zero,zero,0		.22 -- Nop
-1f4:  0648806399	addiu t3,s5,-1		.23 -- _T41 = _V24 - 1
-1f8:  0019613729	addu t1,t1,t3		.24 -- _T38 = _T38 + _T41
-1fc:  0000614528	sll t4,t1,2		.25 -- _T45 = _T38 << 2
-200:  0059531297	addu t4,gp,t4		.26
-204:  2374828032	lw t5,t4,0		.26
-208:  2413232144	lw s7,fp,16		.27 -- load content from _V36 in s7
-20c:  0000000000	sll zero,zero,0		.27 -- Nop
-210:  0049133601	addu s7,s7,t5		.28 -- _V36 = _V36 + _T47
-214:  2950103056	sw s7,fp,16		.29 -- store content of s7 in _V36
-218:  2413035528	lw s4,fp,8		.30 -- load content from _V23 in s4
-21c:  0000000000	sll zero,zero,0		.30 -- Nop
-220:  0001341473	addu t7,zero,s4		.31 -- copy _T48 ← _V23
-224:  0001011840	sll t6,t7,2		.32 -- _T49 = _T48 << 2
-228:  2413101068	lw s5,fp,12		.33 -- load content from _V24 in s5
-22c:  0000000000	sll zero,zero,0		.33 -- Nop
-230:  0648544257	addiu t0,s5,1		.34 -- _T52 = _V24 + 1
-234:  0029913121	addu t6,t6,t0		.35 -- _T49 = _T49 + _T52
-238:  0000938112	sll t2,t6,2		.36 -- _T56 = _T49 << 2
-23c:  0059396129	addu t2,gp,t2		.37
-240:  2370502656	lw t3,t2,0		.37
-244:  2413232144	lw s7,fp,16		.38 -- load content from _V36 in s7
-248:  0000000000	sll zero,zero,0		.38 -- Nop
-24c:  0049002529	addu s7,s7,t3		.39 -- _V36 = _V36 + _T58
-250:  2950103056	sw s7,fp,16		.40 -- store content of s7 in _V36
-254:  2413035528	lw s4,fp,8		.41 -- load content from _V23 in s4
-258:  0000000000	sll zero,zero,0		.41 -- Nop
-25c:  0646709249	addiu t4,s4,1		.42 -- _T60 = _V23 + 1
-260:  0000813184	sll t5,t4,2		.43 -- _T61 = _T60 << 2
-264:  2413101068	lw s5,fp,12		.44 -- load content from _V24 in s5
-268:  0000000000	sll zero,zero,0		.44 -- Nop
-26c:  0001407009	addu t7,zero,s5		.45 -- copy _T63 ← _V24
-270:  0028272673	addu t5,t5,t7		.46 -- _T61 = _T61 + _T63
-274:  0000901248	sll t8,t5,2		.47 -- _T67 = _T61 << 2
-278:  0060342305	addu t8,gp,t8		.48
-27c:  2399666176	lw t0,t8,0		.48
-280:  2413232144	lw s7,fp,16		.49 -- load content from _V36 in s7
-284:  0000000000	sll zero,zero,0		.49 -- Nop
-288:  0048805921	addu s7,s7,t0		.50 -- _V36 = _V36 + _T69
-28c:  2950103056	sw s7,fp,16		.51 -- store content of s7 in _V36
-290:  2413035528	lw s4,fp,8		.52 -- load content from _V23 in s4
-294:  0000000000	sll zero,zero,0		.52 -- Nop
-298:  0001339425	addu t6,zero,s4		.53 -- copy _T70 ← _V23
-29c:  0000938112	sll t2,t6,2		.54 -- _T71 = _T70 << 2
-2a0:  2413101068	lw s5,fp,12		.55 -- load content from _V24 in s5
-2a4:  0000000000	sll zero,zero,0		.55 -- Nop
-2a8:  0001398817	addu t3,zero,s5		.56 -- copy _T73 ← _V24
-2ac:  0021712929	addu t2,t2,t3		.57 -- _T71 = _T71 + _T73
-2b0:  0000673920	sll t1,t2,2		.58 -- _T77 = _T71 << 2
-2b4:  0059328545	addu t1,gp,t1		.59
-2b8:  2368929792	lw s3,t1,0		.59
-2bc:  0000000000	sll zero,zero,0		.59 -- Nop
-2c0:  0001269793	addu t4,zero,s3		.59 -- copy t4 ← s3
-2c4:  0604962820	addiu t7,zero,4		.60
-2c8:  0026175512	mult t4,t7		.60 -- _T80 = _T79 * 4
-2cc:  0000026642	mflo t5		.60
-2d0:  2413232144	lw s7,fp,16		.61 -- load content from _V36 in s7
-2d4:  0000000000	sll zero,zero,0		.61 -- Nop
-2d8:  0049133603	subu s7,s7,t5		.62 -- _V36 = _V36 - _T80
-2dc:  2950103056	sw s7,fp,16		.63 -- store content of s7 in _V36
-2e0:  2413232144	lw s7,fp,16		.64 -- load content from _V36 in s7
-2e4:  0000000000	sll zero,zero,0		.64 -- Nop
-2e8:  0605552895	addiu t8,zero,255		.65
-2ec:  0049811491	subu v0,s7,t8		.65
-2f0:  0406847491	blez v0,300 <laplaciano+0x194>		.65 -- branch if register <= 0
-2f4:  0000000000	sll zero,zero,0		.65 -- Nop
-2f8:  0605421823	addiu s6,zero,255		.66 -- copy _V36 ← 255
-2fc:  2950037520	sw s6,fp,16		.67 -- store content of s6 in _V36
-300:  2412773384	lw s0,fp,8		.68 -- load content from _V23 in s0
-304:  0000000000	sll zero,zero,0		.68 -- Nop
-308:  0001077281	addu t6,zero,s0		.69 -- copy _T81 ← _V23
-30c:  0000940160	sll t3,t6,2		.70 -- _T82 = _T81 << 2
-310:  2412838924	lw s1,fp,12		.71 -- load content from _V24 in s1
-314:  0000000000	sll zero,zero,0		.71 -- Nop
-318:  0001134625	addu t2,zero,s1		.72 -- copy _T84 ← _V24
-31c:  0023746593	addu t3,t3,t2		.73 -- _T82 = _T82 + _T84
-320:  0000739456	sll t1,t3,2		.74 -- _T88 = _T82 << 2
-324:  2412904464	lw s2,fp,16		.75 -- load content from _V36 in s2
-328:  0000000000	sll zero,zero,0		.75 -- Nop
-32c:  0059328545	addu t1,gp,t1		.76
-330:  2905735232	sw s2,t1,64		.76 -- store content of t1 in _G90[_T88]
-334:  2413101068	lw s5,fp,12		.77 -- load content from _V24 in s5
-338:  0000000000	sll zero,zero,0		.77 -- Nop
-33c:  0649396225	addiu s5,s5,1		.78 -- _V24 = _V24 + 1
-340:  2949971980	sw s5,fp,12		.79 -- store content of s5 in _V24
-344:  2412969996	lw s3,fp,12		.80 -- load content from _V24 in s3
-348:  2413232132	lw s7,fp,4		.81 -- load content from _V22 in s7
-34c:  0000000000	sll zero,zero,0		.81 -- Nop
-350:  0041357347	subu v0,s3,s7		.82
-354:  0071368595	bltz v0,1a4 <laplaciano+0x38>		.82 -- branch if register < 0
-358:  0000000000	sll zero,zero,0		.82 -- Nop
-35c:  2413166600	lw s6,fp,8		.83 -- load content from _V23 in s6
-360:  0000000000	sll zero,zero,0		.83 -- Nop
-364:  0651558913	addiu s6,s6,1		.84 -- _V23 = _V23 + 1
-368:  2950037512	sw s6,fp,8		.85 -- store content of s6 in _V23
-36c:  2412773384	lw s0,fp,8		.86 -- load content from _V23 in s0
-370:  2412838912	lw s1,fp,0		.87 -- load content from _V20 in s1
-374:  0000000000	sll zero,zero,0		.87 -- Nop
-378:  0034672675	subu v0,s0,s1		.88
-37c:  0071368581	bltz v0,194 <laplaciano+0x28>		.88 -- branch if register < 0
-380:  0000000000	sll zero,zero,0		.88 -- Nop
-384:  0666697748	addiu sp,sp,20		 -- epilog| pop stack frame
-388:  0001962017	addu fp,zero,sp		 -- epilog| pop stack frame
-38c:  0065011720	jr ra		 -- epilog| return
-
-*/

+ 2 - 2
src/targets/mips/Descriprion.java

@@ -403,7 +403,7 @@ public class Descriprion {
                     .Set("type", "I")
                     .Set("inst", "bltz")
                     .Set("codop", "000001")
-                    .Set("rt", "zero")
+                    .Set("rt", "00000")
                     .Set("format", "I0"));
 
             put("bne", new Instruction()//r != Set
@@ -513,7 +513,7 @@ public class Descriprion {
         if (!Codops.containsKey(inst)) {
             throw new Exception(String.format("Instruction '%s' not defined", inst));
         }
-        return Codops.get(inst);
+        return Codops.get(inst).copy();
     }
 
     public static String InstructionByOperator(Instruction inst) throws Exception {

+ 2 - 2
src/targets/mips/MipsRegisterAllocMiddleware.java

@@ -78,7 +78,7 @@ public class MipsRegisterAllocMiddleware implements AllocatorInterface, Middlewa
             instructionPosition++;
         }
 
-        System.out.println(group);
+//        System.out.println(group);
     }
 
     @Override
@@ -165,7 +165,7 @@ public class MipsRegisterAllocMiddleware implements AllocatorInterface, Middlewa
             // Libera um registrador ocupado
             if (reg == null) {
 
-                System.out.println("spill" + bb + " P:" + position + " b:" + bb.Spill(position));
+//                System.out.println("spill" + bb + " P:" + position + " b:" + bb.Spill(position));
 
                 reg = bb.Spill(position).getRegister();
             }

+ 31 - 61
src/targets/mips/Translate.java

@@ -43,7 +43,7 @@ public class Translate extends API.TargetGen {
     }
 
     @Override
-    public void TranslateLabel(Instruction inst) {
+    public void TranslateLabel(Instruction inst) throws Exception {
 
         Add(new Instruction()
                 .Set("type", "label")
@@ -91,8 +91,6 @@ public class Translate extends API.TargetGen {
             // mult, divu, sgtu ,sltu 
             // sra, srl, sll
             case "R":
-//                System.out.println("Translate assign:" + inst + "-" + Descriprion.Codops.Get(instruction).Get("type"));
-//                System.out.println("SLL:" + inst);
                 LoadParam(inst);
                 //
                 if (ninst.in("inst", "sll,srl,sra".split(","))) {
@@ -234,10 +232,11 @@ public class Translate extends API.TargetGen {
 
         LoadParam(inst);
 
-        String rs = inst.Get("reg.p1"), rt = inst.Get("reg.p2");
+        String rs = inst.Get("reg.p1"),
+                rt = inst.Get("reg.p2");
 
-        Instruction branch = new Instruction("I", instruction)
-                .Set("label", inst.Get("funcname"));
+        Instruction branch = Descriprion.Instruction(instruction);
+//                .Set("label", inst.Get("funcname"));
 
         switch (instruction) {
             case "beq": // == {[inst]}' ' {[rt]},{[rs]},{immediate}
@@ -261,7 +260,9 @@ public class Translate extends API.TargetGen {
                 break;
         }
 
-        Add(branch).Set("label", inst.Get("label")).Set("comment", comments.get(instruction));
+        Add(branch)
+                .Set("label", inst.Get("label"))
+                .Set("comment", comments.get(instruction));
 
         Nop(false);
     }
@@ -289,7 +290,7 @@ public class Translate extends API.TargetGen {
             }
         }
 
-        Add(Descriprion.Instruction("nop").copy());
+        Add(Descriprion.Instruction("nop"));
     }
 
     @Override
@@ -325,9 +326,7 @@ public class Translate extends API.TargetGen {
 
                 alloc.Set("offset", (data.Size() - 0));
             }
-//            System.out.println("PROLOG:(" + newvars + ")" + alloc);
         }
-//        System.out.println("Activation Registry:()\n" + data);
 
         if (alloc.getInt("offset", 0) != 0) {
             // Copia o sp para o fp
@@ -441,7 +440,7 @@ public class Translate extends API.TargetGen {
     public void TranslateLoad(Instruction inst) throws Exception {
         String addr = inst.Get("p1"), rd = inst.Get("reg.p1");
 
-//        System.out.println("Load " + addr + " on block ");
+//        System.out.println("Load " + inst + " on block ");
         LoadWord(
                 target.DEFAULT_WORD_TYPE,
                 rd,
@@ -454,7 +453,6 @@ public class Translate extends API.TargetGen {
     public void TranslateStore(Instruction inst) throws Exception {
         String addr = inst.Get("p1"), rs = inst.Get("reg.p1");
 
-//        System.out.println("Store " + addr + " on block ");
         StoreWord(
                 target.DEFAULT_WORD_TYPE,
                 rs,
@@ -599,9 +597,9 @@ public class Translate extends API.TargetGen {
      * @param rt
      * @return
      */
-    protected Instruction Copy(Instruction inst, String rt) {
+    protected Instruction Copy(Instruction inst, String rt) throws Exception {
         Instruction c;
-        if (inst.eq("p1value", "true")) {
+        if (inst.IsValue("p1")) {
             // andi Rt,Rs,immediate | Rt <-- [Rs] + ([I15]16 || [I15..0]);
             c = Copy(rt, "zero", inst.Get("p1"));
 
@@ -613,7 +611,7 @@ public class Translate extends API.TargetGen {
         return c;
     }
 
-    protected void IndexedRead(Instruction inst) {
+    protected void IndexedRead(Instruction inst) throws Exception {
         // Se a fonte é indexada
         if (inst.eq("src_indexed", "true")) {
             try {
@@ -642,7 +640,6 @@ public class Translate extends API.TargetGen {
                         Offset(p1)
                 );
 
-//                AddNop();
             } catch (Exception ex) {
                 Logger.getLogger(Translate.class.getName()).log(Level.SEVERE, null, ex);
             }
@@ -710,52 +707,30 @@ public class Translate extends API.TargetGen {
      * @param inst
      * @return
      */
-    protected void LoadParam(Instruction inst) {
+    protected void LoadParam(Instruction inst) throws Exception {
         LoadParam(inst, "p1,p2");
     }
 
-    protected void LoadParam(Instruction inst, String params) {
+    protected void LoadParam(Instruction inst, String params) throws Exception {
         LoadParam(inst, params.split(","));
     }
 
-    protected void LoadParam(Instruction inst, String[] params) {
-        String pname;
-        Instruction Ninst;
+    protected void LoadParam(Instruction inst, String[] params) throws Exception {
+        String offset;
 
         for (String param : params) {
-            if (!inst.Has("reg." + param + ".load")) {
-                continue;
-            }
+            if (inst.IsValue(param) && inst.Has("reg." + param)) {
 
-            Ninst = new Instruction();
-            pname = inst.Get(param);
+                offset = inst.Get(param);
 
-            if (inst.eq(param + "value", "true")) {
-//                System.out.println("pname:" + pname);
-                if (pname.equals("0")) {
+                if (offset.equals("0")) {
                     inst.Set("reg." + param, "zero");
                     continue;
                 }
-                Ninst.Set("inst", "addiu") // R[$rt] ← {(imm)[15:0], 0 × 16}
-                        .Set("rs", "zero")
-                        .Set("rt", inst.Get("reg." + param))
-                        .Set("offset", pname);
-            } else {
-
-//                System.out.println("Load PARAM from memory");
-//                try {
-//                    Ninst.Set("inst", "lw") // R[$rt] ← Mem4B(R[$rs] + SignExt16b(imm))
-//                            .Set("rt", inst.Get("reg." + param))
-//                            .Set("rs", FrameRegister(pname))
-//                            .Set("comment", F("load address stored in %S", pname))
-//                            .Set("offset", Offset(pname).getAddress());
-//                } catch (Exception ex) {
-//                    Logger.getLogger(Translate.class.getName()).log(Level.SEVERE, null, ex);
-//                }
+
+                Copy(inst.Get("reg." + param), "zero", offset);
             }
-            Add(Ninst);
         }
-//        return null;
     }
 
     /**
@@ -765,7 +740,7 @@ public class Translate extends API.TargetGen {
      * @param dst
      * @return
      */
-    protected Instruction CopyReg(String src, String dst) {
+    protected Instruction CopyReg(String src, String dst) throws Exception {
         return Add(new Instruction("addu")
                 .Set("rs", "zero")
                 .Set("rt", src)
@@ -773,11 +748,11 @@ public class Translate extends API.TargetGen {
                 .Set("comment", F("copy %s ← %s", dst, src)));
     }
 
-    protected Instruction Copy(String rt, String rs, Offset offset) {
+    protected Instruction Copy(String rt, String rs, Offset offset) throws Exception {
         return Copy(rt, rs, "" + offset);
     }
 
-    protected Instruction Copy(String rt, String rs, String offset) {
+    protected Instruction Copy(String rt, String rs, String offset) throws Exception {
         return Add(new Instruction("addiu") // lw $rt, imm($rs)
                 .Set("rt", rt)
                 .Set("rs", rs)
@@ -862,18 +837,13 @@ public class Translate extends API.TargetGen {
     }
 
     @Override
-    protected Instruction Add(Instruction inst) {
-        try {
-            if (!inst.eq("type", "label")) {
-                getTarget().PositionInc();
-                Instruction definiction = Descriprion.Instruction(inst.Get("inst"));
-                inst.Merge("sa,type,inst,codop,func,format", definiction);
-            }
-
-        } catch (Exception ex) {
-            Logger.getLogger(Translate.class
-                    .getName()).log(Level.SEVERE, null, ex);
+    protected Instruction Add(Instruction inst) throws Exception {
+        if (!inst.eq("type", "label")) {
+            getTarget().PositionInc();
+            Instruction definiction = Descriprion.Instruction(inst.Get("inst"));
+            inst.Merge("sa,type,inst,codop,func,format", definiction);
         }
+
         if (currentIrInstruction != null) {
             inst.Set("inloop", currentIrInstruction.Get("inloop"));
         }

+ 1 - 0
src/templates/Functions.java

@@ -44,6 +44,7 @@ public class Functions {
                 }
                 return "";
             });
+
             put("DEC", (FunctionInterface) (ctx, args) -> {
                 String value = args.get(0);
                 if (!value.equals("")) {

+ 10 - 3
src/tools/mips/Memory.java

@@ -84,8 +84,8 @@ public class Memory {
     }
 
     public Long ReadLong(long address, int rsize) throws Exception {
-//        System.out.println("R(address, rsize):" + R(address, rsize));
-        return Utils.bin32ToDec(R(address, rsize));
+//        System.out.println("R(address, rsize):" + Utils.padPreserveSignal(64, R(address, rsize)));
+        return Long.parseUnsignedLong(Utils.padPreserveSignal(64, R(address, rsize)), 2);
     }
 
     public String R(long address, int rsize) throws Exception {
@@ -94,9 +94,10 @@ public class Memory {
         for (int i = 0; i < rsize; i++) {
             buffer += RB(address + i);
         }
+        return buffer;
 //        return Utils.Pad(buffer, "0", Utils.PAD_LEFT, 32);
 //        System.out.println("R:" + buffer);
-        return Utils.padPreserveSignal(32, buffer);
+//        return Utils.padPreserveSignal(32, buffer);
     }
 
     public String RB(long address) throws Exception {
@@ -143,6 +144,12 @@ public class Memory {
         bin = Utils.Pad(bin, "0", Utils.PAD_LEFT, 32);
 
         String[] bytes = Utils.SplitEach(bin, 8);
+        //Fix to 16 bytes of negative value binary
+
+//        System.out.println("W(" + address + ")" + Arrays.asList(bytes));
+        if (bytes.length > 4) {
+            bpos += 4;
+        }
 
         for (int i = 0; i < wsize; i++) {
             WB(address + i, bytes[bpos + i]);

+ 28 - 58
src/tools/mips/MipsProcessor.java

@@ -28,7 +28,7 @@ public class MipsProcessor {
     public Memory InstructionMemory;
     public Long PC = 0L;
     public RegisterBank RBank;
-    public HashMap<String, Instruction> instructions;
+    public HashMap<String, Instruction> instructions = new HashMap<>();
 
     public TreeMap<String, Boolean> breakPoint = new TreeMap<>();
 
@@ -66,6 +66,7 @@ public class MipsProcessor {
                 + "memory.instruction,"
                 + "memory.instruction.size,"
                 + "memory.data,"
+                + "memory.data.reset,"
                 + "memory.data.size",
                 settings);
 
@@ -121,7 +122,9 @@ public class MipsProcessor {
         }
         // Carrega o conteudo das memorias
         InstructionMemory.ReadFile();
-        DataMemory.ReadFile();
+        if (!settings.eq("memory.data.reset", "true")) {
+            DataMemory.ReadFile();
+        }
 
         // Fetch
 //        System.out.println("InstructionMemory:" + InstructionMemory);
@@ -138,11 +141,10 @@ public class MipsProcessor {
 
             cAddress = Long.toHexString(PC);
 
-            Log("Interation(" + (interation++) + ")[" + cAddress + "]" + instruction.Get("inst"));
-
             // Executa a instrucao
+            Log("Interation(" + (interation++) + ")[ " + cAddress + " ] " + instruction.Get("inst"));
             Execute(instruction);
-
+            // PC já incrementou
             Log("Registradores(\n" + RBank + ")\n Next PC:" + Long.toHexString(PC));
 
             // Verifica o controle de execução do simulador
@@ -158,12 +160,19 @@ public class MipsProcessor {
 //        String bin = Utils.Pad(32, Integer.toBinaryString(val));
 //        System.out.println("Run:" + bin + ":" + bin.length());
         String codop = bin.substring(0, 6), key, func = "";
+        String rs = bin.substring(6, 11),
+                rt = bin.substring(11, 16);
 
-        if (codop.equals("000000")) {
-            func = bin.substring(26);
-            key = "@" + func;
-        } else {
-            key = codop;
+        switch (codop) {
+            case "000000":
+                func = bin.substring(26);
+                key = "@" + func;
+                break;
+            case "000001":
+                key = codop + rt;
+                break;
+            default:
+                key = codop;
         }
 
         if (!instructions.containsKey(key)) {
@@ -173,9 +182,6 @@ public class MipsProcessor {
 
         Instruction i = instructions.get(key).copy();
 
-        String rs = bin.substring(6, 11),
-                rt = bin.substring(11, 16);
-
         switch (i.Get("type")) {
             case "R":
                 i.Set("rs.bin", rs);
@@ -210,8 +216,7 @@ public class MipsProcessor {
 //    public Integer IntToHex(Integer n) {
 //        return Integer.valueOf(String.valueOf(n), 16);
 //    }
-    protected void InitInstructions() {
-        instructions = new HashMap<>();
+    protected void InitInstructions() throws Exception {
         String key;
         for (Map.Entry<String, Instruction> entry : Descriprion.Codops.entrySet()) {
 //            String string = entry.getKey();
@@ -219,9 +224,15 @@ public class MipsProcessor {
 
             key = instruction.Get("codop");
 
-            if (instruction.eq("codop", "000000")) {
-                key = "@" + instruction.Get("func");
+            switch (key) {
+                case "000000":
+                    key = "@" + instruction.Get("func");
+                    break;
+                case "000001":
+                    key += instruction.Get("rt");
+                    break;
             }
+
             instructions.put(key, instruction);
         };
     }
@@ -439,44 +450,3 @@ public class MipsProcessor {
         PC += WORD;
     }
 }
-
-/**
- * <main>: 0: 0201326595	jal c <preenche+0x0>	.0 -- jump to <preenche>
- * 4: 0000000000	sll zero,zero,0	.0 -- Nop 8: 4294967295	stop -- End of programa
- * <preenche>: c: 0666763252	addiu sp,sp,-12	-- prolog| push stack frame 10:
- * 0001962017	addu fp,zero,sp	-- prolog|copy fp ← sp 14: 0605028353	addiu
- * s0,zero,1	.0 -- copy _V1 ← 1 18: 2949644288	sw s0,fp,0	.1 -- store content of
- * s0 in _V1 1c: 0605093888	addiu s1,zero,0	.2 -- copy _V2 ← 0 20: 2949709828	sw
- * s1,fp,4	.3 -- store content of s1 in _V2 24: 0134217774	j b8 <preenche+0xac>
- * .4 -- jump to preenche+_i3 28: 0000000000	sll zero,zero,0	.4 -- Nop 2c:
- * 0605159424	addiu s2,zero,0	.5 -- copy _V3 ← 0 30: 2949775368	sw s2,fp,8	.6 --
- * store content of s2 in _V3 34: 0134217764	j 90 <preenche+0x84>	.7 -- jump to
- * preenche+_i7 38: 0000000000	sll zero,zero,0	.7 -- Nop 3c: 2412969988	lw
- * s3,fp,4	.8 -- load content from _V2 in s3 40: 0000000000	sll zero,zero,0	.8
- * -- Nop 44: 0001267745	addu t3,zero,s3	.9 -- copy _T4 ← _V2 48: 0000745536	sll
- * t4,t3,1	.10 -- _T5 = _T4 << 1 4c: 2413035528	lw s4,fp,8	.11 -- load content
- * from _V3 in s4 50: 0000000000	sll zero,zero,0	.11 -- Nop 54: 0001337377	addu
- * t5,zero,s4	.12 -- copy _T7 ← _V3 58: 0026042401	addu t4,t4,t5	.13 -- _T5 =
- * _T5 + _T7 5c: 0000815232	sll t6,t4,2	.14 -- _T11 = _T5 << 2 60: 2413101056	lw
- * s5,fp,0	.15 -- load content from _V1 in s5 64: 0000000000	sll zero,zero,0	.15
- * -- Nop 68: 0059666465	addu t6,gp,t6	.16 6c: 2916417536	sw s5,t6,0	.16 --
- * store content of t6 in _G13[_T11] 70: 2413101056	lw s5,fp,0	.17 -- load
- * content from _V1 in s5 74: 0000000000	sll zero,zero,0	.17 -- Nop 78:
- * 0649396225	addiu s5,s5,1	.18 -- _V1 = _V1 + 1 7c: 2949971968	sw s5,fp,0	.19
- * -- store content of s5 in _V1 80: 2413035528	lw s4,fp,8	.20 -- load content
- * from _V3 in s4 84: 0000000000	sll zero,zero,0	.20 -- Nop 88: 0647233537	addiu
- * s4,s4,1	.21 -- _V3 = _V3 + 1 8c: 2949906440	sw s4,fp,8	.22 -- store content
- * of s4 in _V3 90: 2413232136	lw s7,fp,8	.23 -- load content from _V3 in s7 94:
- * 0000000000	sll zero,zero,0	.23 -- Nop 98: 0604504066	addiu t0,zero,2	.24 9c:
- * 0048762915	subu v0,s7,t0	.24 a0: 0071368678	bltz v0,3c <preenche+0x30>	.24 --
- * branch if register < 0 a4: 0000000000	sll zero,zero,0	.24 -- Nop a8:
- * 2412773380	lw s0,fp,4	.25 -- load content from _V2 in s0 ac: 0000000000	sll
- * zero,zero,0	.25 -- Nop b0: 0638582785	addiu s0,s0,1	.26 -- _V2 = _V2 + 1 b4:
- * 2949644292	sw s0,fp,4	.27 -- store content of s0 in _V2 b8: 2412838916	lw
- * s1,fp,4	.28 -- load content from _V2 in s1 bc: 0000000000	sll zero,zero,0	.28
- * -- Nop c0: 0604635138	addiu t2,zero,2	.29 c4: 0036311075	subu v0,s1,t2	.29
- * c8: 0071368664	bltz v0,2c <preenche+0x20>	.29 -- branch if register < 0 cc:
- * 0000000000	sll zero,zero,0	.29 -- Nop d0: 0666697740	addiu sp,sp,12	--
- * epilog| pop stack frame d4: 0001962017	addu fp,zero,sp	-- epilog| pop stack
- * frame d8: 0065011720	jr ra	-- epilog| return
- */

+ 35 - 0
src/tools/mips/Simulator.form

@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="3"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+    <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="658" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <EmptySpace min="0" pref="536" max="32767" attributes="0"/>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+</Form>

+ 83 - 0
src/tools/mips/Simulator.java

@@ -0,0 +1,83 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tools.mips;
+
+/**
+ *
+ * @author EUGENIO CARVALHO
+ */
+public class Simulator extends javax.swing.JFrame {
+
+    /**
+     * Creates new form Simulator
+     */
+    public Simulator() {
+        initComponents();
+    }
+
+    /**
+     * This method is called from within the constructor to initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is always
+     * regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 658, Short.MAX_VALUE)
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGap(0, 536, Short.MAX_VALUE)
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    /**
+     * @param args the command line arguments
+     */
+    public static void main(String args[]) {
+        /* Set the Nimbus look and feel */
+        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
+        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
+         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
+         */
+        try {
+            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
+                if ("Nimbus".equals(info.getName())) {
+                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
+                    break;
+                }
+            }
+        } catch (ClassNotFoundException ex) {
+            java.util.logging.Logger.getLogger(Simulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        } catch (InstantiationException ex) {
+            java.util.logging.Logger.getLogger(Simulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        } catch (IllegalAccessException ex) {
+            java.util.logging.Logger.getLogger(Simulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+            java.util.logging.Logger.getLogger(Simulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
+        }
+        //</editor-fold>
+
+        /* Create and display the form */
+        java.awt.EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                new Simulator().setVisible(true);
+            }
+        });
+    }
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    // End of variables declaration//GEN-END:variables
+}

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

@@ -23,33 +23,33 @@ DATA_RADIX = BIN;
 
 CONTENT
 BEGIN
-00000:	00000000000000000000000000000001;	% dec 1 %
-00004:	00000000000000000000000000000010;	% dec 2 %
-00008:	00000000000000000000000000000011;	% dec 3 %
-00012:	00000000000000000000000000000100;	% dec 4 %
-00016:	00000000000000000000000000000001;	% dec 1 %
-00020:	00000000000000000000000000000010;	% dec 2 %
-00024:	00000000000000000000000000000011;	% dec 3 %
-00028:	00000000000000000000000000000100;	% dec 4 %
-00032:	00000000000000000000000000000111;	% dec 7 %
-00036:	00000000000000000000000000001010;	% dec 10 %
-00040:	00000000000000000000000000001111;	% dec 15 %
-00044:	00000000000000000000000000010110;	% dec 22 %
+00000:	00000000000000000000000000000000;	% dec 0 %
+00004:	00000000000000000000000000000000;	% dec 0 %
+00008:	00000000000000000000000000000000;	% dec 0 %
+00012:	00000000000000000000000000000000;	% dec 0 %
+00016:	00000000000000000000000000000000;	% dec 0 %
+00020:	00000000000000000000000000000001;	% dec 1 %
+00024:	00000000000000000000000000000010;	% dec 2 %
+00028:	00000000000000000000000000000000;	% dec 0 %
+00032:	00000000000000000000000000000000;	% dec 0 %
+00036:	00000000000000000000000000000011;	% dec 3 %
+00040:	00000000000000000000000000000100;	% dec 4 %
+00044:	00000000000000000000000000000000;	% dec 0 %
 00048:	00000000000000000000000000000000;	% dec 0 %
 00052:	00000000000000000000000000000000;	% dec 0 %
 00056:	00000000000000000000000000000000;	% dec 0 %
 00060:	00000000000000000000000000000000;	% dec 0 %
 [64..80]:	00000000000000000000000000000000;
 00084:	00000000000000000000000000000001;	% dec 1 %
-00088:	11111111111111111111111111111111;	% dec 4294967295 %
+00088:	00000000000000000000000000000000;	% dec 0 %
 [92..96]:	00000000000000000000000000000000;
-00100:	11111111111111111111111111111111;	% dec 4294967295 %
-00104:	11111111111111111111111111111111;	% dec 4294967295 %
+00100:	00000000000000000000000000000000;	% dec 0 %
+00104:	00000000000000000000000000000000;	% dec 0 %
 [108..16356]:	00000000000000000000000000000000;
 16360:	00000000000000000000000000000101;	% dec 5 %
 16364:	00000000000000000000000000000011;	% dec 3 %
-16368:	00000000000000000000000000000000;	% dec 0 %
-16372:	00000000000000000000000000000010;	% dec 2 %
-16376:	00000000000000000000000000000010;	% dec 2 %
-16380:	00000000000000000000000000000010;	% dec 2 %
+16368:	00000000000000000000000000000011;	% dec 3 %
+16372:	00000000000000000000000000000011;	% dec 3 %
+16376:	00000000000000000000000000000011;	% dec 3 %
+16380:	00000000000000000000000000000000;	% dec 0 %
 END;

+ 219 - 146
src/tools/mips/memory/mi.memory

@@ -25,166 +25,239 @@ CONTENT
 BEGIN
 000:	00001100000000000000000000000101;	% dec 201326597 %
 004:	00000000000000000000000000000000;	% dec 0 %
-008:	00001100000000000000000001000110;	% dec 201326662 %
+008:	00001100000000000000000001011011;	% dec 201326683 %
 012:	00000000000000000000000000000000;	% dec 0 %
-016:	11111111111111111111111111111111;	% dec 4294967295 %
-020:	00100111101111011111111111110100;	% dec 666763252 %
+016:	11111111111111111111111111111111;	% dec -1 %
+020:	00100111101111011111111111101000;	% dec 666763240 %
 024:	00000000000111011111000000100001;	% dec 1962017 %
 028:	00100100000100000000000000000001;	% dec 605028353 %
-032:	10101111110100000000000000000000;	% dec 2949644288 %
-036:	00100100000100010000000000000000;	% dec 605093888 %
-040:	10101111110100010000000000000100;	% dec 2949709828 %
-044:	00001000000000000000000000111101;	% dec 134217789 %
-048:	00000000000000000000000000000000;	% dec 0 %
-052:	00100100000100100000000000000000;	% dec 605159424 %
-056:	10101111110100100000000000001000;	% dec 2949775368 %
-060:	00001000000000000000000000110011;	% dec 134217779 %
+032:	10101111110100000000000000000000;	% dec -1345323008 %
+036:	00100100000100010000000000000011;	% dec 605093891 %
+040:	10101111110100010000000000000100;	% dec -1345257468 %
+044:	00100100000100100000000000000011;	% dec 605159427 %
+048:	10101111110100100000000000001000;	% dec -1345191928 %
+052:	00100100000100110000000000000000;	% dec 605224960 %
+056:	10101111110100110000000000001100;	% dec -1345126388 %
+060:	00001000000000000000000001010010;	% dec 134217810 %
 064:	00000000000000000000000000000000;	% dec 0 %
-068:	10001111110100110000000000000100;	% dec 2412969988 %
-072:	00000000000000000000000000000000;	% dec 0 %
-076:	00000000000100110101100000100001;	% dec 1267745 %
-080:	00000000000010110110000001000000;	% dec 745536 %
-084:	10001111110101000000000000001000;	% dec 2413035528 %
+068:	00100100000101000000000000000000;	% dec 605290496 %
+072:	10101111110101000000000000010000;	% dec -1345060848 %
+076:	00001000000000000000000001001000;	% dec 134217800 %
+080:	00000000000000000000000000000000;	% dec 0 %
+084:	10001111110101010000000000001100;	% dec -1881866228 %
 088:	00000000000000000000000000000000;	% dec 0 %
-092:	00000000000101000110100000100001;	% dec 1337377 %
-096:	00000001100011010110000000100001;	% dec 26042401 %
-100:	00000000000011000111000010000000;	% dec 815232 %
-104:	10001111110101010000000000000000;	% dec 2413101056 %
+092:	00010010101000000000000000000110;	% dec 312475654 %
+096:	00000000000000000000000000000000;	% dec 0 %
+100:	10001111110101100000000000001100;	% dec -1881800692 %
+104:	10001111110101110000000000000100;	% dec -1881735164 %
 108:	00000000000000000000000000000000;	% dec 0 %
-112:	00000011100011100111000000100001;	% dec 59666465 %
-116:	10101101110101010000000000000000;	% dec 2916417536 %
-120:	10001111110100110000000000000100;	% dec 2412969988 %
-124:	00000000000000000000000000000000;	% dec 0 %
-128:	00000000000100110111100000100001;	% dec 1275937 %
-132:	00000000000011111100000001000000;	% dec 1032256 %
-136:	10001111110101000000000000001000;	% dec 2413035528 %
+112:	00010110110101110000000000000101;	% dec 383188997 %
+116:	00000000000000000000000000000000;	% dec 0 %
+120:	00100100000100000000000000000000;	% dec 605028352 %
+124:	10101111110100000000000000010100;	% dec -1345322988 %
+128:	00001000000000000000000000110111;	% dec 134217783 %
+132:	00000000000000000000000000000000;	% dec 0 %
+136:	10001111110100010000000000010000;	% dec -1882128368 %
 140:	00000000000000000000000000000000;	% dec 0 %
-144:	00000000000101000100000000100001;	% dec 1327137 %
-148:	00000011000010001100000000100001;	% dec 50905121 %
-152:	00000000000110000100100010000000;	% dec 1591424 %
-156:	10001111110101010000000000000000;	% dec 2413101056 %
+144:	00010010001000000000000000000110;	% dec 304087046 %
+148:	00000000000000000000000000000000;	% dec 0 %
+152:	10001111110100100000000000010000;	% dec -1882062832 %
+156:	10001111110100110000000000001000;	% dec -1881997304 %
 160:	00000000000000000000000000000000;	% dec 0 %
-164:	00000011100010010100100000100001;	% dec 59328545 %
-168:	10101101001101010000000000010000;	% dec 2905931792 %
-172:	10001111110101010000000000000000;	% dec 2413101056 %
-176:	00000000000000000000000000000000;	% dec 0 %
-180:	00100110101101010000000000000001;	% dec 649396225 %
-184:	10101111110101010000000000000000;	% dec 2949971968 %
-188:	10001111110100000000000000001000;	% dec 2412773384 %
+164:	00010110010100110000000000000101;	% dec 374538245 %
+168:	00000000000000000000000000000000;	% dec 0 %
+172:	00100100000101000000000000000000;	% dec 605290496 %
+176:	10101111110101000000000000010100;	% dec -1345060844 %
+180:	00001000000000000000000000110111;	% dec 134217783 %
+184:	00000000000000000000000000000000;	% dec 0 %
+188:	10001111110101010000000000000000;	% dec -1881866240 %
 192:	00000000000000000000000000000000;	% dec 0 %
-196:	00100110000100000000000000000001;	% dec 638582785 %
-200:	10101111110100000000000000001000;	% dec 2949644296 %
-204:	10001111110100010000000000001000;	% dec 2412838920 %
+196:	00000000000101011011000000100001;	% dec 1421345 %
+200:	10101111110101100000000000010100;	% dec -1344929772 %
+204:	10001111110101010000000000000000;	% dec -1881866240 %
 208:	00000000000000000000000000000000;	% dec 0 %
-212:	00100100000011010000000000000010;	% dec 604831746 %
-216:	00000010001011010001000000100011;	% dec 36507683 %
-220:	00000100010000001111111111011001;	% dec 71368665 %
+212:	00100110101101010000000000000001;	% dec 649396225 %
+216:	10101111110101010000000000000000;	% dec -1344995328 %
+220:	10001111110101110000000000001100;	% dec -1881735156 %
 224:	00000000000000000000000000000000;	% dec 0 %
-228:	10001111110100100000000000000100;	% dec 2412904452 %
-232:	00000000000000000000000000000000;	% dec 0 %
-236:	00100110010100100000000000000001;	% dec 642908161 %
-240:	10101111110100100000000000000100;	% dec 2949775364 %
-244:	10001111110101100000000000000100;	% dec 2413166596 %
-248:	00000000000000000000000000000000;	% dec 0 %
-252:	00100100000011100000000000000010;	% dec 604897282 %
-256:	00000010110011100001000000100011;	% dec 47058979 %
-260:	00000100010000001111111111001011;	% dec 71368651 %
-264:	00000000000000000000000000000000;	% dec 0 %
-268:	00100111101111010000000000001100;	% dec 666697740 %
-272:	00000000000111011111000000100001;	% dec 1962017 %
-276:	00000011111000000000000000001000;	% dec 65011720 %
-280:	00100111101111011111111111110000;	% dec 666763248 %
-284:	00000000000111011111000000100001;	% dec 1962017 %
-288:	00100100000100000000000000000000;	% dec 605028352 %
-292:	10101111110100000000000000000000;	% dec 2949644288 %
-296:	00100100000100010000000000000000;	% dec 605093888 %
-300:	10101111110100010000000000000100;	% dec 2949709828 %
-304:	00001000000000000000000010011011;	% dec 134217883 %
+228:	00000000000101110100100000100001;	% dec 1525793 %
+232:	00000000000010010101000010000000;	% dec 610432 %
+236:	10001111110100000000000000010000;	% dec -1882193904 %
+240:	00000000000000000000000000000000;	% dec 0 %
+244:	00000000000100000101100000100001;	% dec 1071137 %
+248:	00000001010010110101000000100001;	% dec 21712929 %
+252:	00000000000010100110000010000000;	% dec 680064 %
+256:	10001111110100010000000000010100;	% dec -1882128364 %
+260:	00000000000000000000000000000000;	% dec 0 %
+264:	00000011100011000110000000100001;	% dec 59531297 %
+268:	10101101100100010000000000000000;	% dec -1383006208 %
+272:	10001111110100000000000000010000;	% dec -1882193904 %
+276:	00000000000000000000000000000000;	% dec 0 %
+280:	00100110000100000000000000000001;	% dec 638582785 %
+284:	10101111110100000000000000010000;	% dec -1345322992 %
+288:	10001111110100110000000000010000;	% dec -1881997296 %
+292:	00000000000000000000000000000000;	% dec 0 %
+296:	00100100000011100000000000000100;	% dec 604897284 %
+300:	00000010011011100001000000100011;	% dec 40767523 %
+304:	00000100010000001111111111001000;	% dec 71368648 %
 308:	00000000000000000000000000000000;	% dec 0 %
-312:	00100100000100100000000000000000;	% dec 605159424 %
-316:	10101111110100100000000000001000;	% dec 2949775368 %
-320:	00001000000000000000000010010001;	% dec 134217873 %
-324:	00000000000000000000000000000000;	% dec 0 %
-328:	00100100000100110000000000000000;	% dec 605224960 %
-332:	10101111110100110000000000001100;	% dec 2949840908 %
-336:	00001000000000000000000001111000;	% dec 134217848 %
-340:	00000000000000000000000000000000;	% dec 0 %
-344:	10001111110101000000000000000100;	% dec 2413035524 %
+312:	10001111110101000000000000001100;	% dec -1881931764 %
+316:	00000000000000000000000000000000;	% dec 0 %
+320:	00100110100101000000000000000001;	% dec 647233537 %
+324:	10101111110101000000000000001100;	% dec -1345060852 %
+328:	10001111110101100000000000001100;	% dec -1881800692 %
+332:	00000000000000000000000000000000;	% dec 0 %
+336:	00100100000110000000000000000100;	% dec 605552644 %
+340:	00000010110110000001000000100011;	% dec 47714339 %
+344:	00000100010000001111111110111010;	% dec 71368634 %
 348:	00000000000000000000000000000000;	% dec 0 %
-352:	00000000000101000110000000100001;	% dec 1335329 %
-356:	00000000000011000110100001000000;	% dec 813120 %
-360:	10001111110101010000000000001100;	% dec 2413101068 %
-364:	00000000000000000000000000000000;	% dec 0 %
-368:	00000000000101010111000000100001;	% dec 1404961 %
-372:	00000001101011100110100000100001;	% dec 28207137 %
-376:	00000000000011010111100010000000;	% dec 882816 %
-380:	00000011100011110111100000100001;	% dec 59734049 %
-384:	10001101111110000000000000000000;	% dec 2381840384 %
-388:	10001111110101010000000000001100;	% dec 2413101068 %
-392:	00000000000000000000000000000000;	% dec 0 %
-396:	00000000000101010100000000100001;	% dec 1392673 %
-400:	00000000000010000100100001000000;	% dec 542784 %
-404:	10001111110101110000000000001000;	% dec 2413232136 %
-408:	00000000000000000000000000000000;	% dec 0 %
-412:	00000000000101110101000000100001;	% dec 1527841 %
-416:	00000001001010100100100000100001;	% dec 19548193 %
-420:	00000000000010010101100010000000;	% dec 612480 %
-424:	00000011100010110101100000100001;	% dec 59463713 %
-428:	10001101011100000000000000010000;	% dec 2372927504 %
-432:	00000000000000000000000000000000;	% dec 0 %
-436:	00000000000100000110000000100001;	% dec 1073185 %
-440:	00000011000011000111000000011000;	% dec 51146776 %
-444:	00000000000000000111000000010010;	% dec 28690 %
-448:	10001111110100010000000000000000;	% dec 2412838912 %
-452:	00000000000000000000000000000000;	% dec 0 %
-456:	00000010001011101000100000100001;	% dec 36603937 %
-460:	10101111110100010000000000000000;	% dec 2949709824 %
-464:	10001111110100100000000000001100;	% dec 2412904460 %
-468:	00000000000000000000000000000000;	% dec 0 %
-472:	00100110010100100000000000000001;	% dec 642908161 %
-476:	10101111110100100000000000001100;	% dec 2949775372 %
-480:	10001111110100110000000000001100;	% dec 2412969996 %
-484:	00000000000000000000000000000000;	% dec 0 %
-488:	00100100000011110000000000000010;	% dec 604962818 %
-492:	00000010011011110001000000100011;	% dec 40833059 %
-496:	00000100010000001111111111011001;	% dec 71368665 %
-500:	00000000000000000000000000000000;	% dec 0 %
-504:	10001111110101000000000000000100;	% dec 2413035524 %
-508:	00000000000000000000000000000000;	% dec 0 %
-512:	00000000000101000100000000100001;	% dec 1327137 %
-516:	00000000000010000101000001000000;	% dec 544832 %
-520:	10001111110101100000000000001000;	% dec 2413166600 %
+352:	00100111101111010000000000011000;	% dec 666697752 %
+356:	00000000000111011111000000100001;	% dec 1962017 %
+360:	00000011111000000000000000001000;	% dec 65011720 %
+364:	00100111101111011111111111101100;	% dec 666763244 %
+368:	00000000000111011111000000100001;	% dec 1962017 %
+372:	00100100000100000000000000000011;	% dec 605028355 %
+376:	10101111110100000000000000000000;	% dec -1345323008 %
+380:	00100100000100010000000000000011;	% dec 605093891 %
+384:	10101111110100010000000000000100;	% dec -1345257468 %
+388:	00100100000100100000000000000001;	% dec 605159425 %
+392:	10101111110100100000000000001000;	% dec -1345191928 %
+396:	00001000000000000000000011100100;	% dec 134217956 %
+400:	00000000000000000000000000000000;	% dec 0 %
+404:	00100100000100110000000000000001;	% dec 605224961 %
+408:	10101111110100110000000000001100;	% dec -1345126388 %
+412:	00001000000000000000000011011010;	% dec 134217946 %
+416:	00000000000000000000000000000000;	% dec 0 %
+420:	10001111110101000000000000001000;	% dec -1881931768 %
+424:	00000000000000000000000000000000;	% dec 0 %
+428:	00100110100011011111111111111111;	% dec 646840319 %
+432:	00000000000011010111000010000000;	% dec 880768 %
+436:	10001111110101010000000000001100;	% dec -1881866228 %
+440:	00000000000000000000000000000000;	% dec 0 %
+444:	00000000000101010111100000100001;	% dec 1407009 %
+448:	00000001110011110111000000100001;	% dec 30371873 %
+452:	00000000000011101100000010000000;	% dec 966784 %
+456:	00000011100110001100000000100001;	% dec 60342305 %
+460:	10001111000101100000000000000000;	% dec -1894383616 %
+464:	00000000000000000000000000000000;	% dec 0 %
+468:	00000000000101101011100000100001;	% dec 1488929 %
+472:	10101111110101110000000000010000;	% dec -1344864240 %
+476:	10001111110101000000000000001000;	% dec -1881931768 %
+480:	00000000000000000000000000000000;	% dec 0 %
+484:	00000000000101000100000000100001;	% dec 1327137 %
+488:	00000000000010000100100010000000;	% dec 542848 %
+492:	10001111110101010000000000001100;	% dec -1881866228 %
+496:	00000000000000000000000000000000;	% dec 0 %
+500:	00100110101010111111111111111111;	% dec 648806399 %
+504:	00000001001010110100100000100001;	% dec 19613729 %
+508:	00000000000010010110000010000000;	% dec 614528 %
+512:	00000011100011000110000000100001;	% dec 59531297 %
+516:	10001101100011010000000000000000;	% dec -1920139264 %
+520:	10001111110101110000000000010000;	% dec -1881735152 %
 524:	00000000000000000000000000000000;	% dec 0 %
-528:	00000000000101100100100000100001;	% dec 1460257 %
-532:	00000001010010010101000000100001;	% dec 21581857 %
-536:	00000000000010100101100010000000;	% dec 678016 %
-540:	10001111110101010000000000000000;	% dec 2413101056 %
-544:	00000000000000000000000000000000;	% dec 0 %
-548:	00000011100010110101100000100001;	% dec 59463713 %
-552:	10101101011101010000000000100000;	% dec 2910126112 %
-556:	00100100000101010000000000000000;	% dec 605356032 %
-560:	10101111110101010000000000000000;	% dec 2949971968 %
-564:	10001111110100000000000000001000;	% dec 2412773384 %
-568:	00000000000000000000000000000000;	% dec 0 %
-572:	00100110000100000000000000000001;	% dec 638582785 %
-576:	10101111110100000000000000001000;	% dec 2949644296 %
-580:	10001111110100010000000000001000;	% dec 2412838920 %
+528:	00000010111011011011100000100001;	% dec 49133601 %
+532:	10101111110101110000000000010000;	% dec -1344864240 %
+536:	10001111110101000000000000001000;	% dec -1881931768 %
+540:	00000000000000000000000000000000;	% dec 0 %
+544:	00000000000101000111100000100001;	% dec 1341473 %
+548:	00000000000011110111000010000000;	% dec 1011840 %
+552:	10001111110101010000000000001100;	% dec -1881866228 %
+556:	00000000000000000000000000000000;	% dec 0 %
+560:	00100110101010000000000000000001;	% dec 648544257 %
+564:	00000001110010000111000000100001;	% dec 29913121 %
+568:	00000000000011100101000010000000;	% dec 938112 %
+572:	00000011100010100101000000100001;	% dec 59396129 %
+576:	10001101010010110000000000000000;	% dec -1924464640 %
+580:	10001111110101110000000000010000;	% dec -1881735152 %
 584:	00000000000000000000000000000000;	% dec 0 %
-588:	00100100000011100000000000000010;	% dec 604897282 %
-592:	00000010001011100001000000100011;	% dec 36573219 %
-596:	00000100010000001111111110111100;	% dec 71368636 %
+588:	00000010111010111011100000100001;	% dec 49002529 %
+592:	10101111110101110000000000010000;	% dec -1344864240 %
+596:	10001111110101000000000000001000;	% dec -1881931768 %
 600:	00000000000000000000000000000000;	% dec 0 %
-604:	10001111110100100000000000000100;	% dec 2412904452 %
-608:	00000000000000000000000000000000;	% dec 0 %
-612:	00100110010100100000000000000001;	% dec 642908161 %
-616:	10101111110100100000000000000100;	% dec 2949775364 %
-620:	10001111110100110000000000000100;	% dec 2412969988 %
-624:	00000000000000000000000000000000;	% dec 0 %
-628:	00100100000011110000000000000010;	% dec 604962818 %
-632:	00000010011011110001000000100011;	% dec 40833059 %
-636:	00000100010000001111111110101110;	% dec 71368622 %
-640:	00000000000000000000000000000000;	% dec 0 %
-644:	00100111101111010000000000010000;	% dec 666697744 %
-648:	00000000000111011111000000100001;	% dec 1962017 %
-652:	00000011111000000000000000001000;	% dec 65011720 %
+604:	00100110100011000000000000000001;	% dec 646709249 %
+608:	00000000000011000110100010000000;	% dec 813184 %
+612:	10001111110101010000000000001100;	% dec -1881866228 %
+616:	00000000000000000000000000000000;	% dec 0 %
+620:	00000000000101010111100000100001;	% dec 1407009 %
+624:	00000001101011110110100000100001;	% dec 28272673 %
+628:	00000000000011011100000010000000;	% dec 901248 %
+632:	00000011100110001100000000100001;	% dec 60342305 %
+636:	10001111000010000000000000000000;	% dec -1895301120 %
+640:	10001111110101110000000000010000;	% dec -1881735152 %
+644:	00000000000000000000000000000000;	% dec 0 %
+648:	00000010111010001011100000100001;	% dec 48805921 %
+652:	10101111110101110000000000010000;	% dec -1344864240 %
+656:	10001111110101000000000000001000;	% dec -1881931768 %
+660:	00000000000000000000000000000000;	% dec 0 %
+664:	00000000000101000111000000100001;	% dec 1339425 %
+668:	00000000000011100101000010000000;	% dec 938112 %
+672:	10001111110101010000000000001100;	% dec -1881866228 %
+676:	00000000000000000000000000000000;	% dec 0 %
+680:	00000000000101010101100000100001;	% dec 1398817 %
+684:	00000001010010110101000000100001;	% dec 21712929 %
+688:	00000000000010100100100010000000;	% dec 673920 %
+692:	00000011100010010100100000100001;	% dec 59328545 %
+696:	10001101001100110000000000000000;	% dec -1926037504 %
+700:	00000000000000000000000000000000;	% dec 0 %
+704:	00000000000100110110000000100001;	% dec 1269793 %
+708:	00100100000011110000000000000100;	% dec 604962820 %
+712:	00000001100011110110100000011000;	% dec 26175512 %
+716:	00000000000000000110100000010010;	% dec 26642 %
+720:	10001111110101110000000000010000;	% dec -1881735152 %
+724:	00000000000000000000000000000000;	% dec 0 %
+728:	00000010111011011011100000100011;	% dec 49133603 %
+732:	10101111110101110000000000010000;	% dec -1344864240 %
+736:	10001111110101110000000000010000;	% dec -1881735152 %
+740:	00000000000000000000000000000000;	% dec 0 %
+744:	00100100000110000000000011111111;	% dec 605552895 %
+748:	00000010111110000001000000100011;	% dec 49811491 %
+752:	00011000010000000000000000000101;	% dec 406847493 %
+756:	00000000000000000000000000000000;	% dec 0 %
+760:	00100100000101100000000011111111;	% dec 605421823 %
+764:	10101111110101100000000000010000;	% dec -1344929776 %
+768:	00001000000000000000000011001001;	% dec 134217929 %
+772:	00000000000000000000000000000000;	% dec 0 %
+776:	10001111110100000000000000010000;	% dec -1882193904 %
+780:	00000000000000000000000000000000;	% dec 0 %
+784:	00000010000000000001000000100011;	% dec 33558563 %
+788:	00000100010000010000000000000011;	% dec 71368707 %
+792:	00000000000000000000000000000000;	% dec 0 %
+796:	00100100000100010000000000000000;	% dec 605093888 %
+800:	10101111110100010000000000010000;	% dec -1345257456 %
+804:	10001111110100100000000000001000;	% dec -1882062840 %
+808:	00000000000000000000000000000000;	% dec 0 %
+812:	00000000000100100101000000100001;	% dec 1200161 %
+816:	00000000000010100100100010000000;	% dec 673920 %
+820:	10001111110101000000000000001100;	% dec -1881931764 %
+824:	00000000000000000000000000000000;	% dec 0 %
+828:	00000000000101000110000000100001;	% dec 1335329 %
+832:	00000001001011000100100000100001;	% dec 19679265 %
+836:	00000000000010010111100010000000;	% dec 620672 %
+840:	10001111110101010000000000010000;	% dec -1881866224 %
+844:	00000000000000000000000000000000;	% dec 0 %
+848:	00000011100011110111100000100001;	% dec 59734049 %
+852:	10101101111101010000000001000000;	% dec -1376452544 %
+856:	10001111110101000000000000001100;	% dec -1881931764 %
+860:	00000000000000000000000000000000;	% dec 0 %
+864:	00100110100101000000000000000001;	% dec 647233537 %
+868:	10101111110101000000000000001100;	% dec -1345060852 %
+872:	10001111110101110000000000001100;	% dec -1881735156 %
+876:	10001111110101100000000000000100;	% dec -1881800700 %
+880:	00000000000000000000000000000000;	% dec 0 %
+884:	00000010111101100001000000100011;	% dec 49680419 %
+888:	00000100010000001111111110001010;	% dec 71368586 %
+892:	00000000000000000000000000000000;	% dec 0 %
+896:	10001111110100000000000000001000;	% dec -1882193912 %
+900:	00000000000000000000000000000000;	% dec 0 %
+904:	00100110000100000000000000000001;	% dec 638582785 %
+908:	10101111110100000000000000001000;	% dec -1345323000 %
+912:	10001111110100010000000000001000;	% dec -1882128376 %
+916:	10001111110100100000000000000000;	% dec -1882062848 %
+920:	00000000000000000000000000000000;	% dec 0 %
+924:	00000010001100100001000000100011;	% dec 36835363 %
+928:	00000100010000001111111101111100;	% dec 71368572 %
+932:	00000000000000000000000000000000;	% dec 0 %
+936:	00100111101111010000000000010100;	% dec 666697748 %
+940:	00000000000111011111000000100001;	% dec 1962017 %
+944:	00000011111000000000000000001000;	% dec 65011720 %
 END;

+ 47 - 187
test/MemoryJUnitTest.java

@@ -4,10 +4,9 @@
  * and open the template in the editor.
  */
 
-import API.Utils;
+import junit.framework.Assert;
 import org.junit.After;
 import org.junit.AfterClass;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -44,21 +43,38 @@ public class MemoryJUnitTest {
     }
 
     @Test
-    public void WriteByte() throws Exception {
-        String bd = "00000010";
-        memory.WB(bd);
-        Assert.assertEquals(bd, memory.RB(0));
+    public void WriteBinaryByte() throws Exception {
+//        System.out.println(Long.toBinaryString(2L));
+//        System.out.println(Long.toBinaryString(2L));
+        Long value = -3L;
+        memory.W(0L, Long.toBinaryString(value), 4);
+        Assert.assertEquals(value, memory.ReadLong(0L, 4));
+
+        value = 3L;
+        memory.W(0L, Long.toBinaryString(value), 4);
+        Assert.assertEquals(value, memory.ReadLong(0L, 4));
+
+//        System.out.println(Long.toBinaryString(-3L));
+//        System.out.println(Long.parseUnsignedLong(Long.toBinaryString(-3L), 2));
+//        System.out.println(Long.parseUnsignedLong("11111111111111111111111111111101", 2));
+//        System.out.println(Long.parseUnsignedLong("1111111111111111111111111111111111111111111111111111111111111101", 2));
     }
 
-    @Test
-    public void WriteByteAddressed() throws Exception {
-        String bd = "00000010";
-        Long address = 16L;
-        memory.WB(address, bd);
-        Assert.assertEquals(bd, memory.RB(address));
-    }
+//    @Test
+//    public void WriteByte() throws Exception {
+//        String bd = "00000010";
+//        memory.WB(bd);
+//        Assert.assertEquals(bd, memory.RB(0));
+//    }
 //
 //    @Test
+//    public void WriteByteAddressed() throws Exception {
+//        String bd = "00000010";
+//        Long address = 16L;
+//        memory.WB(address, bd);
+//        Assert.assertEquals(bd, memory.RB(address));
+//    }
+//    @Test
 //    public void WriteMultByteAddressed() throws Exception {
 //        Long value = 14030L;
 //
@@ -69,182 +85,26 @@ public class MemoryJUnitTest {
 //        // Lê 4 bytes a partir do endereco 16 -> converte binario para long
 //        Assert.assertEquals(value, memory.ReadLong(address, 4));
 //    }
-
-    @Test
-    public void WriteNegativeValueAddressed() throws Exception {
-        String bin = Long.toBinaryString(3L);
-        printOneAndTwosComplement(Utils.Pad(32, bin));
-        bin = Long.toBinaryString(-3L);
-        printOneAndTwosComplement(Utils.Pad(32, bin));
-//        System.out.println("2c:" + findTwoscomplement(new StringBuffer(Long.toBinaryString(value))));
-        //        convertStringToDecimal(
-        //                findTwoscomplement(new StringBuffer(Long.toBinaryString(value)))
-        //        );
-        // Escreve 4 bytes a partir do endereco 16
-        //        memory.W(address, Long.toBinaryString(value), 4);
-        // Lê 4 bytes a partir do endereco 16 -> converte binario para long
-        //        Assert.assertEquals(value, memory.ReadLong(address, 4));
-    }
-
-    @Test
-    public void WriteInvalidAddress() throws Exception {
-        boolean result = false;
-        try {
-            String bd = "00000010";
-            Long address = 17000L;
-            memory.WB(address, bd);
-        } catch (Exception e) {
-            result = true;
-        }
-        Assert.assertTrue(result);
-    }
-
-    // Print 1's and 2's complement of binary number
-// represented by "bin"
-    public static void printOneAndTwosComplement(String bin) {
-        int n = bin.length();
-        int i;
-
-        String ones = "";
-        StringBuilder twos;
-
-        //  for ones complement flip every bit
-        for (i = 0; i < n; i++) {
-            ones += flip(bin.charAt(i));
-        }
-        System.out.println("Bin b:" + bin);
-        System.out.println("One b:" + ones);
-
-        twos = new StringBuilder(Long.toBinaryString(Long.parseLong(ones, 2) + 1L));
-
-        System.out.println("Two b:" + twos);
-//        for (i = n - 1; i >= 0; i--) {
-        for (i = 0; i < n; i++) {
-            if (ones.charAt(i) == '1') {
-                twos.setCharAt(i, '0');
-            } else {
-                twos.setCharAt(i, '1');
-                break;
-            }
-        }
-        System.out.println("Two a:" + twos);
-        // If No break : all are 1  as in 111  or  11111;
-        // in such case, add extra 1 at beginning
-        //        if (i == -1) {
-        //            twos = '1' + twos;
-        //        }
-//        System.out.println("1's complement: " + ones);
-//        System.out.println("2's complement: " +);
-    }
-
-    // Returns '0' for '1' and '1' for '0'
-    public static char flip(char c) {
-        return (c == '0') ? '1' : '0';
-    }
-//
-//    static String findTwoscomplement(StringBuffer str) {
-//        int n = str.length();
-//
-//        // Traverse the string to get first '1' from
-//        // the last of string
-//        int i;
-//        for (i = n - 1; i >= 0; i--) {
-//            if (str.charAt(i) == '1') {
-//                break;
-//            }
-//        }
-//
-//        // If there exists no '1' concat 1 at the
-//        // starting of string
-//        if (i == -1) {
-//            return "1" + str;
-//        }
-//
-//        // Continue traversal after the position of
-//        // first '1'
-//        for (int k = i - 1; k >= 0; k--) {
-//            //Just flip the values
-//            if (str.charAt(k) == '1') {
-//                str.replace(k, k + 1, "0");
-//            } else {
-//                str.replace(k, k + 1, "1");
-//            }
-//        }
-//
-//        // return the modified string
-//        return str.toString();
-//    }
-//
-//    public static void convertStringToDecimal(String binary) {
-//        int decimal = 0;
 //
-//        int power = 0;
-//
-//        if (binary.charAt(0) == '1' && binary.length() == 32) {
-//
-//            StringBuilder builder = new StringBuilder();
-//
-//            for (int i = 0; i < binary.length(); i++) {
-//
-//                builder.append((binary.charAt(i) == '1' ? '0' : '1'));
-//
-//            }
-//
-//            while (binary.length() > 0) {
-//
-//                int temp = Integer
-//                        .parseInt(builder.charAt((binary.length()) - 1) + "");
-//                decimal += temp * Math.pow(2, power++);
-//                binary = binary.substring(0, binary.length() - 1);
-//
-//            }
-//
-//            System.out.println((decimal + 1) * (-1));
-//
-//        } else {
-//
-//            while (binary.length() > 0) {
-//                int temp = Integer
-//                        .parseInt(binary.charAt((binary.length()) - 1) + "");
-//                decimal += temp * Math.pow(2, power++);
-//                binary = binary.substring(0, binary.length() - 1);
-//            }
-//
-//            System.out.println(decimal);
-//
-//        }
+//    @Test
+//    public void WriteNegativeValueAddressed() throws Exception {
+//        Long value = -3L;
+//        Long address = 16L;
+//        // Escreve 4 bytes a partir do endereco 16
+//        memory.W(address, value, 4);
+//        // Lê 4 bytes a partir do endereco 16 -> converte binario para long
+//        Assert.assertEquals(value, memory.ReadLong(address, 4));
 //    }
-
-//    public static String TwosCompliment(String bin) {
-//        String twos = "", ones = "";
-//        System.out.println("bin:" + bin);
-//
-//        for (int i = 0; i < bin.length(); i++) {
-//            ones += flip(bin.charAt(i));
-//        }
-//
-//        int number0 = (int) Long.parseLong(ones, 2);
-//
-//        System.out.println("number0:" + number0);
-//
-//        StringBuilder builder = new StringBuilder(ones);
-//        boolean b = false;
-//
-//        for (int i = ones.length() - 1; i > 0; i--) {
-//            if (ones.charAt(i) == '1') {
-//                builder.setCharAt(i, '0');
-//            } else {
-//                builder.setCharAt(i, '1');
-//                b = true;
-//                break;
-//            }
-//        }
-//        if (!b) {
-//            builder.append("1", 0, 7);
+//    @Test
+//    public void WriteInvalidAddress() throws Exception {
+//        boolean result = false;
+//        try {
+//            String bd = "00000010";
+//            Long address = 17000L;
+//            memory.WB(address, bd);
+//        } catch (Exception e) {
+//            result = true;
 //        }
-//
-//        twos = builder.toString();
-//
-//        return twos;
+//        Assert.assertTrue(result);
 //    }
 }