0

再会!我是汇编语言的新手,我正在尝试打印一个带有颜色的简单“Hello World”。它可以工作,但是当我现在添加时,例如,13, 10它不会显示回车换行,而是显示其他字符(音符和圆圈)。这是我的代码:

.MODEL SMALL
.DATA
.stack

hello db 13,10,'Hello World'
      db 13,10,'    #####     ',0        ; there are spaces
ROW1 DB 12
COL DB 20

.CODE
.STARTUP
MOV AL, 3       ; 80x25 color
INT 10H         ; video BIOS call   
MOV AH, 2       ; set cursor position
MOV BH, 0       ; display page number
 mov bl,2
MOV DH, ROW1        ; row number
MOV DL, COL     ; column number
INT 10H         ; video BIOS call
CALL FAR PTR DISP   ; display first line of video text

.EXIT

DISP PROC FAR
        MOV SI, 0   ; set up array pointer
NEXT:   MOV AL, hello[SI]; get name character
    CMP AL, 0   ; exit if character is 0
    JZ EXIT     
    MOV BH, 0   ; display page number
    MOV BL, [BP+SI] ; get attribute
    MOV CX, 1   ; do 1 character
    MOV AH, 9   ; write character/attribute on screen
    INT 10H     ; video BIOS call
    INC SI      ; point to next character/attribute
    ADD DL, 1   ; move two columns to the right
    MOV AH, 2   ; set cursor position
    INT 10H     ; video BIOS call
    JMP NEXT    ; and continue
EXIT:   RET
DISP ENDP

END


请帮我修复代码,以便在控制台中看到变量中写入的hello内容。另外,我怎样才能摆脱闪烁的颜色?我刚刚在互联网上获得了一个颜色列表,但是当我在这里输入它时,它会闪烁(mov bl, 2呈绿色但它会闪烁)。

4

2 回答 2

0

您可以将函数 0Eh用于CRLF。它将推进光标位置:

视频 - 电传输出

AH = 0Eh
AL = 要写入的字符
BH = 页码
BL = 前景色(仅限图形模式)

描述:在屏幕上显示一个字符,根据需要推进光标和滚动屏幕

注意:字符 07h (BEL)、08h (BS)、0Ah (LF) 和 0Dh (CR) 被解释并执行预期的操作

于 2013-03-10T21:53:20.283 回答
0

当我回答您的另一个问题时,来自Ralf Brown 的中断列表

INT 10 - VIDEO - WRITE CHARACTER AND ATTRIBUTE AT CURSOR POSITION
    AH = 09h
    AL = character to display
    BH = page number (00h to number of pages - 1) (see #00010)
        background color in 256-color graphics modes (ET4000)
    BL = attribute (text mode) or color (graphics mode)
        if bit 7 set in <256-color graphics mode, character is XOR'ed
          onto screen
    CX = number of times to write character
Return: nothing
Notes:  all characters are displayed, including CR, LF, and BS
    replication count in CX may produce an unpredictable result in graphics
      modes if it is greater than the number of positions remaining in the
      current row
    With PhysTechSoft's PTS ROM-DOS the BH, BL, and CX values are ignored
      on entry.

正如它所说:注意:显示所有字符,包括 CR、LF 和 BS

您必须自己解释承运人退货 (CR, 0x0d)。因此,如果输入是0x0d13十进制),请按照下面的说明进行操作,否则如果输入是其他内容,请按照您当前的操作进行处理。

因此,对于 CR,读取当前光标位置,然后通过以下int 10h调用更改光标位置:

首先,获取当前光标位置:

INT 10 - VIDEO - GET CURSOR POSITION AND SIZE
    AH = 03h
    BH = page number
        0-3 in modes 2&3
        0-7 in modes 0&1
        0 in graphics modes
Return: AX = 0000h (Phoenix BIOS)
    CH = start scan line
    CL = end scan line
    DH = row (00h is top)
    DL = column (00h is left)
Notes:  a separate cursor is maintained for each of up to 8 display pages
    many ROM BIOSes incorrectly return the default size for a color display
      (start 06h, end 07h) when a monochrome display is attached
    With PhysTechSoft's PTS ROM-DOS the BH value is ignored on entry.

在输出中,dh是当前行。这样做inc dh,然后设置其余参数:

INT 10 - VIDEO - SET CURSOR POSITION
    AH = 02h
    BH = page number
        0-3 in modes 2&3
        0-7 in modes 0&1
        0 in graphics modes
    DH = row (00h is top)
    DL = column (00h is left)

但是,当您位于底行并且输入中有 CR 时,您不会在问题中说出您想要做什么。您也应该检查这种情况并以您喜欢的方式处理它。

接着:

inc si
jmp next
于 2013-03-10T17:39:22.410 回答