Why isn't the text colored when using the 0Eh 10h interrupt?

前端 未结 4 840
别跟我提以往
别跟我提以往 2020-12-22 07:43

I\'m using the 10h interrupt with AH as 0Eh to output \"Hello World!\" The text is ouputted but its not colored. I\'m running it on qemu-system-x86_64, assembling with NASM,

4条回答
  •  攒了一身酷
    2020-12-22 08:21

    I was able to print with color by using the 09 for the 10h interrupt, instead of 0E. You do, however, have to change the cursor position after each character to use this method. Here is the working code.

         BITS 16
    
    start:
        mov ax, 07C0h           ; Set up 4K stack space after this bootloader
        add ax, 288             ; (4096 + 512) / 16 bytes per paragraph
        mov ss, ax
        mov sp, 4096
    
        mov ax, 07C0h           ; Set data segment to where we're loaded
        mov ds, ax
    
    
        mov si, text_string     ; Put string position into SI
        call print_string       ; Call our string-printing routine
    
        jmp $                   ; Jump here - infinite loop!
    
    
        text_string db 'Hello World!', 0
    
    
    print_string:                   ; Routine: output string in SI to screen
    
    
     .repeat:
        mov ah, 09h             ; int 10h 'print char' function
        mov bh, 0x00
        mov bl, 0x03
        mov cx, 01h
        lodsb                   ; Get character from string
        cmp al, 0
        je .done                ; If char is zero, end of string
        int 10h                 ; Otherwise, print it
        mov bh, 00h
        mov ah, 03h
        int 10h
        mov ah, 02h
        mov bh, 00h
        inc dl
        int 10h
        jmp .repeat
    
     .done:
        ret
    
    
        times 510-($-$$) db 0   ; Pad remainder of boot sector with 0s
        dw 0xAA55               ; The standard PC boot signature
    

提交回复
热议问题