assume cs:cseg, ds:cseg
org 100H
因为你用过org 100h
我假设您正在编写 DOS'.COM 格式的可执行文件。
mov di,10 ;greeting msg will be printed after 10 spaces
要产生 10 个空格,您需要设置 DI=20,因为在 0B800h 的视频 RAM 中,每个字符占用 2 个字节。
mess proc
push ax
mov ah,cs:[col]
mov bh, 30 ; You don't need this line
conmess:
mov al,cs:[si]
or al,al
jz endmess
mov es:[di],ax
mov es:[di+1],bh ; You don't need this line
inc si
add di,2
jmp conmess
endmess:
pop ax
ret
mess endp
通过直接写入视频RAM 来显示问候消息。为什么要插入两种方式来定义属性字节?
print:
mov bh,10h ; Delete this line
mov ah,9
mov al,0 ; Delete this line
int 10h ; Delete this line
int 21h
ret
其余的编写是通过 DOS 函数完成的。这print例程似乎混合了 BIOS 和 DOS 功能!对于 DOS,你只需要 AH=9
mov ah,4ch
int 21h
Terminate 函数要求您在 AL 寄存器中定义退出代码。使用mov ax,4C00h
.
而不是繁琐的调用nline要生成 CRLF,您可以轻松地将这两个字节写入要输出的字符串中。
就像这个例子
string2 db " 6 7 8 9 10 11 12",13,10,"$"
大多数例程都是使用 PROC/ENDP 声明的,但是print不是。请选择一种系统并坚持使用。
EDIT
由于所有字符串都显示在单独的行上,为它们提供颜色的最简单的解决方案是使用所需的属性擦除当前行。以下是对第一个字符串执行此操作的方法
mov ax,0920h \
mov bx,001Eh ;Yellow on Blue | Best put this in a subroutine!
mov cx,80 |
int 10h /
lea dx,january
call print
call nline