int 10h 13h BIOS 字符串输出不起作用

问题描述 投票:0回答:1

我正在使用 nasm,这是我的代码:

org 0x7c00
bits    16



section .data
 zeichen    dw  'hello2'
section .text


 mov ax,0x7c00
 mov    es,ax
 mov    bh,0
 mov    bp,zeichen

 mov    ah,13h
 mov    bl,00h
 mov    al,1
 mov    cx,6
 mov    dh,010h
 mov    dl,01h

int 10h

 jmp    $

 times  510 - ($-$$)    hlt
 dw 0xaa55

它确实将光标放在正确的位置,但没有打印任何内容。 我使用 qemu-system-i386 加载此文件。 int10 ah=13h 是一个字符串输出,在寄存器 es:bp 中必须是字符串的地址

nasm x86-16 bootloader bios
1个回答
2
投票

为了将来的参考,因为我已经尝试让它工作很长时间了,这里是一个工作版本!

    org 0x7c00
    bits 16

    xor ax, ax
    mov es, ax
    xor bh, bh
    mov bp, msg

    mov ah, 0x13
    mov bl, [foreground]
    mov al, 1
    mov cx, [msg_length]
    mov dh, [msg_y]
    mov dl, [msg_x]

    int 0x10

    hlt

foreground dw 0xa 
msg db 'Hello, World!'
msg_length dw $-msg
msg_x dw 5
msg_y dw 2

    times  510 - ($-$$) db 0
    dw 0xaa55

这是最接近原始版本的版本。

    org 0x7c00
    bits 16

    ; video page number.
    mov bh, 0     
    ; ES:BP is the pointer to string.
    mov ax, 0x0
    mov es, ax    
    mov bp, msg   

    ; attribute(7 is light gray).
    mov bl, 0x7
    ; write mode: character only, cursor moved.
    mov al, 1
    ; string length, hardcoded.
    mov cx, 6
    ; y coordinate
    mov dh, 16
    ; x coordinate
    mov dl, 1

    ; int 10, 13
    mov ah, 0x13
    int 0x10

    ; keep jumping until shutdown.
    jmp $

msg dw  'hello2'

    times  510 - ($-$$) db 0
    dw 0xaa55
© www.soinside.com 2019 - 2024. All rights reserved.