0

I have a problem I'm trying to figure out:

Write an LC-3 assembly language program that asks the user to input a string (the end of the input string is the enter key), and prints the words of this string in reverse order. For example, if the input string is “Hello, my name is Joe”, the output of your program should be “Joe is name my Hello,” Test your program with LC-3 simulator. Your code must be well documented. Hint: Consider using stack for easier implementation.

I know how I would be able to use a stack to return something exactly reversed ex: input "AB CD EF" output "FE DC BA" but how would I be able to only reverse the order of segments? ex: input "AB CD EF" output "EF CD AB"

Thanks

CDO
  • 302
  • 1
  • 3
  • 17

1 Answers1

0

The best thing to do would be increase the number of blocks of memory that get pushed onto your stack at one time. For example, if you are only expecting the user to enter in words that are equal to or less than 5 characters, then one "push" on your stack would take up 5 blocks of memory.

This would make it so you could "pop" the words off the stack without having to rearrange the order of each of the letters.

Chris M
  • 651
  • 6
  • 10