컴 파일 원리 프로 그래 밍 실천 (9) 컴 파일 및 테스트

1424 단어
1. MinGW 에 따라 다운로드 페이지 는 다음 과 같 습 니 다.http://sourceforge.net/projects/mingw/files/latest/download?source=files설치 할 때 모두 설치 하 는 것 이 좋 습 니 다. 그러면 최신 g + 컴 파일 러 를 가지 고 새로운 기능 을 많이 지원 합 니 다.
2. Makefile 과 main. cpp 파일 을 같은 디 렉 터 리 에 복사 합 니 다.
3. MinGW Shell 에서 코드 가 있 는 디 렉 터 리 에 cd 명령 으로 들 어가 make 명령 을 실행 합 니 다.
MinGW 경로 가 Liux 와 유사 하 므 로 cd / f / projects 와 유사 한 명령 으로 디 렉 터 리 에 들 어가 야 합 니 다.
4. 1. txt 파일 을 준비 합 니 다. 내용 은?
const a =10;
var b,c;
procedure p;
	begin
		c:= b+a;
	end;
begin
	read(b);
	while b#0 do
		begin
			call p
			;write(2*c)
			;read(b)
		end
end
.	

5. 실행. / main. exe 는 전체 운행 과정 이 다음 과 같다.
$ ./main.exe
input file?  1.txt
list object code ?Y
   0 const a =10;
   1 var b,c;
   1 procedure p;
   1    begin
   3            c:= b+a;
   7    end;
2    int 0  3
3    lod 1  3
4    lit 0  10
5    opr 0  2
6    sto 1  4
7    opr 0  0
8    begin
9       read(b);
11      while b#0 do
15              begin
15                      call p
16                      ;write(2*c)
20                      ;read(b)
23              end
23   end
24   .
8    int 0  5
9    opr 0  16
10   sto 0  3
11   lod 0  3
12   lit 0  0
13   opr 0  9
14   jpc 0  24
15   cal 0  2
16   lit 0  2
17   lod 0  4
18   opr 0  4
19   opr 0  14
20   opr 0  15
21   opr 0  16
22   sto 0  3
23   jmp 0  11
24   opr 0  0
start pl0
?2
24
?4
28
?0

좋은 웹페이지 즐겨찾기