ccc112b / sp

課程:系統程式 -- 筆記、習題與報告
1 stars 42 forks source link

習題3 : 請用 C 語言硬塞的方式,直接將 power(a,n) 的機器碼放進去執行 (加分題) #4

Open ccckmit opened 4 months ago

ccckmit commented 4 months ago

參考

  1. 06-c4/02-asmFib
  2. 06-c4/02b-asmFib2
  3. fib.c
++ gcc -w c4.c -o c4
++ ./c4 -s test/fib.c
1: #include <stdio.h>
2:
3: int f(int n) {
4:   if (n<=0) return 0;
    ENT  0
    LLA  2
    LI
    PSH
    IMM  0
    LE
    BZ   0
    IMM  0
    LEV
5:   if (n==1) return 1;
    LLA  2
    LI
    PSH
    IMM  1
    EQ
    BZ   0
    IMM  1
    LEV
6:   return f(n-1) + f(n-2);
    LLA  2
    LI
    PSH
    IMM  1
    SUB
    PSH
    JSR  -1283591064
    ADJ  1
    PSH
    LLA  2
    LI
    PSH
    IMM  2
    SUB
    PSH
    JSR  -1283591064
    ADJ  1
    ADD
    LEV
7: }
    LEV
8:
9: int main() {
10:   printf("f(7)=%d\n", f(7));
    ENT  0
    IMM  -1283328912
    PSH
    IMM  7
    PSH
    JSR  -1283591064
    ADJ  1
    PSH
    PRTF
    ADJ  2
11: }
    LEV
Siling5304 commented 4 months ago

資工二 111110525 林思伶 https://github.com/Siling5304/sp/blob/master/hw3/c4.c 產生的機器碼:https://github.com/Siling5304/sp/blob/master/hw3/machine%20code.md 執行結果:https://github.com/Siling5304/sp/blob/master/hw3/README.md

wrr606 commented 4 months ago

資工二 111110517 范揚玄 C4.c 的程式碼:https://github.com/wrr606/sp/blob/master/homework/3/c4.c 機器碼:https://github.com/wrr606/sp/blob/master/homework/3/machine%20code.md Output:https://github.com/wrr606/sp/blob/master/homework/3/output.md 防止手臂得到 Ctrl C+V 關節炎的腳本:https://github.com/wrr606/sp/blob/master/homework/3/Scrip.py

KiuBios commented 4 months ago

資工二 111110519 胡劭家 C4.c :https://github.com/KiuBios/sp/blob/master/hw3/result/c4.c Machine Code:https://github.com/KiuBios/sp/blob/master/hw3/result/MachineCode_power.md Output:https://github.com/KiuBios/sp/blob/master/hw3/result/Output.md

karta9630 commented 3 months ago

資工二 111110503 戴嘉豪 C4.c 的程式碼:https://github.com/karta9630/sp/blob/master/03/c4.c 機器碼:https://github.com/karta9630/sp/blob/master/03/machine.md Output:https://github.com/karta9630/sp/blob/master/03/output.md

yc0123 commented 3 months ago

資工二 111110507 陳穎辰 程式碼:https://github.com/yc0123/sp/blob/master/hw3/c4_power.c 機器碼:https://github.com/yc0123/sp/blob/master/hw3/test/power.md Output:https://github.com/yc0123/sp/blob/master/hw3/README.md

o5xNo commented 3 months ago

資工二 111110508 吳丞恩 C4.c 的程式碼:https://github.com/o5xNo/sp/blob/master/03/c4.c 機器碼 + Output:https://github.com/o5xNo/sp/blob/master/03/power.md

shaaaaaaaaaaK commented 3 months ago

資工二 111110521 呂博翔 C4.c 的程式碼:https://github.com/shaaaaaaaaaaK/sp/blob/master/hw3/c4.c 機器碼:https://github.com/shaaaaaaaaaaK/sp/blob/master/hw3/mechine%20code.md Output:https://github.com/shaaaaaaaaaaK/sp/blob/master/hw3/output.md

s111110512 commented 3 months ago

資工二 沈心怡 111110512 https://github.com/s111110512/sp/tree/master/0320

yang930208 commented 3 months ago

資工二 111110529 楊智鈞 c4.c程式碼 機器碼 執行結果

Astridtu commented 1 month ago

資工二 111110543 凃玫妮 https://github.com/Astridtu/sp/tree/master/Homework3

lkhagvaa2444 commented 1 month ago

資工二 111110544 李荷葦 program code: https://github.com/lkhagvaa2444/sp/blob/master/HW3/output.md machine code: https://github.com/lkhagvaa2444/sp/blob/master/HW3/test/power.md output: https://github.com/lkhagvaa2444/sp/blob/master/HW3/output.md

sealbrother commented 1 month ago

資工二/111110556/蔡杰叡 https://github.com/sealbrother/sp/blob/master/3/Machine.md https://github.com/sealbrother/sp/blob/master/3/Output.md https://github.com/sealbrother/sp/blob/master/3/c4.c

Gavinhsu0512 commented 1 month ago

資工二 111110501 許元承 C4.c 的程式碼:https://github.com/Gavinhsu0512/sp/blob/master/homework3/c4.c 機器碼:https://github.com/Gavinhsu0512/sp/blob/master/homework3/machine%20code.md Output:https://github.com/Gavinhsu0512/sp/blob/master/homework3/output.md?plain=1

GFVictorique commented 1 month ago

資工二 111010521 薛翊呈 https://github.com/GFVictorique/sp/tree/master/hw/hw3

Linyowe commented 1 month ago

建築二 111113344 https://github.com/Linyowe/sp/tree/master/%E7%BF%92%E9%A1%8C3%20%3A%20%E8%AB%8B%E7%94%A8%20C%20%E8%AA%9E%E8%A8%80%E7%A1%AC%E5%A1%9E%E7%9A%84%E6%96%B9%E5%BC%8F%EF%BC%8C%E7%9B%B4%E6%8E%A5%E5%B0%87%20power(a%2Cn)%20%E7%9A%84%E6%A9%9F%E5%99%A8%E7%A2%BC%E6%94%BE%E9%80%B2%E5%8E%BB%E5%9F%B7%E8%A1%8C

henk3520 commented 1 month ago

資工三 111010573 古莛禾 https://github.com/henk3520/sp/tree/main/hw3

Candy96551 commented 4 weeks ago

資工二 111110502 蔡雨軒 C4.c 的程式碼:https://github.com/Candy96551/sp/blob/master/hw3/C4.c 機器碼:https://github.com/Candy96551/sp/blob/master/hw3/machine%20code.md Output:https://github.com/Candy96551/sp/blob/master/hw3/Output.md

RBL23 commented 4 weeks ago

資工二 111110536 劉健明 https://github.com/RBL23/sp/tree/master/3

921006vicky commented 4 weeks ago

資工二 111110505劉思妤 C4.c 的程式碼:https://github.com/921006vicky/sp/blob/master/03/c4.c 機器碼:https://github.com/921006vicky/sp/blob/master/03/machine%20code.md Output:https://github.com/921006vicky/sp/blob/master/03/README.md

liu99002 commented 4 weeks ago

資工二 111110506 劉銓旭 https://github.com/liu99002/sp/tree/master/hw/hw3

XaioYue commented 3 weeks ago

資工二 111110555 董翔宇 https://github.com/XaioYue/sp/tree/master/HW3

pado35 commented 3 weeks ago

資工二 111110511 李明洋 https://github.com/pado35/sp/tree/master/homework/3

Kruez0 commented 3 weeks ago

資工二111110541劉佩芬 https://github.com/Kruez0/sp/tree/master/Hw3

alan198731520 commented 3 weeks ago

資工二 111110524 范祐綸 C4.c 的程式碼:https://github.com/alan198731520/sp/blob/master/hw3/C4.c 機器碼:https://github.com/alan198731520/sp/blob/master/hw3/machine%20code.md Output:https://github.com/alan198731520/sp/blob/master/hw3/Output.md

Yangforrok commented 3 weeks ago

資工二 111110514 羊柏宇 C4.c 的程式碼:https://github.com/Yangforrok/sp/blob/master/3/C4.c 機器碼:https://github.com/Yangforrok/sp/blob/master/3/machine%20code.md Output:https://github.com/Yangforrok/sp/blob/master/3/Output.md