Skip to content

Commit c32fc6d

Browse files
committed
Fixing Examples and Main.java
1 parent d64aafb commit c32fc6d

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

Subtraction

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//Program that subtracts from 10 to 0
2+
3+
//byte 0
4+
//Adding 10 to register 0
5+
ADD 0xFF0A 0xFF00 0x0000
6+
7+
//byte 6
8+
//If its one, jump to the end (byte 30
9+
JMP 0xFF1E 0xFF00 0x0000
10+
11+
//byte 12
12+
//If its not one, will continue here
13+
//Then subtract from register 0
14+
//And store the result on register 0
15+
SUB 0x0000 0xFF01 0x0000
16+
17+
//byte 18
18+
//Print the value on register 0
19+
PRNT 0x0000 0x0000 0x0000
20+
21+
//byte 24
22+
//Return to byte 6 to check if its one
23+
RET 0xFF06 0xFF00 0xFF00
24+
25+
//End
26+
//byte 30
27+
//This is the end in which the register 0 is one
28+
//Then subtract one more time, and then print
29+
SUB 0x0000 0xFF01 0x0000
30+
31+
//byte 36
32+
PRNT 0x0000 0x0000 0x0000

TestRet

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//0
2+
ADD 0xFF01 0x0000 0x0000
3+
//6
4+
PRNT 0x0000 0x0000 0x0000
5+
//12
6+
SUB 0xFF00 0xFF06 0x0001
7+
PRNT 0x0000 0x0000 0x0001
8+
RET 0xFF0C 0xFF00 0x0000

src/main/java/org/example/Main.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Main {
2121
put("JMP", 0x13);
2222
put("JMPR", 0x14);
2323
put("CALL", 0x15);
24+
put("CALLR", 0x16);
2425
put("RET", 0x17);
2526
put("PRNT", 0x18);
2627
}};
@@ -46,7 +47,7 @@ public static byte[] compilar(String arquivo){
4647
String[] linhas = arquivo.split("\n");
4748
for(String linha : linhas){
4849

49-
if(linha.contains("//"))
50+
if(linha.contains("//") || linha.replace(" ", "").isEmpty())
5051
continue;
5152

5253
System.out.println("Linha sendo processada: "+linha);

0 commit comments

Comments
 (0)