如何在emu8086中计算字符串中特定字符的出现

问题描述:

请. .请在这个问题上帮助我.

Please. .kindly help me on this problem. .

输出:

输入字符串:已经

A-2

B-0

C-0

D-1

E-1

编写一个过程,该过程遍历整个字符串以查找特定字符.对于每个比赛,增加一个计数器.返回显示结果时,字符DL出现DH次:
例如A2".

Write a procedure that loops over the entire string in search of a specific character. For each match increment a counter. Upon return display the result as character DL occurs DH times:
e.g. "A - 2".

mov  dl, "A"
call CountChar
... print result ...
mov  dl, "B"
call CountChar
... print result ...


CountChar:
  mov  dh, 0
  mov  cx, ... length of the input string ...
  jcxz Ready
  mov  bx, ... address of the input string ...
 Again:
  cmp  [bx], dl
  jne  Skip
  inc  dh
 Skip:
  inc  bx
  loop Again
 Ready:
  ret