不知道如何一次打印整个日历 [英] Don't know how to print an entire Calendar at once
问题描述
CSEG段
假设CS:CSEG,DS:CSEG
组织100H
开始:
MOV ES,CS:[视频]
MOV AX,3
INT 10H
MOV CS:[COL],0FH
MOV DI,10;问候味精会后10个空格打印
LEA SI,问候
通话乱
通话n线
扬打电话
通话n线
MOV啊,4路
INT 21H山坳0分贝
问候DB欢迎来到2015年日历,0
视频DW 0b800h
一月DB一月$,
串DB周日周一周二周三周四周五周六$
字符串1 DB1 2 3 4 5 $
字符串2分贝6 7 8 9 10 11 12 $
STRING3 DB13 14 15 16 17 18 19 $
串,DB20 21 22 23 24 25 26 $
STRING5 DB27 28 29 30 31 $乱PROC
推斧
MOV啊,CS:[COL]
MOV BH,30
conmess:
MOV等,CS:[SI]
还是人,人
JZ endmess
MOV ES:[二],斧
MOV ES:[二+ 1〕,BH
INC SI
加迪,2
JMP conmess
endmess:
流行斧
RET
乱ENDPn线PROC
MOV啊,2;回车
MOV DL,0DH
INT 21H
MOV DL,0AH;换行
INT 21H
RET
n线ENDP打印:
;印刷线
MOV BH,10H;颜色属性
MOV啊,9
MOV人,0; avoding多余的字符
INT 10H;印刷色
INT 21H
RET扬PROC
LEA DX,一月;负载和放大器;显示〜应变
调用打印
通话n线
LEA DX,串;负载和放大器;显示该字符串
调用打印
通话n线
LEA DX,字符串1;负载和放大器;显示该字符串
调用打印
通话n线
LEA DX,字符串2;负载和放大器;显示该字符串
调用打印
通话n线
LEA DX,STRING3;负载和放大器;显示该字符串
调用打印
通话n线
LEA DX,串,;负载和放大器;显示该字符串
调用打印
通话n线
LEA DX,STRING5;负载和放大器;显示该字符串
调用打印
通话n线
RET
扬ENDPCSEG结束
结束开始
假设CS:CSEG,DS:CSEG
组织100H
由于您使用组织100H
我假设你正在写在DOS'.COM格式的可执行文件。
MOV迪,10;问候味精会后10个空格打印
要产生10个空格,你需要设置DI = 20,因为在0B800h视频RAM每个字符占用2个字节。
乱PROC
推斧
MOV啊,CS:[COL]
MOV BH,30;你不需要这行
conmess:
MOV等,CS:[SI]
还是人,人
JZ endmess
MOV ES:[二],斧
MOV ES:[二+ 1〕,BH;你不需要这行
INC SI
加迪,2
JMP conmess
endmess:
流行斧
RET
乱ENDP
是由视频RAM直接写入显示的问候语。你为什么要插入2种方式来定义属性字节?
打印:
MOV BH,10H;删除此行
MOV啊,9
MOV人,0;删除此行
INT 10H;删除此行
INT 21H
RET
文字的其余部分是通过DOS功能完成。这的打印的程序似乎混合BIOS和DOS功能!对于DOS你只需要AH = 9
MOV啊,4路
INT 21H
该终止函数需要你在AL寄存器定义退出code。使用 MOV AX,4C00h
。
在繁琐的调用代替的 n线的产生CRLF,你可以很容易地编写既要输出字符串中的这些字节。结果
像这样的例子
字符串2分贝6 7 8 9 10 11 12,13,10,$
你的大部分程序都使用PROC / ENDP,但声明的打印的不是。请选择一个系统,并坚持下去。
修改
由于您的所有字符串都在单独的行显示的最简单的方法,给他们颜色是使用所需的属性擦拭当前行。这里是你如何在第一串做
MOV AX,0920h \\
MOV BX,001Eh;蓝底黄字|最好把这个子程序!
MOV CX,80 |
INT 10H /
LEA DX,一月
调用打印
通话n线
cseg segment
assume cs:cseg, ds:cseg
org 100H
begin:
mov es,cs:[video]
mov ax,3
int 10h
mov cs:[col],0fh
mov di,10 ;greeting msg will be printed after 10 spaces
lea si,greeting
call mess
call nline
call jan
call nline
mov ah,4ch
int 21h
col db 0
greeting db "Welcome to the 2015 Calendar ",0
video dw 0b800h
january db " January$",
string db "Sun Mon Tue Wed Thu Fri Sat$"
string1 db " 1 2 3 4 5$"
string2 db " 6 7 8 9 10 11 12$"
string3 db "13 14 15 16 17 18 19$"
string4 db "20 21 22 23 24 25 26$"
string5 db "27 28 29 30 31$"
mess proc
push ax
mov ah,cs:[col]
mov bh, 30
conmess:
mov al,cs:[si]
or al,al
jz endmess
mov es:[di],ax
mov es:[di+1],bh
inc si
add di,2
jmp conmess
endmess:
pop ax
ret
mess endp
nline proc
mov ah, 2 ; carriage return
mov DL, 0DH
int 21H
mov DL, 0AH ; line feed
int 21H
ret
nline endp
print:
;printing the line
mov bh,10h ;color attribute
mov ah,9
mov al,0 ;avoding extra characters
int 10h ;printing color
int 21h
ret
jan proc
lea dx,january ; load & display the STRIN
call print
call nline
lea dx, string ; load & display the STRING
call print
call nline
lea dx, string1 ; load & display the STRING
call print
call nline
lea DX, string2 ; load & display the STRING
call print
call nline
lea DX, string3 ; load & display the STRING
call print
call nline
lea DX, string4 ; load & display the STRING
call print
call nline
lea DX, string5 ; load & display the STRING
call print
call nline
ret
jan endp
cseg ends
end begin
assume cs:cseg, ds:cseg
org 100H
Because you used org 100h
I assume you are writing an executable in DOS'.COM format.
mov di,10 ;greeting msg will be printed after 10 spaces
To produce 10 spaces you need to setup DI=20 because in the video RAM at 0B800h every character occupies 2 bytes.
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
The greeting message is displayed by directly writing in the video RAM. Why did you insert 2 ways to define the attribute byte?
print:
mov bh,10h ; Delete this line
mov ah,9
mov al,0 ; Delete this line
int 10h ; Delete this line
int 21h
ret
The rest of the writing is done via DOS functions. This print routine seems to mix BIOS and DOS functions!!! For DOS you only need AH=9
mov ah,4ch
int 21h
The Terminate function expects you to define an exit code in the AL register. Use mov ax,4C00h
.
In stead of the cumbersome calling of nline to produce a CRLF you could easily write both these bytes in the string that you want to output.
Like this example
string2 db " 6 7 8 9 10 11 12",13,10,"$"
Most of your routines are declared using PROC/ENDP but print is not. Please choose one system and stick to it.
EDIT
Since all of your strings are displayed on separate lines the easiest solution to give them color is to wipe the current line using the desired attribute. Here's how you do it for the first string
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
这篇关于不知道如何一次打印整个日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!