不间断地显示文本
Displaying text without interrupts
我正在尝试制作自己的引导加载程序。因为我从16位模式切换到32位模式时不会有任何中断,所以我将无法使用int 10h
。
这是我目前的代码:
org 0x7c00 ; add to offsets
xor ax, ax ; make it zero
mov ds, ax ; ds=0
mov ss, ax ; stack starts at 0
cld
mov ax, 0xb800 ; Ax = address of video memory
mov es, ax
xor di, di
call print ; call thr print function
hang:
jmp hang ; constanly loop
print:
mov si, msg ; load msg into si
mov cx, 4
mov ah, 07h
printchar:
lodsb ; Hear we load a letter from si
stosw
loop printchar ; if not end of msg, go back to printchar
ret ; return
msg db 'test' ; msg = 'test'
times 510-($-$$) db 0 ; make sure file is 510 bytes in size
dw 0xaa55 ; write boot signiture
并用nasm编译:
nasm -f bin bootloader.asm -o myos.hdd
我已经在我理解的行中添加了注释。我不明白的是显存的使用。有人可以向我解释一下并告诉我在哪里可以找到文档吗?
我已经在互联网上搜索过,但找不到文档。
我想我现在明白了。
mov cx, 4
是消息的长度。 "test" 是四个字节长。
mov ah, 07h
正在设置颜色数据。 0 = 黑色,7 = 浅灰色。
第一个数字是背景颜色,第二个数字是文本颜色。
这意味着要打印的字符将是黑色背景上的浅灰色。
感谢所有帮助过的人。
我正在尝试制作自己的引导加载程序。因为我从16位模式切换到32位模式时不会有任何中断,所以我将无法使用int 10h
。
这是我目前的代码:
org 0x7c00 ; add to offsets
xor ax, ax ; make it zero
mov ds, ax ; ds=0
mov ss, ax ; stack starts at 0
cld
mov ax, 0xb800 ; Ax = address of video memory
mov es, ax
xor di, di
call print ; call thr print function
hang:
jmp hang ; constanly loop
print:
mov si, msg ; load msg into si
mov cx, 4
mov ah, 07h
printchar:
lodsb ; Hear we load a letter from si
stosw
loop printchar ; if not end of msg, go back to printchar
ret ; return
msg db 'test' ; msg = 'test'
times 510-($-$$) db 0 ; make sure file is 510 bytes in size
dw 0xaa55 ; write boot signiture
并用nasm编译:
nasm -f bin bootloader.asm -o myos.hdd
我已经在我理解的行中添加了注释。我不明白的是显存的使用。有人可以向我解释一下并告诉我在哪里可以找到文档吗?
我已经在互联网上搜索过,但找不到文档。
我想我现在明白了。
mov cx, 4
是消息的长度。 "test" 是四个字节长。
mov ah, 07h
正在设置颜色数据。 0 = 黑色,7 = 浅灰色。
第一个数字是背景颜色,第二个数字是文本颜色。
这意味着要打印的字符将是黑色背景上的浅灰色。
感谢所有帮助过的人。