用debug写的一个关于计算字符窜中字母,数字,和其他符号的程序,一直有错误请高手帮忙看看
data segment
string db "in 1990,the exchange rate was 8.1/$"
strend db ?
num db 0
char db 0
other db 0
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov si,offset string
mov cx,strend-string
continue:mov dl,[si]
cmp dl,30h
jl l1
cmp dl 39h
jl l2
cmp dl 41h
jl l1
cmp dl 5ah
jl l3
cmp dl 61h
jl l1
cmp dl 7ah
jl l3
inc other
jmp next
l1:INC other
jmp next
l2:inc num
jmp next
l3:inc char
jmp next
next:inc si
loop continue
mov ah,4ch
int 21h
code ends
end start
[最优解释]
这样就ok了,注意打印的字符要小于10 才能正确打印
data segment
string db "in 1990,the8.1/$"
strend db ?
num db 0
char db 0
other db 0
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov si,offset string
mov cx,strend-string
continue:mov dl,[si]
cmp dl,30h
jl l1
cmp dl,3ah
jl l2
cmp dl,41h
jl l1
cmp dl,5bh
jl l3
cmp dl,61h
jl l1
cmp dl,7bh
jl l3
inc other
jmp next
l1:INC other
jmp next
l2:inc num
jmp next
l3:inc char
next:inc si
loop continue
print:
mov al,num
add al,30h
mov dl,al
mov ah,2
int 21h
mov al,char
add al,30h
mov dl,al
mov ah,2
int 21h
mov al,other
add al,30h
mov dl,al
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start
[其他解释]
cmp dl,30h
jl l1
cmp dl 39h
jl l2
cmp dl 41h
jl l1
cmp dl 5ah
jl l3
cmp dl 61h
jl l1
cmp dl 7ah
jl l3
cmp 2个操作数中间的逗号呢???
我也刚学汇编 现在学到32位的基础
[其他解释]
运行结果在 num/char/other 等相关变量里。
不过,cmp dl, 39h/5ah/7ah 等指令后的 jl 应该是 jle 吧。
[其他解释]
运行结果在哪啊?