程序在程序集 8086 中的程序后无法继续

The program fails to proceed after a procedure in assembly 8086

嗨,朋友们,我无法在 "Upper" 程序后返回到下一行,我不明白 ip 去了哪里...

.MODEL SMALL
.STACK  64
.DATA
input db 30,?,30 dup('$'),'$'
msg1 db "Please enter string to convert:", 0DH , '$'
msg2 db "Your converted input :", 0DH , '$'
TransFormsMan db 32 ; Going to use the dec value 32 to change my lowers chars..


.Code

Main proc
    mov ax, @data
    mov ds, ax
    ; Printing Message1 with a lineBreak
    lea dx, msg1
    mov ah, 09
    int 21H
    mov dl,0AH
    mov ah, 02
    int 21H
    call getString
    xor ax,ax
    lea ax,input
    mov cl,input + 1
    mov ch,0
    add ax,2
    push ax
    push cx
    ; Printing Message2 with a lineBreak
    lea dx, msg2
    mov ah, 09
    int 21H
    mov dl,0AH
    mov ah, 02
    int 21H
    call upper

    mov ah, 4ch
    mov al, 0
    int 21H
endp Main

print proc
    ;Handle bp 
    push bp
    mov bp,sp
    add bp,2
    ;pushes
    push ax
    push bx
    push dx
    ;body:
    mov dx,[bp+2]
    ;add dx,2 ; we want to print without the size of the string. 
    xor ax,ax
    mov ah,9
    int 21H
    xor ax,ax
    xor dx,dx
    mov dx,13 ; Getting down line in the output
    mov ah,2
    int 21h  
    mov dx,10
    mov ah,2
    int 21h ; ^^
    ;pops
    pop dx
    pop bx
    pop ax
    pop bp
    ret 2
endp print

getString proc
    ;Handle bp 
    push bp
    mov bp,sp
    add bp,2
    ;pushes
    push ax
    push dx
    ;body:
    mov ah,0AH
    lea dx,input
    int 21H
    xor ax,ax
    xor dx,dx
    mov dx,13 ; Getting down line in the output
    mov ah,2
    int 21h  
    mov dx,10
    mov ah,2
    int 21h ; ^^
    ;pops
    pop dx
    pop ax
    pop bp
    ret
endp getString

Upper proc
    ;Handle bp 
    push bp
    mov bp,sp
    add bp,2
    ;pushes
    push ax
    push bx
    push cx
    push dx
    push si
    push di
    ;body:
    mov bx,[bp+4]
    mov cx,[bp+2]
    sub sp,[bp+2]
    mov si,sp
    mov di,si

    loopy:
        xor ax,ax
        mov al,[bx]
        cmp al,'z'
        ja notLower
        cmp al,'a'
        jl notLower
        sub al, 32
        mov [si],al
        inc si
        inc bx
        loop loopy
    notLower:
        cmp cx,0
        je stackPrint ; if the last letter was lower so we need to get out of here...
        inc bx
        loop loopy
    stackPrint:
    mov byte ptr [si],'$'
    push di
    call print
    add sp,[bp+2]
    ;pops
    pop di

    pop di
    pop si
    pop dx
    pop cx
    pop bx
    pop ax
    pop bp
    ret 4
endp Upper

END Main

就像我说的代码运行良好但每次 "Upper" 程序结束后我都无法继续下面的行,因为 ret 不会 return 我到后面的行调用过程

mov byte ptr [si],'$'
push di
call print
add sp,[bp+2]
;pops
pop di

Upper 过程中,pop di 是罪魁祸首。 print 过程已从堆栈中移除参数 (ret 2)。
只需删除 pop di.

注意

如果 SSDS 段寄存器在您的程序中不同,则需要进行许多其他更改才能实现此“String In The Stack”解决方案工作!