如何在emu8086中计算字符串中特定字符的出现 [英] How to count the occurence of specific characters in a string in emu8086

查看:280
本文介绍了如何在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

这篇关于如何在emu8086中计算字符串中特定字符的出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆