为啥 debug和普通运行的结果不一致
debug下结果没问题运行程序就出不了结果为啥
功能
从键盘输入一个字符串,显示出现次数最少的最晚输入的一个字符及个数。
e.g.>djtyddy(输入)
t:1(输出)
代码
MyStack segment stack
dw 128 dup(?)
MyStack ends
data segment
string db 100,?,100 dup(?);接受输入
count db ?;记录各个字符出现的次数
temp db 99;记录当前出现次数最少的字符数
result db ?;记录出现次数最少且最后出现的字符
data ends
code segment
assume cs:code,ds:data,ss:MyStack
start:
mov ax,data
mov ds,ax
;mov es,ax
;接受输入
Lea di,string
mov ah,10d
int 21h
call cr
xor cx,cx
mov CL,string+1
Lea bx,string
add bx,2
Lab:
mov dh,[bx]
call compare
mov DL,count
cmp temp,DL
jc run; temp-count<0
mov temp,DL
mov result,dh
run:
inc bx
mov DL,0
mov count,DL
cmp CX,0
jz Lab_over
loop Lab
Lab_over:
; call cr
mov ah,2
mov DL,result
int 21h
mov dL,':'
int 21h
mov ah,2
mov DL,temp
add DL,30h
int 21h
mov ah,4ch
int 21h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;子程序;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;子程序1:实现回车换行
CR proc near
push ax
push dx
mov ah,2
mov DL,0ah
int 21h
mov DL,0dh
int 21h
pop dx
pop ax
ret
CR endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;子程序2:实现字符的比较统计相同字符数量
compare proc near
push bx
push cx
xor cx,cx
mov CL,string+1
Lea bx,string
add bx,2
next:
cmp dh,[bx]
jz same
jmp continue
same:
inc count
continue:
inc bx
cmp CX,0
jz Lab_1
loop next
Lab_1:
pop cx
pop bx
ret
compare endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
code ends
end start