首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linux中的Boot Loader

Linux中的Boot Loader
EN

Stack Overflow用户
提问于 2013-05-03 15:08:46
回答 2查看 213关注 0票数 0

我已经编写了下面的引导程序program.but,有一个问题。

代码语言:javascript
复制
;===================================================================
;Following is an incomplete code of a boot-loader with blanks(.....)
;Replace each blank with appropriate word, words or character
;===================================================================

[ORG 0x7C00]

;==============================================================
;MSG2, MSG3 and MSG4 should describe the right order of typical
;boot-loading functionality (i.e. What basially a boot-loader does?)

MSG1 dd '1. Boot Loader starts ', 0
MSG2 dq '2. Initialize Hardware', 0
MSG3 dq '3. Pass an abstraction of Initialize Hardware', 0
MSG4 dq '4. Execute Kernel', 0
MSG5 dq '5. Boot Loader exits ', 0
;==============================================================

;==============================================================
;Printing the messages (MSG1, MSG2, .....)

MOV SI, MSG1
CALL PrintString ;Call print string procedure
MOV SI, MSG1
CALL PrintString ;Call print string procedure
MOV SI, MSG2
CALL PrintString ;Call print string procedure
MOV SI , MSG3
CALL PrintString ;Call print string procedure
MOV SI , MSG4
CALL PrintString ;Call print string procedure
MOV SI, MSG5
CALL PrintString ;Call print string procedure

JMP $ ;infinite loop here
;===============================================================

;===============================================================
PrintCharacter: ;Procedure to print character on screen

MOV AH, 0x0E
MOV BH, 0x00
MOV BL, 0x07

INT 0x10
RET
;===============================================================

;===============================================================
PrintString: ;Procedure to print string on screen

MOV AL , [SI]
CALL PrintCharacter
NextChar:
INC SI
MOV AL , [SI]
CMP AL , 0
JZ exit_function
CALL PrintCharacter
JMP NextChar
exit_function:
RET
;===============================================================

;===============================================================

times (495) - ($ - $$) db 0
db 0
dw 0xAA52
dd 0xAA53
dq 0xAA54
dw 0xAA55 ;End of Boot-loader

;===

它没有输出第一个错误,我可以纠正你吗? it?.Thank。

EN

回答 2

Stack Overflow用户

发布于 2013-05-03 15:15:29

为了定义字符串,您应该使用db (或者可能是dw),而不是dd/dq

哦,您应该在字符串数据之前跳转到实际代码,否则CPU会认为字符串是应该执行的代码。

票数 2
EN

Stack Overflow用户

发布于 2013-05-03 15:22:54

我没有读到比这更多的东西(省略了评论):

代码语言:javascript
复制
[ORG 0x7C00]

MSG1 dd '1. Boot Loader starts ', 0

这意味着代码的前几个字节根本不是代码,而是一个ASCII字符串。你想要这样的东西:

代码语言:javascript
复制
[ORG 0x7C00]

jmp start

; comments blah blah blah
MSG1 db '1. Boot Loader starts ', 0
; ... etc ...

start:

; instructons start here.

mov si, MSG1
; ...
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16353503

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档