水铝英石

微机原理实验5

;反向输出字符串final可输出任意长度字符串,用回车结束
data SEGMENT USE16
    str db 200 dup(0)
data ENDS
;description
stack SEGMENT USE16
    dw 200 dup(0)
stack ENDS
;description
code SEGMENT USE16
    assume cs:code,ds:data,ss:stack
start:  MOV AX,data
        MOV DS,AX
    mov cx,200
    lea di,str
lp:     
    mov ah,01H  
    int 21H   
    mov [di],al  
    cmp al,0dh
    jz go
    inc di
    jmp lp
go:    
    ;mov ah,02h
    ;mov dl,0dh
    ;int 21H   
    mov ah,02h
    mov dl,0ah
    int 21H 
        
    ;lea bx,string  
    lea bx,str
    push bx
    call display
    pop bx
    mov dl,[bx]
    mov ah,2
    int 21h
    mov ah,4ch
    int 21h
;description
display PROC
    push AX
    push bx
    push dx
    push bp

    mov bp,sp
    mov bx,[bp+10]
    mov al,byte ptr[bx+1]
    cmp al,0dh
    jnz re_call
    jmp return
re_call:
    inc bx
    push bx
    call display
    pop bx
    mov dl,[bx]
    mov ah,2
    int 21h
return: 
    pop bp
    pop dx
    pop bx
    pop AX
    ret
display ENDP
    
code ENDS
    end start

发表评论

邮箱地址不会被公开。 必填项已用*标注

滚动到顶部