Skip to content

Instantly share code, notes, and snippets.

@bcho
Created November 3, 2014 06:04
Show Gist options
  • Select an option

  • Save bcho/8f5b97b19dc57d915d1f to your computer and use it in GitHub Desktop.

Select an option

Save bcho/8f5b97b19dc57d915d1f to your computer and use it in GitHub Desktop.
//------------------------------------------------------------------------
// Start compiling program.
// 11/03/14 14:00:05
//------------------------------------------------------------------------
1 PROGRAM MAIN;
2 CONST A = 2;
3 VAR B, C;
4 BEGIN
5 C := '5';
6 write(C);
7
8 B := 5;
9
10 if B >= 0 && A <= B && 1 then
11 write(1)
12 else
13 write(2);
14
15 while B >= 0 && A <= B && 1 do
16 begin
17 write(B);
18 B := B - 1
19 end
20
21 END.
0 HLT 0 0
1 JMP 0 2
2 INI 0 5
3 LIT 2 53
4 STO 0 4
5 LOD 0 4
6 OPR 0 14
7 LIT 1 5
8 STO 0 3
9 LOD 0 3
10 LIT 1 0
11 OPR 0 11
12 LIT 0 2
13 LOD 0 3
14 OPR 0 13
15 OPR 0 17
16 LIT 1 1
17 OPR 0 17
18 JPC 0 22
19 LIT 1 1
20 OPR 0 14
21 JMP 0 24
22 LIT 1 2
23 OPR 0 14
24 LOD 0 3
25 LIT 1 0
26 OPR 0 11
27 LIT 0 2
28 LOD 0 3
29 OPR 0 13
30 OPR 0 17
31 LIT 1 1
32 OPR 0 17
33 JPC 0 41
34 LOD 0 3
35 OPR 0 14
36 LOD 0 3
37 LIT 1 1
38 OPR 0 3
39 STO 0 3
40 JMP 0 24
41 OPR 0 0
//------------------------------------------------------------------------
// Compile finish.
// 11/03/14 14:00:05
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Start executing program.
// 11/03/14 14:00:05
//------------------------------------------------------------------------
5
error: 0
Interpret: unsupport type for OPR 13
5
Dumping machine state:
P: 15 T: 8
data type: addr, value: 0
data type: addr, value: 0
data type: addr, value: 0
data type: addr, value: 0
data type: int, value: 5
data type: char, value: 53
data type: int, value: 1
data type: addr, value: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment