我试图让文本屏幕打印'h',它存储在一个变量中.我正在使用NASM.x86保护模式,一种从头开始的内核.
DisplayMessage: ;mov byte[Color], 0xF ;mov CFC, EAX; ;mov byte[Color], 104 ;push 104 ;mov byte[esi], Msg ;lodsb mov ebx, Msg add ebx, 4 mov [Msg], eax mov byte[0xB8000], Msg ;mov byte[eax], Color ;pop byte[0xB8000] ;mov byte[0xB8000], byte Color ;mov byte[0xB8000], 0xB500000; ;Now return ret EndCode: Msg: db 104
它显示的字母永远不对.什么是正确的方法来做到这一点?
mov ebx, Msg ; this loads ebx with the address of Msg, OK
add ebx, 4 ; this increments the address by 4, OK, but why?
mov [Msg], eax ; this stores eax into the first 4 bytes of Msg, OK, but why?
mov byte[0xB8000], Msg ; this writes the least significant byte of the
; address of Msg to the screen, not OK.
; Does not make any sense.
Run Code Online (Sandbox Code Playgroud)
为什么不呢?:
mov al, [Msg]
mov [0xB8000], al
Run Code Online (Sandbox Code Playgroud)
这应该Msg
在屏幕的左上角写入('h'具有ASCII码104,正确)的第一个字符,当然,如果您的数据段在其段描述符中具有基址0,并且如果你org
是对的.