我已经用 nasm 编译了这个,我正在通过 bochs 运行它。在我看来,2 颜色变量应该使它以蓝色打印 2 行。它实际上打印一种棕色和一种白色。我无法弄清楚。非常感谢任何帮助
[BITS 16]
[ORG 0x7C00]
main:
;set video mode
mov ah,0x00 ;function ref
mov al,0x10 ;param - video mode
int 0x10
mov si, TestString
mov bl,Color ; Normal text attribute
call PutStr
mov si, TestString
mov bl,Color2 ; Normal text attribute
call PutStr
jmp $
;-------------------------------- End of running code
PutStr:
; Set up the registers for the interrupt call
mov ah,0x0E ; The function to display a chacter (teletype)
mov bh,0x00 ; Page number
.nextchar:
lodsb ; load string byte from SI into AL and increments SI
or al,al ; check for end of string
jz .endofstring ; jump to end if null
int 0x10 ; Run the BIOS video interrupt
jmp .nextchar ; Loop back round to the top
.endofstring:
ret
Color db 0001b
Color2 db 0001b
TestString db 'Hello world',13,10,0,0
times 510-($-$$) db 0 ; Fill the rest of the sector with zero's
dw 0xAA55 ; Add the boot loader signature to the end