assume cs:code,ss:stack,ds:data data segment db ‘welcome to masm‘,‘0‘ data ends stack segment dw 8 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 mov ss,stack call show_str mov ax,4c00h int 21h show_str: //显示字符串的子程序 push ax push cx push dx push ss push si//现场的保留 mov ax,0b800h mov es,ax mov di,0 mov al,0a0h dec dh mul dh mov bx,almov al,2 dec dl mul dl add bx,al
//计算要显示的位置的偏移地址,且用的是ax寄存器的低八位
mov al,ch s: mov ch,0 mov cl,ds:[di] jcxz ok//判断读入的字符是不是0 mov ch,al mov es:[bx+si],cx inc di add si,2 jmp short s ok: pop si pop ss pop dx pop cx pop ax ret//回复现场 end start code ends
王爽老师书上的实验10.1。
时间: 2024-10-29 04:03:13