Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi please helpp me with this MARIE ASSEMBLY code.I got this string with the addr

ID: 3742659 • Letter: H

Question

Hi please helpp me with this MARIE ASSEMBLY code.I got this string with the address name as  NameAddr. The string ends with a 0 character (HEX 000) .Currently my trim string function can find the address of the last character(0 character). However, now I need to iterate backwards and replace any spaces in the string with a 0 character using my removeSpace function. Problem is my function doesn't terminate?

TrimStringAddr, HEX 0    / address of string to trim
TrimString,     HEX 0
/ <--- this is where you add your code for trimming a string
StartTrim, LoadI TrimStringAddr
                Skipcond 800
                JumpI TrimString  / Return if character is 0
                Load TrimStringAddr
                Add One
                Store TrimStringAddr
                Jump StartTrim
//INSPECT CODE HERE   
//Remove spaces
RemoveStringAddr, HEX 0
RemoveSpace, HEX 0
Space, DEC 32
CharacterReplace, Hex 000
StartStringAdr, HEX 0
LoadI NameAddr
Store StartStringAdr

StartRemoveSpace, LoadI TrimStringAddr
                  Subt StartStringAdr
                  Skipcond 400//if at the start of the string,
                  JumpI RemoveSpace
                  LoadI TrimStringAddr
                  Subt Space
                  Skipcond 400//If its a space
                  Load CharacterReplace
                  //STORE ORI VALUE OF TRIMSTRING NOT THE ONE THAT SUBTRACT SPACE?
                  Store TrimStringAddr//Replace
                  Subt One//else store and iterate
                  Jump StartRemoveSpace
           

Explanation / Answer

In my case, this code does not even assemble. There are undefined operandes One and NameAddr. Also, I don't know why my simulator is not recognizing LoadI instruction.

But I will try to help you.

StartRemoveSpace, LoadI TrimStringAddr
                  Subt StartStringAdr
                  Skipcond 400//if at the start of the string,
                  JumpI RemoveSpace

In this part, you are loading the value present at TrimStringAddr and subtracting it with the address StartStringAdr. That is why the function does not terminate.

Instead of loading the value here, you can load the address

StartRemoveSpace, Load TrimStringAddr
                  Subt StartStringAdr
                  Skipcond 400//if at the start of the string,
                  JumpI RemoveSpace

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote