150 likes | 347 Views
PCSPIM 的介紹. 王昱偉. PCSPIM 的介紹. Download and Installation Window Interface and Console Interface Simulator Setting 程式結構參數與 Data Type System Call Program Layout Run program. Download and Installation. 下載 pcspim 壓縮檔並解壓縮 執行 setup.exe 並安裝 執行 pcspim.exe. Window Interface. Registers. Text.
E N D
PCSPIM的介紹 王昱偉
PCSPIM的介紹 Download and Installation Window Interface and Console Interface Simulator Setting 程式結構參數與Data Type System Call Program Layout Run program
Download and Installation • 下載pcspim壓縮檔並解壓縮 • 執行setup.exe並安裝 • 執行pcspim.exe
Window Interface Registers Text Data Messages
Window Interface • Registers 顯示MIPS中所有register的值 • Text 顯示所有指令的位址 • Data 顯示load進來的資料和Stack中的資料 • Message 顯示pcspim的一些資訊,包含error message
Console Interface • 程式執行的畫面
Simulator Setting • 用圖中設定即可,一般不需要更動
Simulator Usage • Simulator Clear Registers:將registers中的資料 清除 Reinitialize:重新初始化simulator Reload:重新讀取檔案 Go:執行程式 BreakPoint:可設定程式執行的中斷點 Single/Multiple Step:可用在debug時
程式結構參數與Data Type • .text 代表後面的是程式的本文 • .globl 程式開始的地方 • main 主程式 • .data 設定要用到的資料 • label 定位程式的某一個地方,可用在迴圈等 • .word , .half: 32/16 bit integer • .byte: 8 bit integer (類似C語言中的char) • ascii,asciiz : string (字串) • .double , .float 浮點數 • newline(“\n”) , tab(“\t”)
System Call • 可以呼叫系統提供的system call read , print等 • 常用兩個register $v0 指定要用的system call種類 接收read的資料 $a0 儲存要print的資料
System Call • Example 讀入一個integer li $v0 , 5 #指定system call的種類 syscall #執行system call 輸出一個string 假設msg代表一個字串 li $v0 , 4 #指定system call的種類 la $a0 , msg #將字串存入$a0 syscall
Function • 呼叫涵式 main function #主程式 …. #code Jal function label(副涵式名稱) #呼叫涵式 …. .text #副涵式 function label : code Jr $ra
Program Layout .text #code section .globl main #start point: must be global main: code .data#data section data label : #data setting .text#function code section function label: code
Run Program • 將程式寫出並儲存成文字檔(txt) • First run the program 1.Simulator->Clear Registers 2.Simulator->Reinitialize 3.File->Open->open the file 4.Simulator->Go • After edit the file(ex. there are errors) 1.Repeat the step 1 , 2 2.Simulator->Reload the file 3.Simulator->Go