2017q3 Homework3 (simulator)
contributed by <yusihlin
>
分析 full-stack-hello
- as : 將組合語言組譯產生對應的 elf file
- $ : constant integer
- # : temp integer ( 也可寫作 register? )
- \ : string literal
- elf : 提供寫入讀取 elf 所需的函式
- vm : 虛擬機環境配置
- vm_regs 記錄程式執行的狀態
- __vm_env 為虛擬機的環境配置
- opcode : 實作用於虛擬機的指令集
- driver : 主程式部分,在後續允許接受輸入參數的判斷也須在這裡的 argv 新增,內涵指令說明與運行模式
- ASSEMBLE_AND_EVAL : 組譯並執行
- ASSEMBLE_AND_WRITE_ELF : 組譯後輸出 elf
- LOAD_ELF_AND_EVAL : 載入 elf 並執行
參考 st9007a 共筆
在 driver.c 中加入 –input 的參數
在 vm.c 加入 vm_set_temp_value 存放 input_val
回到 driver.c,不同 case 中將 input_val 存放在 #0 中
實作 Fibonacci 數列
Iterative
Recursive