给定一个最多256个字符的字符串,您将使用什么IBM Mainframe Assembler指令来检测并指向该字符串中特定的一字节分隔符字符的第一次出现?
答案 0 :(得分:2)
如果在z13或更高版本上运行,则VECTOR FIND ELEMENT EQUAL(VFEE)指令也可能非常有用。它将搜索16个字节以查找特定字符,并返回该字符在字节序列中的位置。尽管您需要一个循环来处理256个字符,但性能将比TRT好得多。在较旧的计算机上,最好使用SRST。
答案 1 :(得分:1)
指令是TRT,"翻译和测试"。 例如,要查找字符串中的第一个空格(X' 40'):
[...]
TRT STRING,HEXTBL
[...]
STRING DC C'WHERE IS THE FIRST SPACE?'
HEXTBL EQU *
DC X'00000000000000000000000000000000' VALUES X'00' - X'0F'
DC X'00000000000000000000000000000000' VALUES X'10' - X'1F'
DC X'00000000000000000000000000000000' VALUES X'20' - X'2F'
DC X'00000000000000000000000000000000' VALUES X'30' - X'3F'
DC X'FF000000000000000000000000000000' VALUES X'40' - X'4F'
DC X'00000000000000000000000000000000' VALUES X'50' - X'5F'
DC X'00000000000000000000000000000000' VALUES X'60' - X'6F'
DC X'00000000000000000000000000000000' VALUES X'70' - X'7F'
DC X'00000000000000000000000000000000' VALUES X'80' - X'8F'
DC X'00000000000000000000000000000000' VALUES X'90' - X'9F'
DC X'00000000000000000000000000000000' VALUES X'A0' - X'AF'
DC X'00000000000000000000000000000000' VALUES X'B0' - X'BF'
DC X'00000000000000000000000000000000' VALUES X'C0' - X'CF'
DC X'00000000000000000000000000000000' VALUES X'D0' - X'DF'
DC X'00000000000000000000000000000000' VALUES X'E0' - X'EF'
DC X'00000000000000000000000000000000' VALUES X'F0' - X'FF'
[...]