MIPS ascii 子串内存覆盖
我正在使用 MARS MIPS 模拟器,并且有一个特定的任务来更改内存上主 Ascii 字符串中的另一个子字符串。然而,模拟器将这 3 个放在内存中并排放置。当我将主字符串的字符向右移动时(如果第二个子字符串比第一个子字符串长),它实际上会覆盖子字符串的字符。我可以听听一些关于如何解决这个问题的想法吗?
I'am using MARS MIPS simulator and There is a specific task to change a substring with another in a main Ascii string on the memory. However, simulator puts these 3 next to each other on the memory. When I shift characters of the main string to the right(if the second substring is longer than the first), it practically overwrites those of the substrings. Can I please hear some ideas on how to solve this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在它们之间添加一些空白。 ;)
如果您无法执行此操作,请声明三个目标缓冲区(始终带有上面的
.space
),在其中复制字符串,然后直接在其中编辑它们。编辑
您可以将这些子字符串保存在两个缓冲区中,这样在修改“主”字符串时您仍然会覆盖子字符串,但您不需要费心,因为您已经在其他地方获得了它们的副本。在实践中,一旦您拥有了自己的子字符串副本,您就可以愉快地忘记原始子字符串并覆盖它们(如果需要),使用您获得的副本作为参考。
也许这就是你能做的一切。如果你没有足够的空间,就不可能发明其他的。您必须覆盖某些内容。顺便说一句,修改“主”字符串后,您可以将副本放在后面,这样调用者仍然可以找到子字符串。
Add some empty space between them. ;)
If you can't do this, declare three destination buffers (always with the
.space
above) where you copy your strings, then edit them directly there.EDIT
You can keep these substrings in two buffers so when modifying the 'main' string you will still overwrite the substrings, but you don't need to bother because you've got their copy somewhere else. In practice, once you have your own copy of the substrings you can happily forget the original ones and overwrite them (if needed), using as reference the copies you got.
Probably this is all you can do. If you haven't got enough room is impossible to invent some other. You have to overwrite something. BTW after you modified the 'main' string you can put your copies after that, so the caller still finds the substrings.