代码之家  ›  专栏  ›  技术社区  ›  Sook Lim

如何在Marie中修剪字符串末尾的空格?

  •  1
  • Sook Lim  · 技术社区  · 6 年前

    我的print子例程在到达0字符(标记字符串的结尾)时停止打印。因此,为了修剪空白,我只需从最后一个字符的地址向后迭代,只要是空白,我就用0替换它。

    //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
    

    任何帮助都将不胜感激谢谢!

    0 回复  |  直到 6 年前