2012-09-14 68 views
0

在一些教程的幫助下,我寫了一小段代碼, 顯示我一個字符串,從我的軟盤啓動後。彙編 - 瞭解一些行

我的問題是現在,那不懂一些線條,我希望你能幫助我, 或只是告訴我,如果我是正確的。

代碼:

mov ax, 07C0h 
add ax, 288   ; (512 + 4096)/16 = 288 
mov ss, ax 
mov sp, 4096 

mov ax, 07C0h 
mov ds, ax 
  1. 線:(?我可以改變這個)@的ADRESS 07C0h 啓動該程序段288
  2. 增加空間斧子
  3. 空間的4096個字節我的程序 (存儲變量和東西嗎?)
  4. 轉至開始ADRESS

感謝您的幫助。

+0

Google「dos引導裝載程序」。 –

回答

4
mov ax, 07C0h 
add ax, 288   ; (512 + 4096)/16 = 288 
mov ss, ax 

這使堆棧段(SS)的開始在段號07C0h + 288.引導程序在段號07C0h的開始裝載。自舉程序的大小是512字節,每個段是16個字節。這意味着堆棧段在引導加載程序結束後開始4096個字節。

mov sp, 4096 

這設置堆棧指針〜4096這意味着現在堆棧的頂部是4096個字節過去堆棧段的開始。實際上,這爲堆棧分配了4096個字節。

mov ax, 07C0h 
mov ds, ax 

這將數據段設置爲07C0h(引導加載程序啓動的段)。稍後在引導加載程序中引用數據標籤時,它們將使用數據段,因此您的引導加載程序必須位於數據段的起始位置才能在內存中找到正確的位置。

+0

我覺得這個文檔很有用:http://duartes.org/gustavo/blog/post/how-computers-boot-up/ – Zack

3
mov ax, 07C0h // copy the address 07C0h into the register ax 
add ax, 288  // add the number 288 to the address in ax 
mov ss, ax  // copy the result to the stack segment register (07C0h + 288) 
mov sp, 4096 // set the stack pointer to 4096 

mov ax, 07C0h // copy the address 07C0h to ax again 
mov ds, ax  // copy the address 07c0h from ax into ds 

..這就是你給出的一切。

+0

好的,非常感謝。 – user1571682