使用 BIOS 例程 INT10h 从变量打印字符

Leo*_*rdo 2 assembly bios nasm bootloader x86-16

有人知道下面的代码有什么问题吗?

我无法让它按照我想要的方式工作。我只想打印变量的单个字符(字母“h”)。

为此,我只需通过方括号使用间接寻址来复制内容

[]

; Set BIOS print screen settings
mov ah, 0x0e ; Teletype
mov bh, 0  ; Page number
mov bl, 4  ; Red on black (00000100 - High 0000 is black, low 0100 is red)
mov cx, 1  ; Writes one character

; Printing to screen
mov al, [msg] ; Copy the contents of 'H' into 'al'; IT SEEMS THIS IS NOT WORKING!!!
jmp print_char ; Jump to executable code and do not let CPU step on DATA SECTION

; [BEG DATA SECTION]
  msg: db 'HELLO', 0
; [END DATA SECTION]

print_char:
int 0x10 ; Call BIOS routine to print the char located at 'al'

infinite_loop:
jmp $
times 510 -($-$$) db 0 ; Pad with 0 until byte 510
dw 0xAA55 ; MBR Boot code signature
Run Code Online (Sandbox Code Playgroud)

我得到的是一个打印“nothing”的屏幕(可能是一个 ASCII 不可打印字符: 在此输入图像描述

Leo*_*rdo 6

问题是顶部缺少以下指令:

组织0x7c00

有关此问题的更多信息,请参见@Michael Petch 的回答。