【问题标题】:Assembly x86 graphic mode 13h cursor placment装配 x86 图形模式 13h 光标放置
【发布时间】:2014-01-30 13:56:15
【问题描述】:

我对汇编非常陌生,我无法理解光标在模式 13h 中的位置。例如,(0,0) 最终出现在屏幕中间。我不明白如何让它到达我想要的位置。

我正在使用的代码:

mov al, 13h
mov ah, 0h
int 10h
mov ax, dseg
mov ds, ax

mov dl, 0 ;row  
mov dh, 0 ;col
mov bx, 0
mov ah, 2h
int 10h
mov dx, offset string
mov ah, 9h      
int 21h

mov al, 3h
mov ah, 0h
int 10h
int 3h

我将不胜感激。

【问题讨论】:

  • 1988 正在打电话,他们想要回他们的代码。 :-)
  • 是的..这是给学校的,我在网上找不到任何解释
  • 模式 13h 位置 0,0 是左上角。我手边没有我的参考资料,但没有什么能引起我的注意,为什么你最终会在屏幕中间看到一个光标。

标签: assembly


【解决方案1】:

哦,我知道那种痛苦。

首先根据Wikipediathis site 的中断int 10h 与代码AH=2h,DL 用于列,DH 用于行。 还有为什么最后是int 3

无论如何,这段代码对我有用 - 它在 pos 2,3 打印字符串。用tasm编译,在dosbox下运行。

; AH=0h: Set video mode
mov al, 13h ; Video mode number
mov ah, 0h
int 10h

; AH=2h: Set cursor position
mov dl, 2 ; Column
mov dh, 3 ; Row
mov bx, 0 ; Page number, 0 for graphics modes
mov ah, 2h
int 10h

; AH=9h: Print string
mov dx, offset string
mov ah, 9h
int 21h

; Wait for keypress
mov ah, 08h
int 21h

; AH=0h: Set video mode
mov al, 3h ; Video mode number
mov ah, 0h
int 10h

; Exit
mov ah, 4ch
mov al, 0
int 21h

还有一个建议:写尽可能多的 cmets;装配中从来没有太多的;)

【讨论】:

  • 写得很好。此代码中的字体大小也发生了变化。如果我们想保持相同的字体, 在第二行。
  • 相同的代码使用 masm 编译,(当然,还有标题)。我在dosbox下测试过了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-31
  • 1970-01-01
  • 2012-06-07
  • 1970-01-01
  • 2018-07-30
  • 2020-08-22
相关资源
最近更新 更多