2017-04-16 43 views
2

这是我写的代码完美的代码,除了我无法弄清楚如何删除控制台的东西(d: \)。 代码在屏幕中间打印出你好。我试图在组件中以图形模式打印消息,但控制台d:仍然存在

IDEAL 
MODEL small 
STACK 100h 
DATASEG 
; -------------------------- 
msg db 'hello' 
; -------------------------- 
CODESEG 
start: 
    mov ax, @data 
    mov ds, ax 
; -------------------------- 
;fullscreen 
MOV AL, 13H 
MOV AH,0 
INT 10H 

mov si,@data;moves to si the location in memory of the data segment 

mov ah,13h;service to print string in graphic mode 
mov al,0;sub-service 0 all the characters will be in the same color(bl) and cursor position is not updated after the string is written 
mov bh,0;page number=always zero 
mov bl,00001111b;color of the text (white foreground and black background) 
;  0000    1111 
;|_ Background _| |_ Foreground _| 
; 

mov cx,5;length of string 
;resoultion of the screen is 244x126 
mov dh,63;y coordinate 
mov dl,122;x coordinate 
mov es,si;moves to es the location in memory of the data segment 
mov bp,offset msg;mov bp the offset of the string 
int 10h 








; -------------------------- 

exit: 
    mov ax, 4c00h 
    int 21h 
END start 

没有如预期黑色背景和白色文字在中间,但在左上角有d:\

感谢您的帮助!

+1

我无法运行你的代码...但是你认为当你的代码执行完毕后,会发生什么? –

回答

2

当程序完成显示消息时,通过使用DOS函数4Ch让它返回到操作系统。这意味着DOS将再次将其提示放在屏幕上。这就是你看到的“d:\”。

要获得足够的时间查看消息,您需要推迟返回到DOS。
只是等待用户按任意键:

mov ah, 07h ;Input from keyboard without echo to the screen 
int 21h 
mov ax, 4C00h ;Terminate 
int 21h 

;resoultion of the screen is 244x126 
mov dh,63;y coordinate 
mov dl,122;x coordinate 

我没有看到你在哪里得到这个特殊的分辨率的数据。
您正在使用的屏幕13h的图形分辨率为320x200,但用于显示文本的BIOS功能13h在DLDH寄存器中预期光标坐标。对于该列,这些范围从0到39,对于该行从0到24。
要显示在屏幕中间的文本“Hello”,那么你将需要:

mov dl, 18 ;Column 
mov dh, 12 ;Row 
+1

非常感谢! – Emil

+0

但是如果我希望用户按下某个键并且消息消失并仍然保持图形模式(没有提示),会发生什么情况。就像“按任意键继续”的菜单一样。 – Emil

相关问题