实验10.1,程序结束异常
代码如下:assume cs:code
datasegment
db 'Welcome to masm!',0
data ends
stack segment
db 16 dup (0)
stack ends
code segment
start: mov dh,8
mov dl,3
mov cl,2
mov ax,data
mov ds,ax
mov si,0
call show_str
mov ax,4c00h
int 21h
show_str:mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
call site
mov ax,0B800h
mov es,ax
mov bp,0
mov ax,0
mov ah,cl ;送属性字节
s1: mov al,ds: ;送字符串字节
cmp al,0 ;判断是否结束位
jeexit
mov es:,al
mov es:,ah
add si,2
add bp,1
jmp s1
exit: ret
site: mov al,0a0h ;计算行偏移地址
mov ah,0
sub dh,1
mul dh
mov si,ax
mov al,2 ;计算列偏移地址
mov ah,0
sub dl,1
mul dh
add si,ax ;偏移地址总和
ret
code ends
end start
程序执行结果如图片 code segment
start: mov dh,8
mov dl,3
mov cl,2
mov ax,data
mov ds,ax
mov si,0
jmp show_str
exit: mov ax,4c00h
int 21h
show_str:mov ax,stack
mov ss,ax
call sites
mov ax,0B800h
mov es,ax
mov bp,0
mov ax,0
mov ah,cl ;送属性字节
s1: mov al,ds: ;送字符串字节
cmp al,0 ;判断是否结束位
jeexit
mov es:,al
mov es:,ah
add si,2
add bp,1
jmp s1
site: mov al,0a0h ;计算行偏移地址
mov ah,0
sub dh,1
mul dh
mov si,ax
mov al,2 ;计算列偏移地址
mov ah,0
sub dl,1
mul dh
add si,ax ;偏移地址总和
ret
code ends
end start
代码段改成这样就可以了
页:
[1]