MIT的6.828課程 是關於作業系統實作的有趣課程,我報名參加了相關的 讀書會 ,並開始研讀課程內容,這篇文章主要紀錄 Lab1 的部份練習(以下描述問題時,我會用比較精簡的方式敘述,想知道完整說明的朋友請直接參考課程嘍~): Ex1:練習x86 assembly。 Ans: 由於該課程使用gas與gcc,所以我簡單練習一下AT&T的語法。 .global mmax mmax: pushl % ebp movl % esp , % ebp movl 8 ( % ebp ) , % eax cmpl 12 ( % ebp ) , % eax jle .L2 movl 8 ( % ebp ) , % eax jmp .L3 .L2: movl 12 ( % ebp ) , % eax .L3: popl % ebp ret inline assembly的版本(由於在C function中嵌入asm,所以省卻prologue & epilogue): #include <stdio.h> static int mmax ( int a,...