int 10h 13h bios string output not working

2.2k views Asked by At

i am using nasm and this is my code :

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

it does put the cursor on the right position but it prints nothing. i load this file with qemu-system-i386. The int10 ah=13h is a string output and in register es:bp has to be the address of the string

1

There are 1 answers

3
Dmytro On

For future reference, since i have been trying to get this working for a long time now, here is a working version!

    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

here is a version closest to original.

    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