【问题标题】:How to display characters in assembly in DOS?如何在 DOS 中显示汇编中的字符?
【发布时间】:2016-02-20 06:42:07
【问题描述】:

我尝试显示以下代码,但我的调试器 (AFD) 继续调试但不显示任何内容。

[org 0x100]
                mov ax, 0xb800
                mov es, ax
                mov di, 0

nextchar:       mov   word [es:di], 0x0720
                add   di, 2
                cmp   di, 40
                jne   nextchar

    mov ax,0x0003  ; 80x25 text mode, 16 colors
    int 0x10

【问题讨论】:

  • 嗯,0x20 是空格字符,而您将黑色指定为背景色,所以我会说您看到的是预期的行为。
  • 除了在顶行打印空格外,完成后设置通常会清除屏幕的视频模式也无济于事。
  • 我把 0x0720 改成了 0x0741 但还是一样
  • 在运行程序之前,首先在 dos 提示符下使用cls 命令清除屏幕。您对屏幕顶行所做的更改可能会滚动。您也可以在写入显示器之前输入mov ax,0x0003 int 0x10。设置显示模式一般也会清屏。

标签: windows assembly nasm dos


【解决方案1】:

在退出前等待键盘按键,让自己有机会真正查看您输出的内容:

[org 0x100]
    mov ax, 0xb800
    mov es, ax
    mov di, 0
nextchar:
    mov   word [es:di], 0x0741 ; Will show 20x "A"
    add   di, 2
    cmp   di, 40
    jne   nextchar

    mov   ah,0x00
    int   0x16                 ; Wait for a key

    mov ax,0x0003              ; 80x25 text mode, 16 colors
    int 0x10

【讨论】:

  • 很抱歉,我发现我的问题只是我自己的错误。我不熟悉 DOS。
猜你喜欢
  • 1970-01-01
  • 2015-11-12
  • 2020-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-25
相关资源
最近更新 更多