Context::go(self::target($i)); Templates::$op["cbz$bits"] = static fn (array $i, Context $c): string => self::branch('\App\Alis\bztest() == 0', $i); Templates::$op["cbnz$bits"] = static fn (array $i, Context $c): string => self::branch('\App\Alis\bztest() != 0', $i); Templates::$op["cbeq$bits"] = static fn (array $i, Context $c): string => self::branch('\App\Alis\beqtest() != 0', $i); Templates::$op["cbne$bits"] = static fn (array $i, Context $c): string => self::branch('\App\Alis\beqtest() == 0', $i); } } private static function target(array $i): int { foreach ($i['ops'] as $op) { if ($op[0] === 'j') { return $op[2]; } } throw new \LogicException('no jump operand'); } private static function branch(string $cond, array $i): string { return sprintf('$s->pc = $o + (%s ? 0x%x : 0x%x);', $cond, self::target($i), $i['end']); } }