2013-12-19 21 views
0

對於學校任務,我必須編寫一個如下所述的程序,我真的很想幫助解決這個問題。要說清楚,我不希望你解決這個問題,我只想要一些指導如何去做。在沒有操作系統的虛擬計算機上運行的啓動時間程序

問題:

寫啓動時的程序,這將在一個虛擬計算機沒有操作系統下運行。程序必須打印出您的名字,並根據ALT鍵的狀態顯示「按下ALT鍵」或「ALT鍵未按下」。

附加提示: - 所述程序具有在16位模式將被寫入

  • 編譯的程序,包括它的數據必須小於510個字節的大小

  • 指令「有機0x7c00」指定在程序加載的內存中的正確地址

  • 寫數據之前的指令

  • 程序在一個無限循環應該執行

  • 沒有printf函數,你將不得不使用中斷0x10的

  • 閱讀ALT鍵的狀態,你可以使用中斷0x16

  • 到文本使用的輸出位置中斷爲0x10

  • 可執行的二進制格式應該是 「塊」(NASM -f -o BOOT.BIN code.asm倉)

  • 調整二進制文件到軟盤的大小(截斷-s 1474560 BOOT.BIN)

  • 標記二進制文件作爲啓動盤:在位置0x1FE保存該值0x55和在 位置到0x1FF保存值和0xAA(使用十六進制編輯器,例如:ghex2)

  • 啓動虛擬機與您的二進制文件的軟盤:(不錯-n 19 QEMU -FDA BOOT.BIN)

+0

你到目前爲止嘗試過什麼?你有什麼工作,以及你卡在哪裏? – 2013-12-19 20:08:13

+0

你在這裏得到了很多提示和指導。關於唯一剩下的就是繼續寫下代碼。我不明白我們能給予更多的幫助。 – 2013-12-19 20:08:33

回答

0

我建議您在組裝bootlo上閱讀this aders。從那篇文章採取,這裏是你好世界 -

 org 7C00h 

     jmp short Start ;Jump over the data (the 'short' keyword makes the jmp instruction smaller) 

Msg: db "Hello World! " 
EndMsg: 

Start: mov bx, 000Fh ;Page 0, colour attribute 15 (white) for the int 10 calls below 
     mov cx, 1  ;We will want to write 1 character 
     xor dx, dx  ;Start at top left corner 
     mov ds, dx  ;Ensure ds = 0 (to let us load the message) 
     cld    ;Ensure direction flag is cleared (for LODSB) 

Print: mov si, Msg  ;Loads the address of the first byte of the message, 7C02h in this case 

         ;PC BIOS Interrupt 10 Subfunction 2 - Set cursor position 
         ;AH = 2 
Char: mov ah, 2  ;BH = page, DH = row, DL = column 
     int 10h 
     lodsb   ;Load a byte of the message into AL. 
         ;Remember that DS is 0 and SI holds the 
         ;offset of one of the bytes of the message. 

         ;PC BIOS Interrupt 10 Subfunction 9 - Write character and colour 
         ;AH = 9 
     mov ah, 9  ;BH = page, AL = character, BL = attribute, CX = character count 
     int 10h 

     inc dl   ;Advance cursor 

     cmp dl, 80  ;Wrap around edge of screen if necessary 
     jne Skip 
     xor dl, dl 
     inc dh 

     cmp dh, 25  ;Wrap around bottom of screen if necessary 
     jne Skip 
     xor dh, dh 

Skip: cmp si, EndMsg ;If we're not at end of message, 
     jne Char  ;continue loading characters 
     jmp Print  ;otherwise restart from the beginning of the message 


times 0200h - 2 - ($ - $$) db 0 ;Zerofill up to 510 bytes 

     dw 0AA55h  ;Boot Sector signature 

;OPTIONAL: 
;To zerofill up to the size of a standard 1.44MB, 3.5" floppy disk 
;times 1474560 - ($ - $$) db 0 
相關問題