王爽 汇编语言 实验十 1、显示字符串

assume cs:code

data segment
        db 'welcome to masm!',0
data ends

code segment
start:
        mov dh,2
        mov dl,2
        mov cl,2
        mov ax,data
        mov ds,ax
        mov si,0
        call show_str
        mov ax,4c00h
        int 21h
        
show_str: 
        push ax
        push bx
        push cx
        push dx
        push si
        push di
        push es
        
        mov bl,dl   ;乘法运算要用到dx
        mov ax,0b800h
        mov es,ax
        mov ax,0
        mov al,dh
        mov di,050h
        mul di
        add al,bl
        add ax,ax
        mov bx,ax   ;此时dx值肯定为0
        mov di,0
        mov ah,cl
     s: mov al,ds:[si]    ;给相应的显示缓存赋值,直到字符串出现0
        mov cx,0
        mov cl,al
        jcxz ok
        mov es:[bx+di],ax
        inc si
        add di,2
        jmp short s
        
    ok: pop es
        pop di
        pop si
        pop dx
        pop cx
        pop bx
        pop ax
        
        ret

code ends

end start

你可能感兴趣的:(王爽 汇编语言 实验十 1、显示字符串)