2013-02-23 57 views
0

我正在參加我的第一個彙編編程課程,我的教師希望我們瞭解基於 的尋址模式是如何工作的。所以這裏是我寫的一些代碼來嘗試並做到這一點。 唯一的問題是我不能理解它,因爲我不斷收到分段錯誤。 我對線路進行了評論,試圖展示我認爲他們在做什麼。 有人可以糾正我的誤解。基於尋址模式的組件x86

謝謝!

.text 
.global _start 
L0: .int 0x99999999 
L1: .int 0x12345678 
L2: .int 0x11111111 
_start: 
movl $L1, %eax #Stores the address of what L1 "pionts to" in regester eax 
movb $0, 2(%eax) #Stores 0 in the location eax has in it +2 memory locations 
       #So 0 should be stored in the same place as L1+2 
checkHere: 


movl $1,%eax 
movl $0,%ebx 
int $0x80 
+0

系統調用1h是退出()的方式,你在_start的意圖是什麼?此外,請小心在ELF分頁地址空間的開始之下尋址。 – 2013-02-23 21:14:54

回答

1

.text是隻讀的。把你的數據放在.data,它應該可以工作。

+0

哇,我什至沒有看到!當然! – 2013-02-23 22:00:35