Write a program that counts the number of the given character in a user given string. The program must have a procedure called 'HowMany ' that will expect ECX hold the number of user given character in the string buffer, ESI to have the address of where the buffer starts, and EAX to have the character to look for (actually in AL). This procedure will set EAX (return to main via EAX) the number of characters (one given in AL) found in the buffer. The main procedure will ask the user for a string and put it into the buffer (buffer BYTE 256) and then ask the user for a single character (the character to find count of in buffer) and store it in EAX (AL); It will then call HowMany and then lastly, will write out the number of the character found the string.
Things to remember:

  1. Prompt user for input and use ReadSting and ReadChar for input.
  2. ReadString sets EAX with the number of character read in (you will want to use this to set ECX)
  3. The register ECX, ESI, and EAX are to be set in main before this procedure is called.
  4. EAX must be set (and not restored via a USES) in the HowMany procedure
  5. Your HowMany procedure must be commented (Description, Receives, Returns, and Requires) and you must format your code well (e.g. indentations)
    First get your procedure to count the number of set character in a set string
    For example 'o' and 'The quick red fox jumps over the lazy brown dog';
Reverend Jim commented: Rude -3

Recommended Answers

All 2 Replies

Frankly, this omits all the other details needed to craft said routines in assembly. The target system is unspecified and one might divine it's for some pre-EUFI 80x86 machine but with the changes in PCs and I might only have an Apple M2 computer, I would find this difficult to implement.

I see Reverend Jim has noted the other issue with your post so I'll add these:

  1. Show your work.
  2. Tell where you are stuck.
  3. As noted, for assembler work, the target must be known.

If you can find a Fiddle to share the problem example, even better since not everyone will have an assembler installed.
Example: https://www.mycompiler.io/new/asm-x86_64

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.