BIOS - OSDev Wiki
INT 0x10, AH = 3 -- cursor position
表示,执行0x10中断的时候,如果ah=3,表示返回光标位置(更多服务参考wiki-bios)
INT 0x10 = Video display functions (including VESA/VBE)
INT 0x13 = mass storage (disk, floppy) access
INT 0x15 = memory size functions
INT 0x16 = keyboard functions
service 09h of the interrupt 10h can change color.
MOV AH,09 ; FUNCTION 9
MOV AL,03 ; HEART ASCII
MOV BX,0004 ; PAGE 0, COLOR 4
MOV CX,07D0 ; 2000 CARACTERS
INT 10H ; INTERRUPT 10 -> BIOS
INT 20H ; END
BX register is used to set the video page and set the color of the caracter.
BH :Page
BL :Color
00H to 0FH表示16个颜色
first 4 bites are used to set the background color, and the last 4 others, the forecolor.
MOV BL,0EH ; Background = Black, Foreground = Yellow
MOV BL,1EH ; Background = Blue, Foreground = Yellow
参考:
Changin Text Color - Assembly - Tek-Tips
示例
- entry _start ;entry告诉链接器从这里开始执行
- _start:
- ;读取光标位置,BIOS的0x10中断的0x03功能是读取光标位置。
- mov ah,#0x03
- xor bh,bh
- int 0x10
-
- mov cx,#23 ;字符串长度
- mov bx,#0x000c ;显示红色的字符串
- mov bp,#msg1 ;向屏幕写入的字符串
- mov ax,#0x07c0
- mov es,ax ;给es写入0x07c0
- mov ax,#0x1301 ;向屏幕写字符串并移动光标到末尾
- int 0x10 ;BIOS的0x10中断的0x13功能的0x01子功能
- inf_loop:
- jmp inf_loop ;死循环
- msg1:
- .byte 13,10 ;回车换行
- .ascii "Dx's os is booting..."
- .byte 13,10
- .org 510 ;之后的语句从510开始
- boot_flag:
- .word 0xAA55 ;磁盘引导标志0xAA55