1

Hi I'm new to Marie programming language and I have a string with the address NameAddr.

My print subroutine stops printing when it reaches a 0 character (marking the end of the string).So to trim the white spaces I simply iterate backwards from the address of the last character and as long as its a white space I replace it with a 0.

However, my removeSpace subroutine does not terminate and when I step through it its not updating the LastCharAddr properly after I pass in the address of the last character?

//Remove spaces
LastCharAddr, HEX 0  
RemoveSpace, HEX  0
Space, DEC 32 //constant needed for subroutine
CharacterReplace, Hex 000 //constant for subroutine


StartRemoveSpace, LoadI LastCharAddr
                  Subt Space
                  Skipcond 400  //If its a space
                  JumpI RemoveSpace  //if not a space terminate
                  Load CharacterReplace  //replace with 0
                  Store LastCharAddr  //Replace
                  Load LastCharAddr
                  Subt One// iterate backwards
                  Store LastCharAddr
                  Jump StartRemoveSpace

Any help will be appreciated thanks!

Sook Lim
  • 541
  • 6
  • 28
  • There's no label after your loop, so it's impossible for execution to jump out of your loop. Doesn't `JumpI RemoveSpace` jump to (and execute) data, and then fall into the loop again? Use your debugger to follow execution and see where it goes. – Peter Cordes Sep 05 '18 at 04:47

0 Answers0