A string toolkit
The problem
Build a program that reads a line and reports facts about it, using the stack and the string instructions: the line backwards, the number of vowels and whether it is a palindrome.
Requirements
- Read a line into a buffer with INT 21h service 0Ah
- Print the line backwards with the stack
- Count the vowels, with a table of vowels in the data segment
- Decide whether the line reads the same backwards, and print yes or no
Technologies
- 8086 assembly
- The stack
- String instructions
- Addressing modes
Step by step
- Read the line and put a dollar sign after its characters.
- Push each character, then pop them all to print the line backwards.
- Count the vowels with a loop over the line and a loop over the vowel table.
- Make a reversed copy of the line in a second buffer and compare it with the line using REPE CMPSB.
- Print the three results, and test with words such as racecar, stack and a single letter.
Expected result
A program that prints the line reversed, the number of vowels and a palindrome verdict for each test line.
How it is evaluated
- The reversed line is correct for lines of any length from 1 to 40
- The vowel count agrees with a count by hand
- The palindrome check uses REPE CMPSB and its flags correctly
Ways to improve it
- Ignore spaces and capital letters in the palindrome check
- Print how often each vowel appears
- Replace every vowel with a star using string instructions