📄 cmpstr.cgs
字号:
# sh testcase for cmp/str $rm, $rn -*- Asm -*-# mach: all# as: -isa=shcompact# ld: -m shelf32 .include "compact/testutils.inc".macro rot8 rotr r0 rotr r0 rotr r0 rotr r0 rotr r0 rotr r0 rotr r0 rotr r0.endm start# Use multiple "wrong" labels because this program is quite long. It's# likely that some instructions will be too far away from the branch# target to use PC-relative branches. match0: # No bytes matching. mov #1, r0 neg r0, r0 xor #170, r0 rot8 xor #170, r0 rot8 xor #170, r0 rot8 xor #170, r0 rot8 mov r0, r1 mov #1, r0 neg r0, r0 xor #85, r0 rot8 xor #85, r0 rot8 xor #85, r0 rot8 xor #85, r0 rot8 cmp/str r0, r1 bt wrong0 bra match1 nopwrong0: failmatch1: # One byte matching. mov #1, r0 neg r0, r0 xor #170, r0 rot8 xor #170, r0 rot8 xor #170, r0 rot8 mov r0, r1 mov #1, r0 neg r0, r0 xor #85, r0 rot8 xor #85, r0 rot8 xor #85, r0 rot8 cmp/str r0, r1 bf wrong1 bra match2 nopwrong1: failmatch2: # Two bytes matching. mov #1, r0 neg r0, r0 xor #170, r0 rot8 xor #170, r0 rot8 mov r0, r1 mov #1, r0 neg r0, r0 xor #85, r0 rot8 xor #85, r0 rot8 cmp/str r0, r1 bf wrong2 bra match3 nopwrong2: fail byte0:match3: # One byte matching. # This is also the test for byte 0. mov #85, r0 mov #85, r1 cmp/str r0, r1 bf wrong3byte1: # Match in byte position 1. mov #85, r0 shll8 r0 mov #85, r1 shll8 r1 cmp/str r0, r1 bf wrong3byte2: # Match in byte position 2. mov #85, r0 shll16 r0 mov #85, r1 shll16 r1 cmp/str r0, r1 bf wrong3byte3: # Match in byte position 3. mov #85, r0 shll16 r0 shll8 r0 mov #85, r1 shll16 r1 shll8 r1 cmp/str r0, r1 bf wrong3okay: passwrong3: fail
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -