MACRO_INSTRUCTIONS =
[
"addi",
"andi",
"lshifti",
"lshiftp",
"muli",
"negi",
"negp",
"noti",
"ori",
"rshifti",
"urshifti",
"rshiftp",
"urshiftp",
"subi",
"xori",
"loadi",
"loadis",
"loadb",
"loadbs",
"loadh",
"loadhs",
"storei",
"storeb",
"loadd",
"moved",
"stored",
"addd",
"divd",
"subd",
"muld",
"sqrtd",
"ci2d",
"fii2d", "fd2ii", "fp2d",
"fd2p",
"bdeq",
"bdneq",
"bdgt",
"bdgteq",
"bdlt",
"bdlteq",
"bdequn",
"bdnequn",
"bdgtun",
"bdgtequn",
"bdltun",
"bdltequn",
"btd2i",
"td2i",
"bcd2i",
"movdz",
"pop",
"push",
"move",
"sxi2p",
"zxi2p",
"nop",
"bieq",
"bineq",
"bia",
"biaeq",
"bib",
"bibeq",
"bigt",
"bigteq",
"bilt",
"bilteq",
"bbeq",
"bbneq",
"bba",
"bbaeq",
"bbb",
"bbbeq",
"bbgt",
"bbgteq",
"bblt",
"bblteq",
"btio",
"btis",
"btiz",
"btinz",
"btbo",
"btbs",
"btbz",
"btbnz",
"jmp",
"baddio",
"baddis",
"baddiz",
"baddinz",
"bsubio",
"bsubis",
"bsubiz",
"bsubinz",
"bmulio",
"bmulis",
"bmuliz",
"bmulinz",
"borio",
"boris",
"boriz",
"borinz",
"break",
"call",
"ret",
"cbeq",
"cbneq",
"cba",
"cbaeq",
"cbb",
"cbbeq",
"cbgt",
"cbgteq",
"cblt",
"cblteq",
"cieq",
"cineq",
"cia",
"ciaeq",
"cib",
"cibeq",
"cigt",
"cigteq",
"cilt",
"cilteq",
"tio",
"tis",
"tiz",
"tinz",
"tbo",
"tbs",
"tbz",
"tbnz",
"tpo",
"tps",
"tpz",
"tpnz",
"peek",
"poke",
"bpeq",
"bpneq",
"bpa",
"bpaeq",
"bpb",
"bpbeq",
"bpgt",
"bpgteq",
"bplt",
"bplteq",
"addp",
"mulp",
"andp",
"orp",
"subp",
"xorp",
"loadp",
"cpeq",
"cpneq",
"cpa",
"cpaeq",
"cpb",
"cpbeq",
"cpgt",
"cpgteq",
"cplt",
"cplteq",
"storep",
"btpo",
"btps",
"btpz",
"btpnz",
"baddpo",
"baddps",
"baddpz",
"baddpnz",
"bo",
"bs",
"bz",
"bnz",
"leai",
"leap",
]
X86_INSTRUCTIONS =
[
"cdqi",
"idivi"
]
ARMv7_INSTRUCTIONS =
[
"smulli",
"addis",
"subis",
"oris"
]
INSTRUCTIONS = MACRO_INSTRUCTIONS + X86_INSTRUCTIONS + ARMv7_INSTRUCTIONS
INSTRUCTION_PATTERN = Regexp.new('\\A((' + INSTRUCTIONS.join(')|(') + '))\\Z')
def isBranch(instruction)
instruction =~ /^b/
end
def hasFallThrough(instruction)
instruction != "ret" and instruction != "jmp"
end