CPU0 工具鏈的主程式

程式作品

C 語言

Java

C#

JavaScript

常用函數

文字處理

遊戲程式

衛星定位

系統程式

資料結構

網路程式

自然語言

人工智慧

機率統計

資訊安全

等待完成

訊息

相關網站

參考文獻

最新修改

簡體版

English

[フレーム]

檔案:main.c

#include "Assembler.h" // 引用組譯器檔頭
#include "Compiler.h" // 引用編譯器檔頭
#define TEST 1 // 編譯目標 1: test
#define C0C 2 // 編譯目標 2: c0c
#define AS0 3 // 編譯目標 3: as0
#define VM0 4 // 編譯目標 4: vm0
void argError(char *msg) { // 處理參數錯誤的情況
 printf("%s\n", msg);
 exit(1);
}
int main(int argc, char *argv[]) { // 主程式開始
 char cFile0[]="test.c0", *cFile=cFile0; // 預設程式檔為 test.c0
 char asmFile0[]="test.asm0", *asmFile=asmFile0;// 預設組合語言為test.asm0
 char objFile0[]="test.obj0", *objFile=objFile0;// 預設目的檔為 test.obj0
#if TARGET==TEST // 如果編譯目標為 TEST
 ArrayTest(); // 測試陣列物件
 HashTableTest(); // 測試雜湊表物件
 OpTableTest(); // 測試指令表物件
 compile(cFile, asmFile); // 測試編譯器
 assemble(asmFile, objFile); // 測試組譯器
 runObjFile(objFile); // 測試虛擬機器
 checkMemory(); // 檢查記憶體使用狀況
#elif TARGET==C0C // 如果編譯目標為 C0C
 if (argc == 3) { // 如果有 3 個參數
 cFile=argv[1]; asmFile=argv[2]; // 設定參數
 } else // 否則
 argError("c0c <c0File> <asmFile>"); // 提示程式執行方法
 compile(cFile, asmFile); // 開始編譯
#elif TARGET==AS0 // 如果編譯目標為 AS0
 if (argc == 3) { // 如果有 3 個參數
 asmFile=argv[1]; objFile=argv[2]; // 設定參數
 } else // 否則
 argError("as0 <asmFile> <objFile>"); // 提示程式執行方法
 assemble(asmFile, objFile); // 開始組譯
#elif TARGET==VM0 // 如果編譯目標為 VM0
 if (argc == 2) // 如果有 2 個參數
 objFile=argv[1]; // 設定參數
 else // 否則
 argError("vm0 <objFile>"); // 提示程式執行方法
 runObjFile(objFile); // 開始執行 (虛擬機)
#endif
 system("pause"); // 暫停 (給 Dev C++ 使用的)
 return 0;
}

Facebook

[フレーム]

Facebook

[フレーム]

Wikidot

Post preview:

(will not be published)


本網頁的作者、授權與引用方式

作者
陳鍾誠,於金門大學資訊工程系,電子郵件:wt.ude.uqn|ccc#wt.ude.uqn|ccc,網站:http://ccckmit.wikidot.com
授權
本文採用創作共用 (Creative Common) 3.0 版的 姓名標示─非商業性─相同方式分享 授權條款,歡迎轉載或修改使用,但若做為商業使用時必須取得授權,引用本文時請參考下列格式。
中文版 (APA格式)
陳鍾誠 (20 Oct 2010 07:18),(網頁標題) CPU0 工具鏈的主程式,(網站標題) 陳鍾誠的網站,取自 http://ccckmit.wikidot.com/code:cpu0main ,網頁修改第 0 版。
英文版 (APA格式)
Chung-Chen Chen (20 Oct 2010 07:18), Retrieved from http://ccckmit.wikidot.com/code:cpu0main , Page Revision 0.
page revision: 0, last edited: 20 Oct 2010 07:18
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).
Notify administrators if there is objectionable content in this page.
Something does not work as expected? Find out what you can do.
General Wikidot.com documentation and help section.
Wikidot.com Terms of Service - what you can, what you should not etc.
Wikidot.com Privacy Policy.

AltStyle によって変換されたページ (->オリジナル) /