【发布时间】:2019-08-17 20:45:18
【问题描述】:
在程序中找出没有。字符串中的元音。我被困在“输入一个字符串:”??为什么?即使编译器说一切都好。
程序来计算编号。字符串中的元音。
;;;;;;;PROGRAM TO CHECK NO. OF VOWELS IN A STRING;;;;;
.model small
.stack 100h
.data
vowels db 'AEIOUaeiou$'
msg1 db 'Enter a string:$'
msg2 db 'The string is:$'
msg3 db 'No of vowels are:$'
string db 50 dup('$')
count db ?
.code
main proc
mov ax, @data
mov ds, ax
mov es, ax
lea dx,msg1
mov ah,09h ;for displaying enter a string
int 21h
lea di,string
cld
xor bl,bl
input:mov ah,01 ; stuck here, at taking input, why??
cmp al, 13
je endinput
stosb
inc bl
jmp input
endinput:cld
xor bh,bh
lea si,string
vowelornot: mov cx,11
lodsb
lea di,vowels
repne scasb
cmp cx, 00
je stepdown
inc bh
stepdown: dec bl
jnz vowelornot
mov ah,06 ;;;THIS FOR CLEARING SCREEN I GUESS
mov al,0 ;;;
int 10h
lea dx,msg2
mov ah,09
int 21h
mov dl, 13 ;;; NEW LINE
mov ah, 2
int 21h
mov dl, 10
mov ah, 2
int 21h
lea dx,string
mov ah, 09
int 21h
mov dl,13 ;;;NEW LINE
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
lea dx, msg3
mov ah,09
int 21h
mov dl,13 ;;;NEW LINE
mov ah,2
int 21h
mov dl,10
mov ah,2
int 21h
mov count, bh
mov dh, count ;;; DH = VOWEL COUNT
mov ah,09
int 21h
mov ah, 4ch ;;; EXIT
int 21h
main endp
end
【问题讨论】:
-
缺少一个
int 21h来调用 ah=1 函数。 -
谢谢,嗯。但是,我仍然无法计算元音,问题出在哪里,您能纠正我吗?
-
终于让这个工作了.....我不知道这里有很多东西不得不改变这些...... ```` add bh, 48 ;;;将数字转为ASCII;;;; mov dl, bh mov ah, 2 ;;;不,我得到了元音的真实计数。是的;;;; int 21h ``````
-
我无法将这篇文章设为“已回答”? @HansPassant,