【发布时间】:2019-02-20 13:13:59
【问题描述】:
我编写了一个汇编程序,它计算用户读取的字符串中元音的数量。字符串的读取和长度的计算工作正常。但是在比较字符串的字符时,前两个字符不起作用。这是我的代码。
.MODEL small
.STACK
.DATA
input db 10,?
length db ?
count db ?
.CODE
.STARTUP
;reading string
mov dx,00h
mov dx,offset input
mov ah,0Ah
int 21h
;calculating length
mov length,00h
mov si,offset input+2
;checking for vowels
loopi: cmp [si],'$'
je next
add length,01h
inc si
loop loopi
next:
mov cx,00h
mov cl,length
mov si,offset input+2
mov count,00h
counting:cmp [si],'a'
je count1
cmp [si],'e'
je count1
cmp [si],'i'
je count1
cmp [si],'o'
je count1
cmp [si],'u'
je count1
inc si
loop counting
cmp cl,00h
je exit
count1:inc count
inc si
loop counting
exit:
.EXIT
end
此代码不比较/检查字符串的前两个字符。有人可以尽快帮助我吗? 任何帮助将不胜感激。非常感谢。
【问题讨论】:
标签: assembly user-input x86-16 emu8086