实验十,第一个作业
assume cs:codesg,ds:datasgdatasg segment
db 'welcome to masm!',0
datasg ends
codesg segment
start: mov dh,8 ;参数 行号
mov dl,3 ;参数 列号
mov bh,02h ;参数 颜色
mov ax,datasg
mov ds,ax
mov si,0
call show_str
; int 16h ;这是一个键盘中断
mov ax,4c00h
int 21h
show_str:
mov ax,0b800h ;显示区基址
mov es,ax
; dec dh ;行号减1
mov al,0a0h ;每行0a0h个字节,十进制160个
mul dh ;0a0h*dh=行号位置二级基址
mov bp,ax ;计算行号位置并赋值给bp
dec dl ;列号减1
mov al,2 ;每列2个字节
mul dl ;2*dl=列号位置 最后的偏移
mov di,ax ;计算列号位置并赋值给di
s:mov ch,0
mov cl,ds: ;判断cx是否为0
jcxz ok
mov bl,cl
mov word ptr es:,bx
add di,2
inc si
loop s
ok: ret
codesg ends
end start
这个程序有点小问题,1. 第25行,也就是最后一行不能显示字符串
2.当把列的位置定位在后面的时候,大概70列往后,字符串显示不全
页:
[1]