1

在使用 dosbox 时,我在程序集 (8086) 中遇到了一个奇怪的错误。我正在尝试打印绿色的文本。这是我的主要功能,当我调用该函数时:

mov bl,2h                       ; set the color (green)
mov dx,OFFSET str_msg           ; set the string to print
call WRITE_TEXT_IN_COLOR
call NEW_LINE

这是函数 WRITE_TEXT_IN_COLOR

proc WRITE_TEXT_IN_COLOR 
mov ah,9  
mov cx,200  ; number of chars that will be painted
int 10h
int 21H 
ret
endp WRITE_TEXT_IN_COLOR

现在,当我运行该程序时,它会打印“必需”文本以及一长串“dddddd”,我将非常感谢可能的解决方案。

4

1 回答 1

1

如果 CX 中的计数正好等于消息的实际长度,您的代码就可以工作。如果 CX 的数字大于消息的长度,则 BIOS 将显示 AL 寄存器中的任何字符代码(您忘记设置)中的多余部分

我提出以下更改

mov bx,0002h          ; set the color (green) AND select page 0
mov dx,OFFSET str_msg ; set the string to print
call WRITE_TEXT_IN_COLOR
call NEW_LINE

proc WRITE_TEXT_IN_COLOR 
 mov ax,0920h  ;AH=Function number AL=Space character  
 mov cx,200  ; number of chars that will be painted
 int 10h     ;BIOS function 09h
 int 21H     ;DOS function 09h
 ret
endp WRITE_TEXT_IN_COLOR
于 2015-05-02T13:25:30.070 回答