c
1.
(1)(4) .
. . . FORTRAN C PASCAL . . . . . (Compiler) (3),(4).
. 1 .() () (). Mini-Mini-Pascal (3)(5). .
. Mini-Mini-Pascal . .
: Mini-Mini-Pascal
1: .
1
()
1.1 (4),(5)
.
(Stack) .
. 2 (a) . . (SP) 1 . ( 2 (b)) ( 2 (c)). 1 1 .
(Push Down)
(Pop Up)
7
7
12
5
SP
SP
12
5
12
5
(a)
(b)
(c)
2: .
.
.
.
.
X+Y (X,Y)+ XY+ (1) . X Y +
2
SP
. X Y . , . , ..
XY (X,Y) XY (2) XY (X,Y) XY (3) X/Y (X,Y)/ XY/ (4)
.
.
A + (B C) D (5)
.. B C D A . . . A (B C) D .
(A, (BC)D)+ (6) . (B C) D B C D
(A, ((B C), D))+ (7) . B C
(A, ((B, C), D))+ (8) . ,
ABCD+ (9)
(5) . .. .. (9) B C BC D + A BC D (5) .
3
6
8
6
5
6
3
8
6
3
8
6
ABCD*+ ABCD*+ ABCD*+
(a) (b) (c)
*
ABCD*+ ABCD*+
(f) (g) (h)
ABCD*+
(d) (e)
+
ABCD*+
(i) (j)
10
5
6
10
5
6
50
6
50
6
56
3: .
.
.
.
.
3 A = 6, B = 8, C = 3, D = 10 (9) (a) (j) . .(a) A 6 . (b) B 8 .(c) C 3 .(d) B C 2 .(e)
4
. (f) D 10 .(g) 2 BC D 2 .(h) . (i) + A BC D 2 .(j) (9) 56 .
.
.
1.2
(1),(5) .
4 .
(). 0 .
0 PC 1 2
3
0 1 2 3
23 24 25
()
SP
4: .
. . 0 . . . .
5
Get Put L oad
L oad C onstant S tore
Add
S ubtract Multiply Divide
E qual Greater than Less than
Conditional Jump Unconditional Jump
GET X PUT X LOD X
LDC I
STR X
1: .
X . X . X .( SP SP + 1.)
I .( SP SP + 1.)
X
.( SP SP 1.)
ADD 2 SUB
1 0 .
0 K . K .
.(
ML T
DIVSPSP1.)
EQL 2 ( GRT S P S P 2. ) LES
CJP K
UJP K
. 26 0 25 . . .
14 1 . EQL, GRT, LES 1 0 . CJP .
. 5, 6 10 .
(a) GET 0 . 1 .(b) (f) .
6
0
1 PC 2 3 4 5
0 1 2
PC 3 4 5
0 1 2 3
PC 4 5
20
GET 0 LOD 0 LDC 10 ADD STR 0 PUT 0
0 1 2
SP 25
GET 0
LOD 0
GET 0 LOD 0 LDC 10 ADD STR 0 PUT 0
0
20
20
SP
1 2 25
0 1 2 25
LOD 0
LDC 10
20
GET 0 LOD 0 LDC 10 ADD STR 0 PUT 0
SP
10
20
LDC 10
ADD
5: .
7
0 1 2 25
0 1 2 25
0 1 2
20
GET 0 LOD 0 LDC 10 ADD STR 0 PUT 0
30
PC
0 1 2 3 4 5
0 1 2 3 4 5
0 1 2 3 4 5
SP
ADD
STR 0
30
GET 0 LOD 0 LDC 10 ADD STR 0 PUT 0
PC
SP
STR 0
PUT 0
30
30
GET 0 LOD 0 LDC 10 ADD STR 0 PUT 0
PC
SP 25
PUT 0
6: ().
8
GET 0 0 20 .
(b) LOD 0 . LOD 0 0 . 1 .(c) (e) .
(c) 10 LDC 10 . .
(d) ADD .ADD 2 . 30 . 2 2 1 1 .
(e) 0 STR 0 .
(f) 0 PUT 0 . 30 . .
1.3 Mini-Mini-Pascal Mini-Mini-Pascal
. Mini-Mini-Pascal
.
READ(L);
A:= 0; K:= 1;
WHILE K < L+1 DOA:= A+K; K:= K+1 ENDWHILE; WRITE(A). (6),(7) .READ := (6) .WHILE WHILE DO DO ENDWHILE .WRITE .1 .Mini-Mini-Pascal . .9.: 0123456789 10 ;: ABC Z 26 ();: ( ) + . / : ; < = > 13 .
READ, WRITE, WHILE, DO, ENDWHILE
5 . 1 26 . 32768 +32767 . 7, 8 (5),(6) .Mini-Mini-Pascal . . . ; .READ WRITE 1 . .
(program) .
;
READ ( ) WRITE ( )
: = DO
;
7: .
1.4 Mini-Mini-Pascal
Mini-Mini-Pascal
Mini-Mini-Pascal ..
9 SAMPLE1.PAS SAMPLE1.OBJ . 5, 6
(statement)
WHI L E
E NDWHI L E
10
(relational expression)
< = >
(simple expression) +
+
(term)
(factor)
* /
( )
(unsigned constant)
8: ().
11
. 10 .SAMPLE1.PAS . GET 0 0 . READ(A) .Mini-Mini-Pascal A Z 26 0 25 . A 0 . A:= A+10 1 4 4 ( 0 ).
10 . SAMPLE2.PAS . SAMPLE2.OBJ . . 1 A, K, L 0, 10, 11 .WHILE 5 9 10 CJP 20 19 UJP 5 ().
SAMPLE1.PAS
READ(A); A:= A+10; WRITE(A).
SAMPLE1.OBJ
GET 0
LOD 0
LDC 10
ADD
STR 0
PUT 0
9: 1. 12
SAMPLE2.PAS
READ(L);
A:= 0; K:= 1; WHILE K < L+1 DOA:= A+K;K:= K+1 ENDWHILE; WRITE(A).SAMPLE2.OBJGET 11LDC 0STR 0LDC 1STR 10LOD 10LOD 11LDC 1ADDLESCJP 20LOD 0LOD 10ADDSTR 0LOD 10LDC 1ADDSTR 10UJP 5PUT 0 10: 2.1.5 Mini-Mini-Pascal (3)(5) . 11 (3) .(a) (3) (b) .(a) (lexical analyze) . (token) . . . . (3) . ().. .13(a) 11: . . 11 (b) . (a) .Mini-Mini-Pascal . . (3) . . ..Mini- Mini-Pascal A Z 26 . . .14(b) Mini-Mini-Pascal 1.6 1. ..2. . 3. .(1) :1994. (2) :1993.(3) A. V. Aho, J. D. Ullman / :1986. (4) :1981.(5) :1993.(6) K. Jensen, N. Wirth / :PASCAL1981. (7) :TURBO Pascal 1987.15
Reviews
There are no reviews yet.