## Is a character an angle bracket? A particularly easy test. .globl isntangle isntangle: mov 4(%esp), %eax isntangle2: or $2, %eax sub $'>, %eax # also sets ZF on match! ret ## How about, does a character need to be escaped in general HTML? ## Here we have 0x22 '"', 0x3C '<', 0x3E '>', and most ## importantly 0x26 '&' to deal with. ## Brute-force baseline, five instructions for every case: .globl safe_without_escaping safe_without_escaping: mov 4(%esp), %eax cmp $'&, %eax ja isntangle2 # unsigned! je 1f sub $'", %eax # ; " ret 1: xor %eax, %eax # unnecessary if you're using ZF instead of %eax ret ## Could you do it in three or four instructions? ## Maybe a more interesting question is whether you can use ## SSE instructions to scan several bytes at once for & or <.