master
   1source: [*:0]const u8,
   2operands: std.StringHashMapUnmanaged(Operand),
   3
   4pub const Operand = union(enum) {
   5    register: aarch64.encoding.Register,
   6};
   7
   8pub fn nextInstruction(as: *Assemble) !?Instruction {
   9    const original_source = while (true) {
  10        const original_source = as.source;
  11        var token_buf: [token_buf_len]u8 = undefined;
  12        const source_token = try as.nextToken(&token_buf, .{});
  13        switch (source_token.len) {
  14            0 => return null,
  15            else => switch (source_token[0]) {
  16                else => break original_source,
  17                '\n', ';' => {},
  18            },
  19        }
  20    };
  21    log.debug(
  22        \\.
  23        \\=========================
  24        \\= Assembling "{f}"
  25        \\=========================
  26        \\
  27    , .{std.zig.fmtString(std.mem.span(original_source))});
  28    for (matchers) |matcher| {
  29        as.source = original_source;
  30        if (try matcher(as)) |result| return result;
  31    }
  32    as.source = original_source;
  33    log.debug("Nothing matched!\n", .{});
  34    return error.InvalidSyntax;
  35}
  36
  37fn zonCast(comptime Result: type, zon_value: anytype, symbols: anytype) Result {
  38    const ZonValue = @TypeOf(zon_value);
  39    const Symbols = @TypeOf(symbols);
  40    switch (@typeInfo(ZonValue)) {
  41        .void, .bool, .int, .float, .pointer, .comptime_float, .comptime_int, .@"enum" => return zon_value,
  42        .@"struct" => |zon_struct| switch (@typeInfo(Result)) {
  43            .pointer => |result_pointer| {
  44                comptime assert(result_pointer.size == .slice and result_pointer.is_const);
  45                const elems = comptime blk: {
  46                    var temp_elems: [zon_value.len]result_pointer.child = undefined;
  47                    for (&temp_elems, zon_value) |*elem, zon_elem| elem.* = zonCast(result_pointer.child, zon_elem, symbols);
  48                    break :blk temp_elems;
  49                };
  50                return &elems;
  51            },
  52            .@"struct" => |result_struct| {
  53                comptime var used_zon_fields = 0;
  54                var result: Result = undefined;
  55                inline for (result_struct.fields) |result_field| @field(result, result_field.name) = if (@hasField(ZonValue, result_field.name)) result: {
  56                    used_zon_fields += 1;
  57                    break :result zonCast(@FieldType(Result, result_field.name), @field(zon_value, result_field.name), symbols);
  58                } else result_field.defaultValue() orelse @compileError(std.fmt.comptimePrint("missing zon field '{s}': {} <- {any}", .{ result_field.name, Result, zon_value }));
  59                if (used_zon_fields != zon_struct.fields.len) @compileError(std.fmt.comptimePrint("unused zon field: {} <- {any}", .{ Result, zon_value }));
  60                return result;
  61            },
  62            .@"union" => {
  63                if (zon_struct.fields.len != 1) @compileError(std.fmt.comptimePrint("{} <- {any}", .{ Result, zon_value }));
  64                const field_name = zon_struct.fields[0].name;
  65                return @unionInit(
  66                    Result,
  67                    field_name,
  68                    zonCast(@FieldType(Result, field_name), @field(zon_value, field_name), symbols),
  69                );
  70            },
  71            else => @compileError(std.fmt.comptimePrint("unsupported zon type: {} <- {any}", .{ Result, zon_value })),
  72        },
  73        .enum_literal => if (@hasField(Symbols, @tagName(zon_value))) {
  74            const symbol = @field(symbols, @tagName(zon_value));
  75            const Symbol = @TypeOf(symbol);
  76            switch (@typeInfo(Result)) {
  77                .@"enum" => switch (@typeInfo(Symbol)) {
  78                    .int => |info| {
  79                        var buf: [
  80                            std.fmt.count("{d}", .{switch (info.signedness) {
  81                                .signed => std.math.minInt(Symbol),
  82                                .unsigned => std.math.maxInt(Symbol),
  83                            }})
  84                        ]u8 = undefined;
  85                        return std.meta.stringToEnum(Result, std.fmt.bufPrint(&buf, "{d}", .{symbol}) catch unreachable).?;
  86                    },
  87                    else => return symbol,
  88                },
  89                else => return symbol,
  90            }
  91        } else {
  92            const Container = switch (@typeInfo(Result)) {
  93                else => struct {},
  94                .@"struct", .@"enum", .@"union", .@"opaque" => Result,
  95                .optional => |info| info.child,
  96                .error_union => |info| info.payload,
  97            };
  98            return if (@hasDecl(Container, @tagName(zon_value))) @field(Container, @tagName(zon_value)) else zon_value;
  99        },
 100        else => @compileError(std.fmt.comptimePrint("unsupported zon type: {} <- {any}", .{ Result, zon_value })),
 101    }
 102}
 103
 104const matchers = matchers: {
 105    const instructions = @import("instructions.zon");
 106    var mut_matchers: [instructions.len]*const fn (as: *Assemble) error{InvalidSyntax}!?Instruction = undefined;
 107    for (instructions, &mut_matchers) |instruction, *matcher| matcher.* = struct {
 108        fn match(as: *Assemble) !?Instruction {
 109            comptime for (@typeInfo(@TypeOf(instruction)).@"struct".fields) |field| {
 110                if (std.mem.eql(u8, field.name, "requires")) continue;
 111                if (std.mem.eql(u8, field.name, "pattern")) continue;
 112                if (std.mem.eql(u8, field.name, "symbols")) continue;
 113                if (std.mem.eql(u8, field.name, "encode")) continue;
 114                @compileError("unexpected field '" ++ field.name ++ "'");
 115            };
 116            if (@hasField(@TypeOf(instruction), "requires")) _ = zonCast(
 117                []const std.Target.aarch64.Feature,
 118                instruction.requires,
 119                .{},
 120            );
 121            var symbols: Symbols: {
 122                const symbols = @typeInfo(@TypeOf(instruction.symbols)).@"struct".fields;
 123                var field_names: [symbols.len][]const u8 = undefined;
 124                var field_types: [symbols.len]type = undefined;
 125                for (symbols, &field_names, &field_types) |symbol, *field_name, *FieldType| {
 126                    field_name.* = symbol.name;
 127                    FieldType.* = zonCast(SymbolSpec, @field(instruction.symbols, symbol.name), .{}).Storage();
 128                }
 129                break :Symbols @Struct(.auto, null, &field_names, &field_types, &@splat(.{}));
 130            } = undefined;
 131            const Symbol = std.meta.FieldEnum(@TypeOf(instruction.symbols));
 132            comptime var unused_symbols: std.enums.EnumSet(Symbol) = .initFull();
 133            comptime var pattern_as: Assemble = .{ .source = instruction.pattern, .operands = undefined };
 134            inline while (true) {
 135                comptime var ct_token_buf: [token_buf_len]u8 = undefined;
 136                var token_buf: [token_buf_len]u8 = undefined;
 137                const pattern_token = comptime pattern_as.nextToken(&ct_token_buf, .{ .placeholders = true }) catch |err|
 138                    @compileError(@errorName(err) ++ " while parsing '" ++ instruction.pattern ++ "'");
 139                const source_token = try as.nextToken(&token_buf, .{ .operands = true });
 140                log.debug("\"{f}\" -> \"{f}\"", .{
 141                    std.zig.fmtString(pattern_token),
 142                    std.zig.fmtString(source_token),
 143                });
 144                if (pattern_token.len == 0) {
 145                    comptime var unused_symbol_it = unused_symbols.iterator();
 146                    inline while (comptime unused_symbol_it.next()) |unused_symbol|
 147                        @compileError(@tagName(unused_symbol) ++ " unused while parsing '" ++ instruction.pattern ++ "'");
 148                    switch (source_token.len) {
 149                        0 => {},
 150                        else => switch (source_token[0]) {
 151                            else => {
 152                                log.debug("'{s}' not matched...", .{instruction.pattern});
 153                                return null;
 154                            },
 155                            '\n', ';' => {},
 156                        },
 157                    }
 158                    const encode = @field(Instruction, @tagName(instruction.encode[0]));
 159                    const Encode = @TypeOf(encode);
 160                    var args: std.meta.ArgsTuple(Encode) = undefined;
 161                    inline for (&args, @typeInfo(Encode).@"fn".params, 1..instruction.encode.len) |*arg, param, encode_index|
 162                        arg.* = zonCast(param.type.?, instruction.encode[encode_index], symbols);
 163                    return @call(.auto, encode, args);
 164                } else if (pattern_token[0] == '<') {
 165                    const symbol_name = comptime pattern_token[1 .. std.mem.indexOfScalarPos(u8, pattern_token, 1, '|') orelse
 166                        pattern_token.len - 1];
 167                    const symbol = @field(Symbol, symbol_name);
 168                    const symbol_ptr = &@field(symbols, symbol_name);
 169                    const symbol_value = zonCast(SymbolSpec, @field(instruction.symbols, symbol_name), .{}).parse(source_token) orelse {
 170                        log.debug("'{s}' not matched...", .{instruction.pattern});
 171                        return null;
 172                    };
 173                    if (comptime unused_symbols.contains(symbol)) {
 174                        log.debug("{s} = {any}", .{ symbol_name, symbol_value });
 175                        symbol_ptr.* = symbol_value;
 176                        comptime unused_symbols.remove(symbol);
 177                    } else if (symbol_ptr.* != symbol_value) {
 178                        log.debug("'{s}' not matched...", .{instruction.pattern});
 179                        return null;
 180                    }
 181                } else if (!toUpperEqlAssertUpper(source_token, pattern_token)) {
 182                    log.debug("'{s}' not matched...", .{instruction.pattern});
 183                    return null;
 184                }
 185            }
 186        }
 187    }.match;
 188    break :matchers mut_matchers;
 189};
 190
 191fn toUpperEqlAssertUpper(lhs: []const u8, rhs: []const u8) bool {
 192    if (lhs.len != rhs.len) return false;
 193    for (lhs, rhs) |l, r| {
 194        assert(!std.ascii.isLower(r));
 195        if (std.ascii.toUpper(l) != r) return false;
 196    }
 197    return true;
 198}
 199
 200const token_buf_len = "v31.b[15]".len;
 201fn nextToken(as: *Assemble, buf: *[token_buf_len]u8, comptime opts: struct {
 202    operands: bool = false,
 203    placeholders: bool = false,
 204}) ![]const u8 {
 205    const invalid_syntax: u8 = 1;
 206    while (true) c: switch (as.source[0]) {
 207        0 => return as.source[0..0],
 208        '\t', '\n' + 1...'\r', ' ' => as.source = as.source[1..],
 209        '\n', '!', '#', ',', ';', '[', ']' => {
 210            defer as.source = as.source[1..];
 211            return as.source[0..1];
 212        },
 213        '%' => if (opts.operands) {
 214            if (as.source[1] != '[') continue :c invalid_syntax;
 215            const name_start: usize = 2;
 216            var index = name_start;
 217            while (switch (as.source[index]) {
 218                else => true,
 219                ':', ']' => false,
 220            }) index += 1;
 221            const operand = as.operands.get(as.source[name_start..index]) orelse continue :c invalid_syntax;
 222            const modifier = modifier: switch (as.source[index]) {
 223                else => unreachable,
 224                ':' => {
 225                    index += 1;
 226                    const modifier_start = index;
 227                    while (switch (as.source[index]) {
 228                        else => true,
 229                        ']' => false,
 230                    }) index += 1;
 231                    break :modifier as.source[modifier_start..index];
 232                },
 233                ']' => "",
 234            };
 235            assert(as.source[index] == ']');
 236            const modified_operand: Operand = if (std.mem.eql(u8, modifier, ""))
 237                operand
 238            else if (std.mem.eql(u8, modifier, "w")) switch (operand) {
 239                .register => |reg| .{ .register = reg.alias.w() },
 240            } else if (std.mem.eql(u8, modifier, "x")) switch (operand) {
 241                .register => |reg| .{ .register = reg.alias.x() },
 242            } else if (std.mem.eql(u8, modifier, "b")) switch (operand) {
 243                .register => |reg| .{ .register = reg.alias.b() },
 244            } else if (std.mem.eql(u8, modifier, "h")) switch (operand) {
 245                .register => |reg| .{ .register = reg.alias.h() },
 246            } else if (std.mem.eql(u8, modifier, "s")) switch (operand) {
 247                .register => |reg| .{ .register = reg.alias.s() },
 248            } else if (std.mem.eql(u8, modifier, "d")) switch (operand) {
 249                .register => |reg| .{ .register = reg.alias.d() },
 250            } else if (std.mem.eql(u8, modifier, "q")) switch (operand) {
 251                .register => |reg| .{ .register = reg.alias.q() },
 252            } else if (std.mem.eql(u8, modifier, "Z")) switch (operand) {
 253                .register => |reg| .{ .register = reg.alias.z() },
 254            } else continue :c invalid_syntax;
 255            switch (modified_operand) {
 256                .register => |reg| {
 257                    as.source = as.source[index + 1 ..];
 258                    return std.fmt.bufPrint(buf, "{f}", .{reg.fmt()}) catch unreachable;
 259                },
 260            }
 261        } else continue :c invalid_syntax,
 262        '+', '-', '.', '0'...'9', 'A'...'Z', '_', 'a'...'z' => {
 263            var index: usize = 1;
 264            while (more: switch (as.source[index]) {
 265                '0'...'9' => true,
 266                'A'...'Z', '_', 'a'...'z' => switch (as.source[0]) {
 267                    else => true,
 268                    '.' => {
 269                        index = 1;
 270                        break :more false;
 271                    },
 272                },
 273                '.' => switch (as.source[0]) {
 274                    else => unreachable,
 275                    '+', '-', '.', '0'...'9' => true,
 276                    'A'...'Z', '_', 'a'...'z' => false,
 277                },
 278                else => false,
 279            }) index += 1;
 280            defer as.source = as.source[index..];
 281            return as.source[0..index];
 282        },
 283        '<' => if (opts.placeholders) {
 284            var index: usize = 1;
 285            while (switch (as.source[index]) {
 286                0 => return error.UnterminatedPlaceholder,
 287                '>' => false,
 288                else => true,
 289            }) index += 1;
 290            defer as.source = as.source[index + 1 ..];
 291            return as.source[0 .. index + 1];
 292        } else continue :c invalid_syntax,
 293        else => {
 294            if (!@inComptime()) log.debug("invalid token \"{f}\"", .{std.zig.fmtString(std.mem.span(as.source))});
 295            return error.InvalidSyntax;
 296        },
 297    };
 298}
 299
 300const SymbolSpec = union(enum) {
 301    reg_alias: aarch64.encoding.Register.Format.Alias,
 302    reg: struct { format: aarch64.encoding.Register.Format, allow_sp: bool = false },
 303    arrangement: struct {
 304        elem_size: ?Instruction.DataProcessingVector.Size = null,
 305        allow_double: bool = true,
 306        min_valid_len: comptime_int = 0,
 307    },
 308    systemreg,
 309    imm: struct {
 310        type: std.builtin.Type.Int,
 311        multiple_of: ?comptime_int = null,
 312        min_valid: ?comptime_int = null,
 313        max_valid: ?comptime_int = null,
 314        adjust: enum { none, neg_wrap, dec } = .none,
 315    },
 316    fimm: struct { only_valid: ?f16 = null },
 317    extend: struct { size: ?aarch64.encoding.Register.GeneralSize = null },
 318    shift: struct { allow_ror: bool = true },
 319    barrier: struct { only_sy: bool = false },
 320
 321    fn Storage(comptime spec: SymbolSpec) type {
 322        return switch (spec) {
 323            .reg_alias => aarch64.encoding.Register.Alias,
 324            .reg => aarch64.encoding.Register,
 325            .arrangement => aarch64.encoding.Register.Arrangement,
 326            .systemreg => aarch64.encoding.Register.System,
 327            .imm => |imm_spec| @Int(imm_spec.type.signedness, imm_spec.type.bits),
 328            .fimm => f16,
 329            .extend => Instruction.DataProcessingRegister.AddSubtractExtendedRegister.Option,
 330            .shift => Instruction.DataProcessingRegister.Shift.Op,
 331            .barrier => Instruction.BranchExceptionGeneratingSystem.Barriers.Option,
 332        };
 333    }
 334
 335    fn parse(comptime spec: SymbolSpec, token: []const u8) ?Storage(spec) {
 336        const Result = Storage(spec);
 337        switch (spec) {
 338            .reg_alias => |reg_alias_spec| {
 339                const reg = aarch64.encoding.Register.parse(token) orelse {
 340                    log.debug("invalid register: \"{f}\"", .{std.zig.fmtString(token)});
 341                    return null;
 342                };
 343                if (reg.format != .alias or reg.format.alias != reg_alias_spec) {
 344                    log.debug("invalid register size: \"{f}\"", .{std.zig.fmtString(token)});
 345                    return null;
 346                }
 347                return reg.alias;
 348            },
 349            .reg => |reg_spec| {
 350                const reg = Result.parse(token) orelse {
 351                    log.debug("invalid register: \"{f}\"", .{std.zig.fmtString(token)});
 352                    return null;
 353                };
 354                if (switch (reg_spec.format) {
 355                    .alias, .vector, .element, .scalable => comptime unreachable,
 356                    .general => |general_spec| reg.format != .general or reg.format.general != general_spec,
 357                    .scalar => |scalar_spec| reg.format != .scalar or reg.format.scalar != scalar_spec,
 358                }) {
 359                    log.debug("invalid register size: \"{f}\"", .{std.zig.fmtString(token)});
 360                    return null;
 361                }
 362                if (reg.alias == if (reg_spec.allow_sp) .zr else .sp) {
 363                    log.debug("invalid register usage: \"{f}\"", .{std.zig.fmtString(token)});
 364                    return null;
 365                }
 366                return reg;
 367            },
 368            .arrangement => |arrangement_spec| {
 369                var buf: [
 370                    max_len: {
 371                        var max_len = 0;
 372                        for (@typeInfo(Result).@"enum".fields) |field| max_len = @max(max_len, field.name.len);
 373                        break :max_len max_len;
 374                    } + 1
 375                ]u8 = undefined;
 376                const arrangement = std.meta.stringToEnum(Result, std.ascii.lowerString(
 377                    &buf,
 378                    token[0..@min(token.len, buf.len)],
 379                )) orelse {
 380                    log.debug("invalid arrangement: \"{f}\"", .{std.zig.fmtString(token)});
 381                    return null;
 382                };
 383                if (arrangement_spec.elem_size) |elem_size| if (arrangement.elemSize() != elem_size) {
 384                    log.debug("invalid arrangement: \"{f}\"", .{std.zig.fmtString(token)});
 385                    return null;
 386                };
 387                if (!arrangement_spec.allow_double and arrangement.elemSize() == .double) {
 388                    log.debug("invalid arrangement: \"{f}\"", .{std.zig.fmtString(token)});
 389                    return null;
 390                }
 391                if (arrangement.len() < arrangement_spec.min_valid_len) {
 392                    log.debug("invalid arrangement: \"{f}\"", .{std.zig.fmtString(token)});
 393                    return null;
 394                }
 395                return arrangement;
 396            },
 397            .systemreg => {
 398                const systemreg = Result.parse(token) orelse {
 399                    log.debug("invalid system register: \"{f}\"", .{std.zig.fmtString(token)});
 400                    return null;
 401                };
 402                assert(systemreg.op0 >= 2);
 403                return systemreg;
 404            },
 405            .imm => |imm_spec| {
 406                const imm = std.fmt.parseInt(@Int(
 407                    imm_spec.type.signedness,
 408                    switch (imm_spec.adjust) {
 409                        .none, .neg_wrap => imm_spec.type.bits,
 410                        .dec => imm_spec.type.bits + 1,
 411                    },
 412                ), token, 0) catch {
 413                    log.debug("invalid immediate: \"{f}\"", .{std.zig.fmtString(token)});
 414                    return null;
 415                };
 416                if (imm_spec.multiple_of) |multiple_of| if (@rem(imm, multiple_of) != 0) {
 417                    log.debug("invalid immediate usage: \"{f}\"", .{std.zig.fmtString(token)});
 418                    return null;
 419                };
 420                if (imm_spec.min_valid) |min_valid| if (imm < min_valid) {
 421                    log.debug("out of range immediate: \"{f}\"", .{std.zig.fmtString(token)});
 422                    return null;
 423                };
 424                if (imm_spec.max_valid) |max_valid| if (imm > max_valid) {
 425                    log.debug("out of range immediate: \"{f}\"", .{std.zig.fmtString(token)});
 426                    return null;
 427                };
 428                return switch (imm_spec.adjust) {
 429                    .none => imm,
 430                    .neg_wrap => -%imm,
 431                    .dec => std.math.cast(Result, imm - 1) orelse {
 432                        log.debug("out of range immediate: \"{f}\"", .{std.zig.fmtString(token)});
 433                        return null;
 434                    },
 435                };
 436            },
 437            .fimm => |fimm_spec| {
 438                const full_fimm = std.fmt.parseFloat(f128, token) catch {
 439                    log.debug("invalid immediate: \"{f}\"", .{std.zig.fmtString(token)});
 440                    return null;
 441                };
 442                const fimm: f16 = @floatCast(full_fimm);
 443                if (fimm != full_fimm) {
 444                    log.debug("out of range immediate: \"{f}\"", .{std.zig.fmtString(token)});
 445                    return null;
 446                }
 447                if (fimm_spec.only_valid) |only_valid| {
 448                    if (@as(u16, @bitCast(fimm)) != @as(u16, @bitCast(only_valid))) {
 449                        log.debug("out of range immediate: \"{f}\"", .{std.zig.fmtString(token)});
 450                        return null;
 451                    }
 452                } else {
 453                    const Repr = std.math.FloatRepr(f16);
 454                    const repr: Repr = @bitCast(fimm);
 455                    if (repr.mantissa & std.math.maxInt(Repr.Mantissa) >> 5 != 0 or switch (repr.exponent) {
 456                        .denormal, .infinite => true,
 457                        else => std.math.cast(i3, repr.exponent.unbias() - 1) == null,
 458                    }) {
 459                        log.debug("out of range immediate: \"{f}\"", .{std.zig.fmtString(token)});
 460                        return null;
 461                    }
 462                }
 463                return fimm;
 464            },
 465            .extend => |extend_spec| {
 466                var buf: [
 467                    max_len: {
 468                        var max_len = 0;
 469                        for (@typeInfo(Result).@"enum".fields) |field| max_len = @max(max_len, field.name.len);
 470                        break :max_len max_len;
 471                    } + 1
 472                ]u8 = undefined;
 473                const extend = std.meta.stringToEnum(Result, std.ascii.lowerString(
 474                    &buf,
 475                    token[0..@min(token.len, buf.len)],
 476                )) orelse {
 477                    log.debug("invalid extend: \"{f}\"", .{std.zig.fmtString(token)});
 478                    return null;
 479                };
 480                if (extend_spec.size) |size| if (extend.sf() != size) {
 481                    log.debug("invalid extend: \"{f}\"", .{std.zig.fmtString(token)});
 482                    return null;
 483                };
 484                return extend;
 485            },
 486            .shift => |shift_spec| {
 487                var buf: [
 488                    max_len: {
 489                        var max_len = 0;
 490                        for (@typeInfo(Result).@"enum".fields) |field| max_len = @max(max_len, field.name.len);
 491                        break :max_len max_len;
 492                    } + 1
 493                ]u8 = undefined;
 494                const shift = std.meta.stringToEnum(Result, std.ascii.lowerString(
 495                    &buf,
 496                    token[0..@min(token.len, buf.len)],
 497                )) orelse {
 498                    log.debug("invalid shift: \"{f}\"", .{std.zig.fmtString(token)});
 499                    return null;
 500                };
 501                if (!shift_spec.allow_ror and shift == .ror) {
 502                    log.debug("invalid shift usage: \"{f}\"", .{std.zig.fmtString(token)});
 503                    return null;
 504                }
 505                return shift;
 506            },
 507            .barrier => |barrier_spec| {
 508                var buf: [
 509                    max_len: {
 510                        var max_len = 0;
 511                        for (@typeInfo(Result).@"enum".fields) |field| max_len = @max(max_len, field.name.len);
 512                        break :max_len max_len;
 513                    } + 1
 514                ]u8 = undefined;
 515                const barrier = std.meta.stringToEnum(Result, std.ascii.lowerString(
 516                    &buf,
 517                    token[0..@min(token.len, buf.len)],
 518                )) orelse {
 519                    log.debug("invalid barrier: \"{f}\"", .{std.zig.fmtString(token)});
 520                    return null;
 521                };
 522                if (barrier_spec.only_sy and barrier != .sy) {
 523                    log.debug("invalid barrier: \"{f}\"", .{std.zig.fmtString(token)});
 524                    return null;
 525                }
 526                return barrier;
 527            },
 528        }
 529    }
 530};
 531
 532test "add sub" {
 533    var as: Assemble = .{
 534        .source =
 535        \\ adc w0, w0, w1
 536        \\ adc w2, w3, w4
 537        \\ adc w5, w5, wzr
 538        \\ adc w6, w7, wzr
 539        \\
 540        \\ adcs w0, w0, w1
 541        \\ adcs w2, w3, w4
 542        \\ adcs w5, w5, wzr
 543        \\ adcs w6, w7, wzr
 544        \\
 545        \\ add w0, w0, w1
 546        \\ add w2, w3, w4
 547        \\ add wsp, w5, w6
 548        \\ add w7, wsp, w8
 549        \\ add wsp, wsp, w9
 550        \\ add w10, w10, wzr
 551        \\ add w11, w12, wzr
 552        \\ add wsp, w13, wzr
 553        \\ add w14, wsp, wzr
 554        \\ add wsp, wsp, wzr
 555        \\
 556        \\ add x0, x0, x1
 557        \\ add x2, x3, x4
 558        \\ add sp, x5, x6
 559        \\ add x7, sp, x8
 560        \\ add sp, sp, x9
 561        \\ add x10, x10, xzr
 562        \\ add x11, x12, xzr
 563        \\ add sp, x13, xzr
 564        \\ add x14, sp, xzr
 565        \\ add sp, sp, xzr
 566        \\
 567        \\ add w0, w0, w1
 568        \\ add w2, w3, w4, uxtb #0
 569        \\ add wsp, w5, w6, uxth #1
 570        \\ add w7, wsp, w8, uxtw #2
 571        \\ add wsp, wsp, w9, uxtx #0
 572        \\ add w10, w10, wzr, uxtx #3
 573        \\ add w11, w12, wzr, sxtb #4
 574        \\ add wsp, w13, wzr, sxth #0
 575        \\ add w14, wsp, wzr, sxtw #1
 576        \\ add wsp, wsp, wzr, sxtx #2
 577        \\
 578        \\ add x0, x0, x1
 579        \\ add x2, x3, w4, uxtb #0
 580        \\ add sp, x5, w6, uxth #1
 581        \\ add x7, sp, w8, uxtw #2
 582        \\ add sp, sp, x9, uxtx #0
 583        \\ add x10, x10, xzr, uxtx #3
 584        \\ add x11, x12, wzr, sxtb #4
 585        \\ add sp, x13, wzr, sxth #0
 586        \\ add x14, sp, wzr, sxtw #1
 587        \\ add sp, sp, xzr, sxtx #2
 588        \\
 589        \\ add w0, w0, #0
 590        \\ add w0, w1, #1, lsl #0
 591        \\ add wsp, w2, #2, lsl #12
 592        \\ add w3, wsp, #3, lsl #0
 593        \\ add wsp, wsp, #4095, lsl #12
 594        \\ add w0, w1, #0
 595        \\ add w2, w3, #0, lsl #0
 596        \\ add w4, wsp, #0
 597        \\ add w5, wsp, #0, lsl #0
 598        \\ add wsp, w6, #0
 599        \\ add wsp, w7, #0, lsl #0
 600        \\ add wsp, wsp, #0
 601        \\ add wsp, wsp, #0, lsl #0
 602        \\
 603        \\ add x0, x0, #0
 604        \\ add x0, x1, #1, lsl #0
 605        \\ add sp, x2, #2, lsl #12
 606        \\ add x3, sp, #3, lsl #0
 607        \\ add sp, sp, #4095, lsl #12
 608        \\ add x0, x1, #0
 609        \\ add x2, x3, #0, lsl #0
 610        \\ add x4, sp, #0
 611        \\ add x5, sp, #0, lsl #0
 612        \\ add sp, x6, #0
 613        \\ add sp, x7, #0, lsl #0
 614        \\ add sp, sp, #0
 615        \\ add sp, sp, #0, lsl #0
 616        \\
 617        \\ add w0, w0, w0
 618        \\ add w1, w1, w2, lsl #0
 619        \\ add w3, w4, w5, lsl #1
 620        \\ add w6, w6, wzr, lsl #31
 621        \\ add w7, wzr, w8, lsr #0
 622        \\ add w9, wzr, wzr, lsr #30
 623        \\ add wzr, w10, w11, lsr #31
 624        \\ add wzr, w12, wzr, asr #0x0
 625        \\ add wzr, wzr, w13, asr #0x10
 626        \\ add wzr, wzr, wzr, asr #0x1f
 627        \\
 628        \\ add x0, x0, x0
 629        \\ add x1, x1, x2, lsl #0
 630        \\ add x3, x4, x5, lsl #1
 631        \\ add x6, x6, xzr, lsl #63
 632        \\ add x7, xzr, x8, lsr #0
 633        \\ add x9, xzr, xzr, lsr #62
 634        \\ add xzr, x10, x11, lsr #63
 635        \\ add xzr, x12, xzr, asr #0x0
 636        \\ add xzr, xzr, x13, asr #0x1F
 637        \\ add xzr, xzr, xzr, asr #0x3f
 638        \\
 639        \\ addg x0, sp, #0, #0xf
 640        \\ addg sp, x1, #0x3f0, #0
 641        \\
 642        \\ adds w0, w0, w1
 643        \\ adds w2, w3, w4
 644        \\ adds w5, w5, w6
 645        \\ adds w7, wsp, w8
 646        \\ adds w9, wsp, w9
 647        \\ adds w10, w10, wzr
 648        \\ adds w11, w12, wzr
 649        \\ adds wzr, w13, wzr
 650        \\ adds w14, wsp, wzr
 651        \\ adds wzr, wsp, wzr
 652        \\
 653        \\ adds x0, x0, x1
 654        \\ adds x2, x3, x4
 655        \\ adds x5, x5, x6
 656        \\ adds x7, sp, x8
 657        \\ adds x9, sp, x9
 658        \\ adds x10, x10, xzr
 659        \\ adds x11, x12, xzr
 660        \\ adds xzr, x13, xzr
 661        \\ adds x14, sp, xzr
 662        \\ adds xzr, sp, xzr
 663        \\
 664        \\ adds w0, w0, w1
 665        \\ adds w2, w3, w4, uxtb #0
 666        \\ adds wzr, w5, w6, uxth #1
 667        \\ adds w7, wsp, w8, uxtw #2
 668        \\ adds w9, wsp, w9, uxtx #0
 669        \\ adds w10, w10, wzr, uxtx #3
 670        \\ adds w11, w12, wzr, sxtb #4
 671        \\ adds wzr, w13, wzr, sxth #0
 672        \\ adds w14, wsp, wzr, sxtw #1
 673        \\ adds wzr, wsp, wzr, sxtx #2
 674        \\
 675        \\ adds x0, x0, x1
 676        \\ adds x2, x3, w4, uxtb #0
 677        \\ adds xzr, x5, w6, uxth #1
 678        \\ adds x7, sp, w8, uxtw #2
 679        \\ adds xzr, sp, x9, uxtx #0
 680        \\ adds x10, x10, xzr, uxtx #3
 681        \\ adds x11, x12, wzr, sxtb #4
 682        \\ adds xzr, x13, wzr, sxth #0
 683        \\ adds x14, sp, wzr, sxtw #1
 684        \\ adds xzr, sp, xzr, sxtx #2
 685        \\
 686        \\ adds w0, w0, #0
 687        \\ adds w0, w1, #1, lsl #0
 688        \\ adds wzr, w2, #2, lsl #12
 689        \\ adds w3, wsp, #3, lsl #0
 690        \\ adds wzr, wsp, #4095, lsl #12
 691        \\ adds w0, w1, #0
 692        \\ adds w2, w3, #0, lsl #0
 693        \\ adds w4, wsp, #0
 694        \\ adds w5, wsp, #0, lsl #0
 695        \\ adds wzr, w6, #0
 696        \\ adds wzr, w7, #0, lsl #0
 697        \\ adds wzr, wsp, #0
 698        \\ adds wzr, wsp, #0, lsl #0
 699        \\
 700        \\ adds x0, x0, #0
 701        \\ adds x0, x1, #1, lsl #0
 702        \\ adds xzr, x2, #2, lsl #12
 703        \\ adds x3, sp, #3, lsl #0
 704        \\ adds xzr, sp, #4095, lsl #12
 705        \\ adds x0, x1, #0
 706        \\ adds x2, x3, #0, lsl #0
 707        \\ adds x4, sp, #0
 708        \\ adds x5, sp, #0, lsl #0
 709        \\ adds xzr, x6, #0
 710        \\ adds xzr, x7, #0, lsl #0
 711        \\ adds xzr, sp, #0
 712        \\ adds xzr, sp, #0, lsl #0
 713        \\
 714        \\ adds w0, w0, w0
 715        \\ adds w1, w1, w2, lsl #0
 716        \\ adds w3, w4, w5, lsl #1
 717        \\ adds w6, w6, wzr, lsl #31
 718        \\ adds w7, wzr, w8, lsr #0
 719        \\ adds w9, wzr, wzr, lsr #30
 720        \\ adds wzr, w10, w11, lsr #31
 721        \\ adds wzr, w12, wzr, asr #0x0
 722        \\ adds wzr, wzr, w13, asr #0x10
 723        \\ adds wzr, wzr, wzr, asr #0x1f
 724        \\
 725        \\ adds x0, x0, x0
 726        \\ adds x1, x1, x2, lsl #0
 727        \\ adds x3, x4, x5, lsl #1
 728        \\ adds x6, x6, xzr, lsl #63
 729        \\ adds x7, xzr, x8, lsr #0
 730        \\ adds x9, xzr, xzr, lsr #62
 731        \\ adds xzr, x10, x11, lsr #63
 732        \\ adds xzr, x12, xzr, asr #0x0
 733        \\ adds xzr, xzr, x13, asr #0x1F
 734        \\ adds xzr, xzr, xzr, asr #0x3f
 735        \\
 736        \\ neg w0, w0
 737        \\ neg w1, w2, lsl #0
 738        \\ neg w3, wzr, lsl #7
 739        \\ neg wzr, w4, lsr #14
 740        \\ neg wzr, wzr, asr #21
 741        \\
 742        \\ neg x0, x0
 743        \\ neg x1, x2, lsl #0
 744        \\ neg x3, xzr, lsl #11
 745        \\ neg xzr, x4, lsr #22
 746        \\ neg xzr, xzr, asr #33
 747        \\
 748        \\ sbc w0, w0, w1
 749        \\ sbc w2, w3, w4
 750        \\ sbc w5, w5, wzr
 751        \\ sbc w6, w7, wzr
 752        \\
 753        \\ sbcs w0, w0, w1
 754        \\ sbcs w2, w3, w4
 755        \\ sbcs w5, w5, wzr
 756        \\ sbcs w6, w7, wzr
 757        \\
 758        \\ sub w0, w0, w1
 759        \\ sub w2, w3, w4
 760        \\ sub wsp, w5, w6
 761        \\ sub w7, wsp, w8
 762        \\ sub wsp, wsp, w9
 763        \\ sub w10, w10, wzr
 764        \\ sub w11, w12, wzr
 765        \\ sub wsp, w13, wzr
 766        \\ sub w14, wsp, wzr
 767        \\ sub wsp, wsp, wzr
 768        \\
 769        \\ sub x0, x0, x1
 770        \\ sub x2, x3, x4
 771        \\ sub sp, x5, x6
 772        \\ sub x7, sp, x8
 773        \\ sub sp, sp, x9
 774        \\ sub x10, x10, xzr
 775        \\ sub x11, x12, xzr
 776        \\ sub sp, x13, xzr
 777        \\ sub x14, sp, xzr
 778        \\ sub sp, sp, xzr
 779        \\
 780        \\ sub w0, w0, w1
 781        \\ sub w2, w3, w4, uxtb #0
 782        \\ sub wsp, w5, w6, uxth #1
 783        \\ sub w7, wsp, w8, uxtw #2
 784        \\ sub wsp, wsp, w9, uxtx #0
 785        \\ sub w10, w10, wzr, uxtx #3
 786        \\ sub w11, w12, wzr, sxtb #4
 787        \\ sub wsp, w13, wzr, sxth #0
 788        \\ sub w14, wsp, wzr, sxtw #1
 789        \\ sub wsp, wsp, wzr, sxtx #2
 790        \\
 791        \\ sub x0, x0, x1
 792        \\ sub x2, x3, w4, uxtb #0
 793        \\ sub sp, x5, w6, uxth #1
 794        \\ sub x7, sp, w8, uxtw #2
 795        \\ sub sp, sp, x9, uxtx #0
 796        \\ sub x10, x10, xzr, uxtx #3
 797        \\ sub x11, x12, wzr, sxtb #4
 798        \\ sub sp, x13, wzr, sxth #0
 799        \\ sub x14, sp, wzr, sxtw #1
 800        \\ sub sp, sp, xzr, sxtx #2
 801        \\
 802        \\ sub w0, w0, #0
 803        \\ sub w0, w1, #1, lsl #0
 804        \\ sub wsp, w2, #2, lsl #12
 805        \\ sub w3, wsp, #3, lsl #0
 806        \\ sub wsp, wsp, #4095, lsl #12
 807        \\ sub w0, w1, #0
 808        \\ sub w2, w3, #0, lsl #0
 809        \\ sub w4, wsp, #0
 810        \\ sub w5, wsp, #0, lsl #0
 811        \\ sub wsp, w6, #0
 812        \\ sub wsp, w7, #0, lsl #0
 813        \\ sub wsp, wsp, #0
 814        \\ sub wsp, wsp, #0, lsl #0
 815        \\
 816        \\ sub x0, x0, #0
 817        \\ sub x0, x1, #1, lsl #0
 818        \\ sub sp, x2, #2, lsl #12
 819        \\ sub x3, sp, #3, lsl #0
 820        \\ sub sp, sp, #4095, lsl #12
 821        \\ sub x0, x1, #0
 822        \\ sub x2, x3, #0, lsl #0
 823        \\ sub x4, sp, #0
 824        \\ sub x5, sp, #0, lsl #0
 825        \\ sub sp, x6, #0
 826        \\ sub sp, x7, #0, lsl #0
 827        \\ sub sp, sp, #0
 828        \\ sub sp, sp, #0, lsl #0
 829        \\
 830        \\ sub w0, w0, w0
 831        \\ sub w1, w1, w2, lsl #0
 832        \\ sub w3, w4, w5, lsl #1
 833        \\ sub w6, w6, wzr, lsl #31
 834        \\ sub w7, wzr, w8, lsr #0
 835        \\ sub w9, wzr, wzr, lsr #30
 836        \\ sub wzr, w10, w11, lsr #31
 837        \\ sub wzr, w12, wzr, asr #0x0
 838        \\ sub wzr, wzr, w13, asr #0x10
 839        \\ sub wzr, wzr, wzr, asr #0x1f
 840        \\
 841        \\ sub x0, x0, x0
 842        \\ sub x1, x1, x2, lsl #0
 843        \\ sub x3, x4, x5, lsl #1
 844        \\ sub x6, x6, xzr, lsl #63
 845        \\ sub x7, xzr, x8, lsr #0
 846        \\ sub x9, xzr, xzr, lsr #62
 847        \\ sub xzr, x10, x11, lsr #63
 848        \\ sub xzr, x12, xzr, asr #0x0
 849        \\ sub xzr, xzr, x13, asr #0x1F
 850        \\ sub xzr, xzr, xzr, asr #0x3f
 851        \\
 852        \\ subg x0, sp, #0, #0xf
 853        \\ subg sp, x1, #0x3f0, #0
 854        \\
 855        \\ subs w0, w0, w1
 856        \\ subs w2, w3, w4
 857        \\ subs w5, w5, w6
 858        \\ subs w7, wsp, w8
 859        \\ subs w9, wsp, w9
 860        \\ subs w10, w10, wzr
 861        \\ subs w11, w12, wzr
 862        \\ subs wzr, w13, wzr
 863        \\ subs w14, wsp, wzr
 864        \\ subs wzr, wsp, wzr
 865        \\
 866        \\ subs x0, x0, x1
 867        \\ subs x2, x3, x4
 868        \\ subs x5, x5, x6
 869        \\ subs x7, sp, x8
 870        \\ subs x9, sp, x9
 871        \\ subs x10, x10, xzr
 872        \\ subs x11, x12, xzr
 873        \\ subs xzr, x13, xzr
 874        \\ subs x14, sp, xzr
 875        \\ subs xzr, sp, xzr
 876        \\
 877        \\ subs w0, w0, w1
 878        \\ subs w2, w3, w4, uxtb #0
 879        \\ subs wzr, w5, w6, uxth #1
 880        \\ subs w7, wsp, w8, uxtw #2
 881        \\ subs w9, wsp, w9, uxtx #0
 882        \\ subs w10, w10, wzr, uxtx #3
 883        \\ subs w11, w12, wzr, sxtb #4
 884        \\ subs wzr, w13, wzr, sxth #0
 885        \\ subs w14, wsp, wzr, sxtw #1
 886        \\ subs wzr, wsp, wzr, sxtx #2
 887        \\
 888        \\ subs x0, x0, x1
 889        \\ subs x2, x3, w4, uxtb #0
 890        \\ subs xzr, x5, w6, uxth #1
 891        \\ subs x7, sp, w8, uxtw #2
 892        \\ subs xzr, sp, x9, uxtx #0
 893        \\ subs x10, x10, xzr, uxtx #3
 894        \\ subs x11, x12, wzr, sxtb #4
 895        \\ subs xzr, x13, wzr, sxth #0
 896        \\ subs x14, sp, wzr, sxtw #1
 897        \\ subs xzr, sp, xzr, sxtx #2
 898        \\
 899        \\ subs w0, w0, #0
 900        \\ subs w0, w1, #1, lsl #0
 901        \\ subs wzr, w2, #2, lsl #12
 902        \\ subs w3, wsp, #3, lsl #0
 903        \\ subs wzr, wsp, #4095, lsl #12
 904        \\ subs w0, w1, #0
 905        \\ subs w2, w3, #0, lsl #0
 906        \\ subs w4, wsp, #0
 907        \\ subs w5, wsp, #0, lsl #0
 908        \\ subs wzr, w6, #0
 909        \\ subs wzr, w7, #0, lsl #0
 910        \\ subs wzr, wsp, #0
 911        \\ subs wzr, wsp, #0, lsl #0
 912        \\
 913        \\ subs x0, x0, #0
 914        \\ subs x0, x1, #1, lsl #0
 915        \\ subs xzr, x2, #2, lsl #12
 916        \\ subs x3, sp, #3, lsl #0
 917        \\ subs xzr, sp, #4095, lsl #12
 918        \\ subs x0, x1, #0
 919        \\ subs x2, x3, #0, lsl #0
 920        \\ subs x4, sp, #0
 921        \\ subs x5, sp, #0, lsl #0
 922        \\ subs xzr, x6, #0
 923        \\ subs xzr, x7, #0, lsl #0
 924        \\ subs xzr, sp, #0
 925        \\ subs xzr, sp, #0, lsl #0
 926        \\
 927        \\ subs w0, w0, w0
 928        \\ subs w1, w1, w2, lsl #0
 929        \\ subs w3, w4, w5, lsl #1
 930        \\ subs w6, w6, wzr, lsl #31
 931        \\ subs w7, wzr, w8, lsr #0
 932        \\ subs w9, wzr, wzr, lsr #30
 933        \\ subs wzr, w10, w11, lsr #31
 934        \\ subs wzr, w12, wzr, asr #0x0
 935        \\ subs wzr, wzr, w13, asr #0x10
 936        \\ subs wzr, wzr, wzr, asr #0x1f
 937        \\
 938        \\ subs x0, x0, x0
 939        \\ subs x1, x1, x2, lsl #0
 940        \\ subs x3, x4, x5, lsl #1
 941        \\ subs x6, x6, xzr, lsl #63
 942        \\ subs x7, xzr, x8, lsr #0
 943        \\ subs x9, xzr, xzr, lsr #62
 944        \\ subs xzr, x10, x11, lsr #63
 945        \\ subs xzr, x12, xzr, asr #0x0
 946        \\ subs xzr, xzr, x13, asr #0x1F
 947        \\ subs xzr, xzr, xzr, asr #0x3f
 948        ,
 949        .operands = .empty,
 950    };
 951
 952    try std.testing.expectFmt("adc w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
 953    try std.testing.expectFmt("adc w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
 954    try std.testing.expectFmt("adc w5, w5, wzr", "{f}", .{(try as.nextInstruction()).?});
 955    try std.testing.expectFmt("adc w6, w7, wzr", "{f}", .{(try as.nextInstruction()).?});
 956
 957    try std.testing.expectFmt("adcs w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
 958    try std.testing.expectFmt("adcs w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
 959    try std.testing.expectFmt("adcs w5, w5, wzr", "{f}", .{(try as.nextInstruction()).?});
 960    try std.testing.expectFmt("adcs w6, w7, wzr", "{f}", .{(try as.nextInstruction()).?});
 961
 962    try std.testing.expectFmt("add w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
 963    try std.testing.expectFmt("add w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
 964    try std.testing.expectFmt("add wsp, w5, w6", "{f}", .{(try as.nextInstruction()).?});
 965    try std.testing.expectFmt("add w7, wsp, w8", "{f}", .{(try as.nextInstruction()).?});
 966    try std.testing.expectFmt("add wsp, wsp, w9", "{f}", .{(try as.nextInstruction()).?});
 967    try std.testing.expectFmt("add w10, w10, wzr", "{f}", .{(try as.nextInstruction()).?});
 968    try std.testing.expectFmt("add w11, w12, wzr", "{f}", .{(try as.nextInstruction()).?});
 969    try std.testing.expectFmt("add wsp, w13, wzr", "{f}", .{(try as.nextInstruction()).?});
 970    try std.testing.expectFmt("add w14, wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
 971    try std.testing.expectFmt("add wsp, wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
 972
 973    try std.testing.expectFmt("add x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
 974    try std.testing.expectFmt("add x2, x3, x4", "{f}", .{(try as.nextInstruction()).?});
 975    try std.testing.expectFmt("add sp, x5, x6", "{f}", .{(try as.nextInstruction()).?});
 976    try std.testing.expectFmt("add x7, sp, x8", "{f}", .{(try as.nextInstruction()).?});
 977    try std.testing.expectFmt("add sp, sp, x9", "{f}", .{(try as.nextInstruction()).?});
 978    try std.testing.expectFmt("add x10, x10, xzr", "{f}", .{(try as.nextInstruction()).?});
 979    try std.testing.expectFmt("add x11, x12, xzr", "{f}", .{(try as.nextInstruction()).?});
 980    try std.testing.expectFmt("add sp, x13, xzr", "{f}", .{(try as.nextInstruction()).?});
 981    try std.testing.expectFmt("add x14, sp, xzr", "{f}", .{(try as.nextInstruction()).?});
 982    try std.testing.expectFmt("add sp, sp, xzr", "{f}", .{(try as.nextInstruction()).?});
 983
 984    try std.testing.expectFmt("add w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
 985    try std.testing.expectFmt("add w2, w3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
 986    try std.testing.expectFmt("add wsp, w5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
 987    try std.testing.expectFmt("add w7, wsp, w8, lsl #2", "{f}", .{(try as.nextInstruction()).?});
 988    try std.testing.expectFmt("add wsp, wsp, w9, uxtx", "{f}", .{(try as.nextInstruction()).?});
 989    try std.testing.expectFmt("add w10, w10, wzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
 990    try std.testing.expectFmt("add w11, w12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
 991    try std.testing.expectFmt("add wsp, w13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
 992    try std.testing.expectFmt("add w14, wsp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
 993    try std.testing.expectFmt("add wsp, wsp, wzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
 994
 995    try std.testing.expectFmt("add x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
 996    try std.testing.expectFmt("add x2, x3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
 997    try std.testing.expectFmt("add sp, x5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
 998    try std.testing.expectFmt("add x7, sp, w8, uxtw #2", "{f}", .{(try as.nextInstruction()).?});
 999    try std.testing.expectFmt("add sp, sp, x9", "{f}", .{(try as.nextInstruction()).?});
1000    try std.testing.expectFmt("add x10, x10, xzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
1001    try std.testing.expectFmt("add x11, x12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
1002    try std.testing.expectFmt("add sp, x13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
1003    try std.testing.expectFmt("add x14, sp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
1004    try std.testing.expectFmt("add sp, sp, xzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
1005
1006    try std.testing.expectFmt("add w0, w0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1007    try std.testing.expectFmt("add w0, w1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1008    try std.testing.expectFmt("add wsp, w2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1009    try std.testing.expectFmt("add w3, wsp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1010    try std.testing.expectFmt("add wsp, wsp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1011    try std.testing.expectFmt("add w0, w1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1012    try std.testing.expectFmt("add w2, w3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1013    try std.testing.expectFmt("mov w4, wsp", "{f}", .{(try as.nextInstruction()).?});
1014    try std.testing.expectFmt("mov w5, wsp", "{f}", .{(try as.nextInstruction()).?});
1015    try std.testing.expectFmt("mov wsp, w6", "{f}", .{(try as.nextInstruction()).?});
1016    try std.testing.expectFmt("mov wsp, w7", "{f}", .{(try as.nextInstruction()).?});
1017    try std.testing.expectFmt("mov wsp, wsp", "{f}", .{(try as.nextInstruction()).?});
1018    try std.testing.expectFmt("mov wsp, wsp", "{f}", .{(try as.nextInstruction()).?});
1019
1020    try std.testing.expectFmt("add x0, x0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1021    try std.testing.expectFmt("add x0, x1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1022    try std.testing.expectFmt("add sp, x2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1023    try std.testing.expectFmt("add x3, sp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1024    try std.testing.expectFmt("add sp, sp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1025    try std.testing.expectFmt("add x0, x1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1026    try std.testing.expectFmt("add x2, x3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1027    try std.testing.expectFmt("mov x4, sp", "{f}", .{(try as.nextInstruction()).?});
1028    try std.testing.expectFmt("mov x5, sp", "{f}", .{(try as.nextInstruction()).?});
1029    try std.testing.expectFmt("mov sp, x6", "{f}", .{(try as.nextInstruction()).?});
1030    try std.testing.expectFmt("mov sp, x7", "{f}", .{(try as.nextInstruction()).?});
1031    try std.testing.expectFmt("mov sp, sp", "{f}", .{(try as.nextInstruction()).?});
1032    try std.testing.expectFmt("mov sp, sp", "{f}", .{(try as.nextInstruction()).?});
1033
1034    try std.testing.expectFmt("add w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
1035    try std.testing.expectFmt("add w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
1036    try std.testing.expectFmt("add w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1037    try std.testing.expectFmt("add w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
1038    try std.testing.expectFmt("add w7, wzr, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1039    try std.testing.expectFmt("add w9, wzr, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
1040    try std.testing.expectFmt("add wzr, w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
1041    try std.testing.expectFmt("add wzr, w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1042    try std.testing.expectFmt("add wzr, wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
1043    try std.testing.expectFmt("add wzr, wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
1044
1045    try std.testing.expectFmt("add x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
1046    try std.testing.expectFmt("add x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
1047    try std.testing.expectFmt("add x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1048    try std.testing.expectFmt("add x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
1049    try std.testing.expectFmt("add x7, xzr, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1050    try std.testing.expectFmt("add x9, xzr, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
1051    try std.testing.expectFmt("add xzr, x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
1052    try std.testing.expectFmt("add xzr, x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1053    try std.testing.expectFmt("add xzr, xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
1054    try std.testing.expectFmt("add xzr, xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
1055
1056    try std.testing.expectFmt("addg x0, sp, #0x0, #0xf", "{f}", .{(try as.nextInstruction()).?});
1057    try std.testing.expectFmt("addg sp, x1, #0x3f0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1058
1059    try std.testing.expectFmt("adds w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1060    try std.testing.expectFmt("adds w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
1061    try std.testing.expectFmt("adds w5, w5, w6", "{f}", .{(try as.nextInstruction()).?});
1062    try std.testing.expectFmt("adds w7, wsp, w8", "{f}", .{(try as.nextInstruction()).?});
1063    try std.testing.expectFmt("adds w9, wsp, w9", "{f}", .{(try as.nextInstruction()).?});
1064    try std.testing.expectFmt("adds w10, w10, wzr", "{f}", .{(try as.nextInstruction()).?});
1065    try std.testing.expectFmt("adds w11, w12, wzr", "{f}", .{(try as.nextInstruction()).?});
1066    try std.testing.expectFmt("cmn w13, wzr", "{f}", .{(try as.nextInstruction()).?});
1067    try std.testing.expectFmt("adds w14, wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
1068    try std.testing.expectFmt("cmn wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
1069
1070    try std.testing.expectFmt("adds x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
1071    try std.testing.expectFmt("adds x2, x3, x4", "{f}", .{(try as.nextInstruction()).?});
1072    try std.testing.expectFmt("adds x5, x5, x6", "{f}", .{(try as.nextInstruction()).?});
1073    try std.testing.expectFmt("adds x7, sp, x8", "{f}", .{(try as.nextInstruction()).?});
1074    try std.testing.expectFmt("adds x9, sp, x9", "{f}", .{(try as.nextInstruction()).?});
1075    try std.testing.expectFmt("adds x10, x10, xzr", "{f}", .{(try as.nextInstruction()).?});
1076    try std.testing.expectFmt("adds x11, x12, xzr", "{f}", .{(try as.nextInstruction()).?});
1077    try std.testing.expectFmt("cmn x13, xzr", "{f}", .{(try as.nextInstruction()).?});
1078    try std.testing.expectFmt("adds x14, sp, xzr", "{f}", .{(try as.nextInstruction()).?});
1079    try std.testing.expectFmt("cmn sp, xzr", "{f}", .{(try as.nextInstruction()).?});
1080
1081    try std.testing.expectFmt("adds w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1082    try std.testing.expectFmt("adds w2, w3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
1083    try std.testing.expectFmt("cmn w5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
1084    try std.testing.expectFmt("adds w7, wsp, w8, lsl #2", "{f}", .{(try as.nextInstruction()).?});
1085    try std.testing.expectFmt("adds w9, wsp, w9, uxtx", "{f}", .{(try as.nextInstruction()).?});
1086    try std.testing.expectFmt("adds w10, w10, wzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
1087    try std.testing.expectFmt("adds w11, w12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
1088    try std.testing.expectFmt("cmn w13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
1089    try std.testing.expectFmt("adds w14, wsp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
1090    try std.testing.expectFmt("cmn wsp, wzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
1091
1092    try std.testing.expectFmt("adds x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
1093    try std.testing.expectFmt("adds x2, x3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
1094    try std.testing.expectFmt("cmn x5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
1095    try std.testing.expectFmt("adds x7, sp, w8, uxtw #2", "{f}", .{(try as.nextInstruction()).?});
1096    try std.testing.expectFmt("cmn sp, x9", "{f}", .{(try as.nextInstruction()).?});
1097    try std.testing.expectFmt("adds x10, x10, xzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
1098    try std.testing.expectFmt("adds x11, x12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
1099    try std.testing.expectFmt("cmn x13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
1100    try std.testing.expectFmt("adds x14, sp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
1101    try std.testing.expectFmt("cmn sp, xzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
1102
1103    try std.testing.expectFmt("adds w0, w0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1104    try std.testing.expectFmt("adds w0, w1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1105    try std.testing.expectFmt("adds wzr, w2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1106    try std.testing.expectFmt("adds w3, wsp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1107    try std.testing.expectFmt("adds wzr, wsp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1108    try std.testing.expectFmt("adds w0, w1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1109    try std.testing.expectFmt("adds w2, w3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1110    try std.testing.expectFmt("adds w4, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1111    try std.testing.expectFmt("adds w5, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1112    try std.testing.expectFmt("adds wzr, w6, #0x0", "{f}", .{(try as.nextInstruction()).?});
1113    try std.testing.expectFmt("adds wzr, w7, #0x0", "{f}", .{(try as.nextInstruction()).?});
1114    try std.testing.expectFmt("adds wzr, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1115    try std.testing.expectFmt("adds wzr, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1116
1117    try std.testing.expectFmt("adds x0, x0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1118    try std.testing.expectFmt("adds x0, x1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1119    try std.testing.expectFmt("adds xzr, x2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1120    try std.testing.expectFmt("adds x3, sp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1121    try std.testing.expectFmt("adds xzr, sp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1122    try std.testing.expectFmt("adds x0, x1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1123    try std.testing.expectFmt("adds x2, x3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1124    try std.testing.expectFmt("adds x4, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1125    try std.testing.expectFmt("adds x5, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1126    try std.testing.expectFmt("adds xzr, x6, #0x0", "{f}", .{(try as.nextInstruction()).?});
1127    try std.testing.expectFmt("adds xzr, x7, #0x0", "{f}", .{(try as.nextInstruction()).?});
1128    try std.testing.expectFmt("adds xzr, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1129    try std.testing.expectFmt("adds xzr, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1130
1131    try std.testing.expectFmt("adds w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
1132    try std.testing.expectFmt("adds w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
1133    try std.testing.expectFmt("adds w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1134    try std.testing.expectFmt("adds w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
1135    try std.testing.expectFmt("adds w7, wzr, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1136    try std.testing.expectFmt("adds w9, wzr, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
1137    try std.testing.expectFmt("cmn w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
1138    try std.testing.expectFmt("cmn w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1139    try std.testing.expectFmt("cmn wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
1140    try std.testing.expectFmt("cmn wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
1141
1142    try std.testing.expectFmt("adds x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
1143    try std.testing.expectFmt("adds x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
1144    try std.testing.expectFmt("adds x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1145    try std.testing.expectFmt("adds x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
1146    try std.testing.expectFmt("adds x7, xzr, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1147    try std.testing.expectFmt("adds x9, xzr, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
1148    try std.testing.expectFmt("cmn x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
1149    try std.testing.expectFmt("cmn x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1150    try std.testing.expectFmt("cmn xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
1151    try std.testing.expectFmt("cmn xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
1152
1153    try std.testing.expectFmt("neg w0, w0", "{f}", .{(try as.nextInstruction()).?});
1154    try std.testing.expectFmt("neg w1, w2", "{f}", .{(try as.nextInstruction()).?});
1155    try std.testing.expectFmt("neg w3, wzr, lsl #7", "{f}", .{(try as.nextInstruction()).?});
1156    try std.testing.expectFmt("neg wzr, w4, lsr #14", "{f}", .{(try as.nextInstruction()).?});
1157    try std.testing.expectFmt("neg wzr, wzr, asr #21", "{f}", .{(try as.nextInstruction()).?});
1158
1159    try std.testing.expectFmt("neg x0, x0", "{f}", .{(try as.nextInstruction()).?});
1160    try std.testing.expectFmt("neg x1, x2", "{f}", .{(try as.nextInstruction()).?});
1161    try std.testing.expectFmt("neg x3, xzr, lsl #11", "{f}", .{(try as.nextInstruction()).?});
1162    try std.testing.expectFmt("neg xzr, x4, lsr #22", "{f}", .{(try as.nextInstruction()).?});
1163    try std.testing.expectFmt("neg xzr, xzr, asr #33", "{f}", .{(try as.nextInstruction()).?});
1164
1165    try std.testing.expectFmt("sbc w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1166    try std.testing.expectFmt("sbc w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
1167    try std.testing.expectFmt("sbc w5, w5, wzr", "{f}", .{(try as.nextInstruction()).?});
1168    try std.testing.expectFmt("sbc w6, w7, wzr", "{f}", .{(try as.nextInstruction()).?});
1169
1170    try std.testing.expectFmt("sbcs w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1171    try std.testing.expectFmt("sbcs w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
1172    try std.testing.expectFmt("sbcs w5, w5, wzr", "{f}", .{(try as.nextInstruction()).?});
1173    try std.testing.expectFmt("sbcs w6, w7, wzr", "{f}", .{(try as.nextInstruction()).?});
1174
1175    try std.testing.expectFmt("sub w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1176    try std.testing.expectFmt("sub w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
1177    try std.testing.expectFmt("sub wsp, w5, w6", "{f}", .{(try as.nextInstruction()).?});
1178    try std.testing.expectFmt("sub w7, wsp, w8", "{f}", .{(try as.nextInstruction()).?});
1179    try std.testing.expectFmt("sub wsp, wsp, w9", "{f}", .{(try as.nextInstruction()).?});
1180    try std.testing.expectFmt("sub w10, w10, wzr", "{f}", .{(try as.nextInstruction()).?});
1181    try std.testing.expectFmt("sub w11, w12, wzr", "{f}", .{(try as.nextInstruction()).?});
1182    try std.testing.expectFmt("sub wsp, w13, wzr", "{f}", .{(try as.nextInstruction()).?});
1183    try std.testing.expectFmt("sub w14, wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
1184    try std.testing.expectFmt("sub wsp, wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
1185
1186    try std.testing.expectFmt("sub x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
1187    try std.testing.expectFmt("sub x2, x3, x4", "{f}", .{(try as.nextInstruction()).?});
1188    try std.testing.expectFmt("sub sp, x5, x6", "{f}", .{(try as.nextInstruction()).?});
1189    try std.testing.expectFmt("sub x7, sp, x8", "{f}", .{(try as.nextInstruction()).?});
1190    try std.testing.expectFmt("sub sp, sp, x9", "{f}", .{(try as.nextInstruction()).?});
1191    try std.testing.expectFmt("sub x10, x10, xzr", "{f}", .{(try as.nextInstruction()).?});
1192    try std.testing.expectFmt("sub x11, x12, xzr", "{f}", .{(try as.nextInstruction()).?});
1193    try std.testing.expectFmt("sub sp, x13, xzr", "{f}", .{(try as.nextInstruction()).?});
1194    try std.testing.expectFmt("sub x14, sp, xzr", "{f}", .{(try as.nextInstruction()).?});
1195    try std.testing.expectFmt("sub sp, sp, xzr", "{f}", .{(try as.nextInstruction()).?});
1196
1197    try std.testing.expectFmt("sub w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1198    try std.testing.expectFmt("sub w2, w3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
1199    try std.testing.expectFmt("sub wsp, w5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
1200    try std.testing.expectFmt("sub w7, wsp, w8, lsl #2", "{f}", .{(try as.nextInstruction()).?});
1201    try std.testing.expectFmt("sub wsp, wsp, w9, uxtx", "{f}", .{(try as.nextInstruction()).?});
1202    try std.testing.expectFmt("sub w10, w10, wzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
1203    try std.testing.expectFmt("sub w11, w12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
1204    try std.testing.expectFmt("sub wsp, w13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
1205    try std.testing.expectFmt("sub w14, wsp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
1206    try std.testing.expectFmt("sub wsp, wsp, wzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
1207
1208    try std.testing.expectFmt("sub x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
1209    try std.testing.expectFmt("sub x2, x3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
1210    try std.testing.expectFmt("sub sp, x5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
1211    try std.testing.expectFmt("sub x7, sp, w8, uxtw #2", "{f}", .{(try as.nextInstruction()).?});
1212    try std.testing.expectFmt("sub sp, sp, x9", "{f}", .{(try as.nextInstruction()).?});
1213    try std.testing.expectFmt("sub x10, x10, xzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
1214    try std.testing.expectFmt("sub x11, x12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
1215    try std.testing.expectFmt("sub sp, x13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
1216    try std.testing.expectFmt("sub x14, sp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
1217    try std.testing.expectFmt("sub sp, sp, xzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
1218
1219    try std.testing.expectFmt("sub w0, w0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1220    try std.testing.expectFmt("sub w0, w1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1221    try std.testing.expectFmt("sub wsp, w2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1222    try std.testing.expectFmt("sub w3, wsp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1223    try std.testing.expectFmt("sub wsp, wsp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1224    try std.testing.expectFmt("sub w0, w1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1225    try std.testing.expectFmt("sub w2, w3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1226    try std.testing.expectFmt("sub w4, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1227    try std.testing.expectFmt("sub w5, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1228    try std.testing.expectFmt("sub wsp, w6, #0x0", "{f}", .{(try as.nextInstruction()).?});
1229    try std.testing.expectFmt("sub wsp, w7, #0x0", "{f}", .{(try as.nextInstruction()).?});
1230    try std.testing.expectFmt("sub wsp, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1231    try std.testing.expectFmt("sub wsp, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1232
1233    try std.testing.expectFmt("sub x0, x0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1234    try std.testing.expectFmt("sub x0, x1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1235    try std.testing.expectFmt("sub sp, x2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1236    try std.testing.expectFmt("sub x3, sp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1237    try std.testing.expectFmt("sub sp, sp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1238    try std.testing.expectFmt("sub x0, x1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1239    try std.testing.expectFmt("sub x2, x3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1240    try std.testing.expectFmt("sub x4, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1241    try std.testing.expectFmt("sub x5, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1242    try std.testing.expectFmt("sub sp, x6, #0x0", "{f}", .{(try as.nextInstruction()).?});
1243    try std.testing.expectFmt("sub sp, x7, #0x0", "{f}", .{(try as.nextInstruction()).?});
1244    try std.testing.expectFmt("sub sp, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1245    try std.testing.expectFmt("sub sp, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1246
1247    try std.testing.expectFmt("sub w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
1248    try std.testing.expectFmt("sub w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
1249    try std.testing.expectFmt("sub w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1250    try std.testing.expectFmt("sub w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
1251    try std.testing.expectFmt("neg w7, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1252    try std.testing.expectFmt("neg w9, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
1253    try std.testing.expectFmt("sub wzr, w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
1254    try std.testing.expectFmt("sub wzr, w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1255    try std.testing.expectFmt("neg wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
1256    try std.testing.expectFmt("neg wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
1257
1258    try std.testing.expectFmt("sub x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
1259    try std.testing.expectFmt("sub x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
1260    try std.testing.expectFmt("sub x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1261    try std.testing.expectFmt("sub x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
1262    try std.testing.expectFmt("neg x7, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1263    try std.testing.expectFmt("neg x9, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
1264    try std.testing.expectFmt("sub xzr, x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
1265    try std.testing.expectFmt("sub xzr, x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1266    try std.testing.expectFmt("neg xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
1267    try std.testing.expectFmt("neg xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
1268
1269    try std.testing.expectFmt("subg x0, sp, #0x0, #0xf", "{f}", .{(try as.nextInstruction()).?});
1270    try std.testing.expectFmt("subg sp, x1, #0x3f0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1271
1272    try std.testing.expectFmt("subs w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1273    try std.testing.expectFmt("subs w2, w3, w4", "{f}", .{(try as.nextInstruction()).?});
1274    try std.testing.expectFmt("subs w5, w5, w6", "{f}", .{(try as.nextInstruction()).?});
1275    try std.testing.expectFmt("subs w7, wsp, w8", "{f}", .{(try as.nextInstruction()).?});
1276    try std.testing.expectFmt("subs w9, wsp, w9", "{f}", .{(try as.nextInstruction()).?});
1277    try std.testing.expectFmt("subs w10, w10, wzr", "{f}", .{(try as.nextInstruction()).?});
1278    try std.testing.expectFmt("subs w11, w12, wzr", "{f}", .{(try as.nextInstruction()).?});
1279    try std.testing.expectFmt("cmp w13, wzr", "{f}", .{(try as.nextInstruction()).?});
1280    try std.testing.expectFmt("subs w14, wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
1281    try std.testing.expectFmt("cmp wsp, wzr", "{f}", .{(try as.nextInstruction()).?});
1282
1283    try std.testing.expectFmt("subs x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
1284    try std.testing.expectFmt("subs x2, x3, x4", "{f}", .{(try as.nextInstruction()).?});
1285    try std.testing.expectFmt("subs x5, x5, x6", "{f}", .{(try as.nextInstruction()).?});
1286    try std.testing.expectFmt("subs x7, sp, x8", "{f}", .{(try as.nextInstruction()).?});
1287    try std.testing.expectFmt("subs x9, sp, x9", "{f}", .{(try as.nextInstruction()).?});
1288    try std.testing.expectFmt("subs x10, x10, xzr", "{f}", .{(try as.nextInstruction()).?});
1289    try std.testing.expectFmt("subs x11, x12, xzr", "{f}", .{(try as.nextInstruction()).?});
1290    try std.testing.expectFmt("cmp x13, xzr", "{f}", .{(try as.nextInstruction()).?});
1291    try std.testing.expectFmt("subs x14, sp, xzr", "{f}", .{(try as.nextInstruction()).?});
1292    try std.testing.expectFmt("cmp sp, xzr", "{f}", .{(try as.nextInstruction()).?});
1293
1294    try std.testing.expectFmt("subs w0, w0, w1", "{f}", .{(try as.nextInstruction()).?});
1295    try std.testing.expectFmt("subs w2, w3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
1296    try std.testing.expectFmt("cmp w5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
1297    try std.testing.expectFmt("subs w7, wsp, w8, lsl #2", "{f}", .{(try as.nextInstruction()).?});
1298    try std.testing.expectFmt("subs w9, wsp, w9, uxtx", "{f}", .{(try as.nextInstruction()).?});
1299    try std.testing.expectFmt("subs w10, w10, wzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
1300    try std.testing.expectFmt("subs w11, w12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
1301    try std.testing.expectFmt("cmp w13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
1302    try std.testing.expectFmt("subs w14, wsp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
1303    try std.testing.expectFmt("cmp wsp, wzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
1304
1305    try std.testing.expectFmt("subs x0, x0, x1", "{f}", .{(try as.nextInstruction()).?});
1306    try std.testing.expectFmt("subs x2, x3, w4, uxtb", "{f}", .{(try as.nextInstruction()).?});
1307    try std.testing.expectFmt("cmp x5, w6, uxth #1", "{f}", .{(try as.nextInstruction()).?});
1308    try std.testing.expectFmt("subs x7, sp, w8, uxtw #2", "{f}", .{(try as.nextInstruction()).?});
1309    try std.testing.expectFmt("cmp sp, x9", "{f}", .{(try as.nextInstruction()).?});
1310    try std.testing.expectFmt("subs x10, x10, xzr, uxtx #3", "{f}", .{(try as.nextInstruction()).?});
1311    try std.testing.expectFmt("subs x11, x12, wzr, sxtb #4", "{f}", .{(try as.nextInstruction()).?});
1312    try std.testing.expectFmt("cmp x13, wzr, sxth", "{f}", .{(try as.nextInstruction()).?});
1313    try std.testing.expectFmt("subs x14, sp, wzr, sxtw #1", "{f}", .{(try as.nextInstruction()).?});
1314    try std.testing.expectFmt("cmp sp, xzr, sxtx #2", "{f}", .{(try as.nextInstruction()).?});
1315
1316    try std.testing.expectFmt("subs w0, w0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1317    try std.testing.expectFmt("subs w0, w1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1318    try std.testing.expectFmt("subs wzr, w2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1319    try std.testing.expectFmt("subs w3, wsp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1320    try std.testing.expectFmt("subs wzr, wsp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1321    try std.testing.expectFmt("subs w0, w1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1322    try std.testing.expectFmt("subs w2, w3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1323    try std.testing.expectFmt("subs w4, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1324    try std.testing.expectFmt("subs w5, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1325    try std.testing.expectFmt("subs wzr, w6, #0x0", "{f}", .{(try as.nextInstruction()).?});
1326    try std.testing.expectFmt("subs wzr, w7, #0x0", "{f}", .{(try as.nextInstruction()).?});
1327    try std.testing.expectFmt("subs wzr, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1328    try std.testing.expectFmt("subs wzr, wsp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1329
1330    try std.testing.expectFmt("subs x0, x0, #0x0", "{f}", .{(try as.nextInstruction()).?});
1331    try std.testing.expectFmt("subs x0, x1, #0x1", "{f}", .{(try as.nextInstruction()).?});
1332    try std.testing.expectFmt("subs xzr, x2, #0x2, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1333    try std.testing.expectFmt("subs x3, sp, #0x3", "{f}", .{(try as.nextInstruction()).?});
1334    try std.testing.expectFmt("subs xzr, sp, #0xfff, lsl #12", "{f}", .{(try as.nextInstruction()).?});
1335    try std.testing.expectFmt("subs x0, x1, #0x0", "{f}", .{(try as.nextInstruction()).?});
1336    try std.testing.expectFmt("subs x2, x3, #0x0", "{f}", .{(try as.nextInstruction()).?});
1337    try std.testing.expectFmt("subs x4, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1338    try std.testing.expectFmt("subs x5, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1339    try std.testing.expectFmt("subs xzr, x6, #0x0", "{f}", .{(try as.nextInstruction()).?});
1340    try std.testing.expectFmt("subs xzr, x7, #0x0", "{f}", .{(try as.nextInstruction()).?});
1341    try std.testing.expectFmt("subs xzr, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1342    try std.testing.expectFmt("subs xzr, sp, #0x0", "{f}", .{(try as.nextInstruction()).?});
1343
1344    try std.testing.expectFmt("subs w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
1345    try std.testing.expectFmt("subs w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
1346    try std.testing.expectFmt("subs w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1347    try std.testing.expectFmt("subs w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
1348    try std.testing.expectFmt("negs w7, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1349    try std.testing.expectFmt("negs w9, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
1350    try std.testing.expectFmt("cmp w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
1351    try std.testing.expectFmt("cmp w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1352    try std.testing.expectFmt("cmp wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
1353    try std.testing.expectFmt("cmp wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
1354
1355    try std.testing.expectFmt("subs x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
1356    try std.testing.expectFmt("subs x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
1357    try std.testing.expectFmt("subs x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
1358    try std.testing.expectFmt("subs x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
1359    try std.testing.expectFmt("negs x7, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
1360    try std.testing.expectFmt("negs x9, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
1361    try std.testing.expectFmt("cmp x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
1362    try std.testing.expectFmt("cmp x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
1363    try std.testing.expectFmt("cmp xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
1364    try std.testing.expectFmt("cmp xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
1365
1366    try std.testing.expect(null == try as.nextInstruction());
1367}
1368test "bit manipulation" {
1369    var as: Assemble = .{
1370        .source =
1371        \\rbit w0, w1
1372        \\rbit w2, wzr
1373        \\rbit x3, x4
1374        \\rbit xzr, x5
1375        \\
1376        \\rev16 w0, w1
1377        \\rev16 w2, wzr
1378        \\rev16 x3, x4
1379        \\rev16 xzr, x5
1380        \\
1381        \\rev32 x3, x4
1382        \\rev32 xzr, x5
1383        \\
1384        \\rev w0, w1
1385        \\rev w2, wzr
1386        \\rev x3, x4
1387        \\rev xzr, x5
1388        \\
1389        \\rev64 x3, x4
1390        \\rev64 xzr, x5
1391        \\
1392        \\clz w0, w1
1393        \\clz w2, wzr
1394        \\clz x3, x4
1395        \\clz xzr, x5
1396        \\
1397        \\cls w0, w1
1398        \\cls w2, wzr
1399        \\cls x3, x4
1400        \\cls xzr, x5
1401        ,
1402        .operands = .empty,
1403    };
1404
1405    try std.testing.expectFmt("rbit w0, w1", "{f}", .{(try as.nextInstruction()).?});
1406    try std.testing.expectFmt("rbit w2, wzr", "{f}", .{(try as.nextInstruction()).?});
1407    try std.testing.expectFmt("rbit x3, x4", "{f}", .{(try as.nextInstruction()).?});
1408    try std.testing.expectFmt("rbit xzr, x5", "{f}", .{(try as.nextInstruction()).?});
1409
1410    try std.testing.expectFmt("rev16 w0, w1", "{f}", .{(try as.nextInstruction()).?});
1411    try std.testing.expectFmt("rev16 w2, wzr", "{f}", .{(try as.nextInstruction()).?});
1412    try std.testing.expectFmt("rev16 x3, x4", "{f}", .{(try as.nextInstruction()).?});
1413    try std.testing.expectFmt("rev16 xzr, x5", "{f}", .{(try as.nextInstruction()).?});
1414
1415    try std.testing.expectFmt("rev32 x3, x4", "{f}", .{(try as.nextInstruction()).?});
1416    try std.testing.expectFmt("rev32 xzr, x5", "{f}", .{(try as.nextInstruction()).?});
1417
1418    try std.testing.expectFmt("rev w0, w1", "{f}", .{(try as.nextInstruction()).?});
1419    try std.testing.expectFmt("rev w2, wzr", "{f}", .{(try as.nextInstruction()).?});
1420    try std.testing.expectFmt("rev x3, x4", "{f}", .{(try as.nextInstruction()).?});
1421    try std.testing.expectFmt("rev xzr, x5", "{f}", .{(try as.nextInstruction()).?});
1422
1423    try std.testing.expectFmt("rev x3, x4", "{f}", .{(try as.nextInstruction()).?});
1424    try std.testing.expectFmt("rev xzr, x5", "{f}", .{(try as.nextInstruction()).?});
1425
1426    try std.testing.expectFmt("clz w0, w1", "{f}", .{(try as.nextInstruction()).?});
1427    try std.testing.expectFmt("clz w2, wzr", "{f}", .{(try as.nextInstruction()).?});
1428    try std.testing.expectFmt("clz x3, x4", "{f}", .{(try as.nextInstruction()).?});
1429    try std.testing.expectFmt("clz xzr, x5", "{f}", .{(try as.nextInstruction()).?});
1430
1431    try std.testing.expectFmt("cls w0, w1", "{f}", .{(try as.nextInstruction()).?});
1432    try std.testing.expectFmt("cls w2, wzr", "{f}", .{(try as.nextInstruction()).?});
1433    try std.testing.expectFmt("cls x3, x4", "{f}", .{(try as.nextInstruction()).?});
1434    try std.testing.expectFmt("cls xzr, x5", "{f}", .{(try as.nextInstruction()).?});
1435
1436    try std.testing.expect(null == try as.nextInstruction());
1437}
1438test "bitfield" {
1439    var as: Assemble = .{
1440        .source =
1441        \\bfc w0, #1, #31
1442        \\bfc w1, #31, #1
1443        \\bfc x2, #1, #63
1444        \\bfc x3, #63, #1
1445        \\
1446        \\bfi w0, w1, #1, #31
1447        \\bfi w2, wzr, #31, #1
1448        \\bfi x3, xzr, #1, #63
1449        \\bfi x4, x5, #63, #1
1450        \\
1451        \\bfm w0, wzr, #25, #5
1452        \\bfm w1, w2, #31, #1
1453        \\bfm w3, w4, #1, #31
1454        \\bfm x5, xzr, #57, #7
1455        \\bfm x6, x7, #63, #1
1456        \\bfm x8, x9, #1, #63
1457        \\
1458        \\sbfm w0, w1, #31, #1
1459        \\sbfm w2, w3, #1, #31
1460        \\sbfm x4, x5, #63, #1
1461        \\sbfm x6, x7, #1, #63
1462        \\
1463        \\ubfm w0, w1, #31, #1
1464        \\ubfm w2, w3, #1, #31
1465        \\ubfm x4, x5, #63, #1
1466        \\ubfm x6, x7, #1, #63
1467        ,
1468        .operands = .empty,
1469    };
1470
1471    try std.testing.expectFmt("bfc w0, #1, #31", "{f}", .{(try as.nextInstruction()).?});
1472    try std.testing.expectFmt("bfc w1, #31, #1", "{f}", .{(try as.nextInstruction()).?});
1473    try std.testing.expectFmt("bfc x2, #1, #63", "{f}", .{(try as.nextInstruction()).?});
1474    try std.testing.expectFmt("bfc x3, #63, #1", "{f}", .{(try as.nextInstruction()).?});
1475
1476    try std.testing.expectFmt("bfi w0, w1, #1, #31", "{f}", .{(try as.nextInstruction()).?});
1477    try std.testing.expectFmt("bfc w2, #31, #1", "{f}", .{(try as.nextInstruction()).?});
1478    try std.testing.expectFmt("bfc x3, #1, #63", "{f}", .{(try as.nextInstruction()).?});
1479    try std.testing.expectFmt("bfi x4, x5, #63, #1", "{f}", .{(try as.nextInstruction()).?});
1480
1481    try std.testing.expectFmt("bfc w0, #7, #6", "{f}", .{(try as.nextInstruction()).?});
1482    try std.testing.expectFmt("bfi w1, w2, #1, #2", "{f}", .{(try as.nextInstruction()).?});
1483    try std.testing.expectFmt("bfxil w3, w4, #1, #31", "{f}", .{(try as.nextInstruction()).?});
1484    try std.testing.expectFmt("bfc x5, #7, #8", "{f}", .{(try as.nextInstruction()).?});
1485    try std.testing.expectFmt("bfi x6, x7, #1, #2", "{f}", .{(try as.nextInstruction()).?});
1486    try std.testing.expectFmt("bfxil x8, x9, #1, #63", "{f}", .{(try as.nextInstruction()).?});
1487
1488    try std.testing.expectFmt("sbfiz w0, w1, #1, #2", "{f}", .{(try as.nextInstruction()).?});
1489    try std.testing.expectFmt("sbfx w2, w3, #1, #31", "{f}", .{(try as.nextInstruction()).?});
1490    try std.testing.expectFmt("sbfiz x4, x5, #1, #2", "{f}", .{(try as.nextInstruction()).?});
1491    try std.testing.expectFmt("sbfx x6, x7, #1, #63", "{f}", .{(try as.nextInstruction()).?});
1492
1493    try std.testing.expectFmt("ubfiz w0, w1, #1, #2", "{f}", .{(try as.nextInstruction()).?});
1494    try std.testing.expectFmt("ubfx w2, w3, #1, #31", "{f}", .{(try as.nextInstruction()).?});
1495    try std.testing.expectFmt("ubfiz x4, x5, #1, #2", "{f}", .{(try as.nextInstruction()).?});
1496    try std.testing.expectFmt("ubfx x6, x7, #1, #63", "{f}", .{(try as.nextInstruction()).?});
1497
1498    try std.testing.expect(null == try as.nextInstruction());
1499}
1500test "branch register" {
1501    var as: Assemble = .{
1502        .source =
1503        \\ret
1504        \\br x30
1505        \\blr x30
1506        \\ret x30
1507        \\br x29
1508        \\blr x29
1509        \\ret x29
1510        \\br x2
1511        \\blr x1
1512        \\ret x0
1513        ,
1514        .operands = .empty,
1515    };
1516
1517    try std.testing.expectFmt("ret", "{f}", .{(try as.nextInstruction()).?});
1518    try std.testing.expectFmt("br x30", "{f}", .{(try as.nextInstruction()).?});
1519    try std.testing.expectFmt("blr x30", "{f}", .{(try as.nextInstruction()).?});
1520    try std.testing.expectFmt("ret", "{f}", .{(try as.nextInstruction()).?});
1521    try std.testing.expectFmt("br x29", "{f}", .{(try as.nextInstruction()).?});
1522    try std.testing.expectFmt("blr x29", "{f}", .{(try as.nextInstruction()).?});
1523    try std.testing.expectFmt("ret x29", "{f}", .{(try as.nextInstruction()).?});
1524    try std.testing.expectFmt("br x2", "{f}", .{(try as.nextInstruction()).?});
1525    try std.testing.expectFmt("blr x1", "{f}", .{(try as.nextInstruction()).?});
1526    try std.testing.expectFmt("ret x0", "{f}", .{(try as.nextInstruction()).?});
1527
1528    try std.testing.expect(null == try as.nextInstruction());
1529}
1530test "division" {
1531    var as: Assemble = .{
1532        .source =
1533        \\udiv w0, w1, w2
1534        \\udiv x3, x4, xzr
1535        \\sdiv w5, wzr, w6
1536        \\sdiv x7, x8, x9
1537        ,
1538        .operands = .empty,
1539    };
1540
1541    try std.testing.expectFmt("udiv w0, w1, w2", "{f}", .{(try as.nextInstruction()).?});
1542    try std.testing.expectFmt("udiv x3, x4, xzr", "{f}", .{(try as.nextInstruction()).?});
1543    try std.testing.expectFmt("sdiv w5, wzr, w6", "{f}", .{(try as.nextInstruction()).?});
1544    try std.testing.expectFmt("sdiv x7, x8, x9", "{f}", .{(try as.nextInstruction()).?});
1545
1546    try std.testing.expect(null == try as.nextInstruction());
1547}
1548test "exception generating" {
1549    var as: Assemble = .{
1550        .source =
1551        \\SVC #0
1552        \\HVC #0x1
1553        \\SMC #0o15
1554        \\BRK #42
1555        \\HLT #0x42
1556        \\TCANCEL #123
1557        \\DCPS1 #1234
1558        \\DCPS2 #12345
1559        \\DCPS3 #65535
1560        \\DCPS3 #0x0
1561        \\DCPS2 #0
1562        \\DCPS1
1563        ,
1564        .operands = .empty,
1565    };
1566
1567    try std.testing.expectFmt("svc #0", "{f}", .{(try as.nextInstruction()).?});
1568    try std.testing.expectFmt("hvc #0x1", "{f}", .{(try as.nextInstruction()).?});
1569    try std.testing.expectFmt("smc #0xd", "{f}", .{(try as.nextInstruction()).?});
1570    try std.testing.expectFmt("brk #0x2a", "{f}", .{(try as.nextInstruction()).?});
1571    try std.testing.expectFmt("hlt #0x42", "{f}", .{(try as.nextInstruction()).?});
1572    try std.testing.expectFmt("tcancel #0x7b", "{f}", .{(try as.nextInstruction()).?});
1573    try std.testing.expectFmt("dcps1 #0x4d2", "{f}", .{(try as.nextInstruction()).?});
1574    try std.testing.expectFmt("dcps2 #0x3039", "{f}", .{(try as.nextInstruction()).?});
1575    try std.testing.expectFmt("dcps3 #0xffff", "{f}", .{(try as.nextInstruction()).?});
1576    try std.testing.expectFmt("dcps3", "{f}", .{(try as.nextInstruction()).?});
1577    try std.testing.expectFmt("dcps2", "{f}", .{(try as.nextInstruction()).?});
1578    try std.testing.expectFmt("dcps1", "{f}", .{(try as.nextInstruction()).?});
1579
1580    try std.testing.expect(null == try as.nextInstruction());
1581}
1582test "extract" {
1583    var as: Assemble = .{
1584        .source =
1585        \\extr W0, W1, W2, #0
1586        \\extr W3, W3, W4, #1
1587        \\extr W5, W5, W5, #31
1588        \\
1589        \\extr X0, X1, X2, #0
1590        \\extr X3, X3, X4, #1
1591        \\extr X5, X5, X5, #63
1592        ,
1593        .operands = .empty,
1594    };
1595
1596    try std.testing.expectFmt("extr w0, w1, w2, #0", "{f}", .{(try as.nextInstruction()).?});
1597    try std.testing.expectFmt("extr w3, w3, w4, #1", "{f}", .{(try as.nextInstruction()).?});
1598    try std.testing.expectFmt("extr w5, w5, w5, #31", "{f}", .{(try as.nextInstruction()).?});
1599
1600    try std.testing.expectFmt("extr x0, x1, x2, #0", "{f}", .{(try as.nextInstruction()).?});
1601    try std.testing.expectFmt("extr x3, x3, x4, #1", "{f}", .{(try as.nextInstruction()).?});
1602    try std.testing.expectFmt("extr x5, x5, x5, #63", "{f}", .{(try as.nextInstruction()).?});
1603
1604    try std.testing.expect(null == try as.nextInstruction());
1605}
1606test "flags" {
1607    var as: Assemble = .{
1608        .source =
1609        \\AXFLAG
1610        \\CFINV
1611        \\XAFLAG
1612        ,
1613        .operands = .empty,
1614    };
1615
1616    try std.testing.expectFmt("axflag", "{f}", .{(try as.nextInstruction()).?});
1617    try std.testing.expectFmt("cfinv", "{f}", .{(try as.nextInstruction()).?});
1618    try std.testing.expectFmt("xaflag", "{f}", .{(try as.nextInstruction()).?});
1619
1620    try std.testing.expect(null == try as.nextInstruction());
1621}
1622test "hints" {
1623    var as: Assemble = .{
1624        .source =
1625        \\NOP
1626        \\hint #0
1627        \\YiElD
1628        \\Hint #0x1
1629        \\WfE
1630        \\hInt #02
1631        \\wFi
1632        \\hiNt #0b11
1633        \\sEv
1634        \\hinT #4
1635        \\sevl
1636        \\HINT #0b101
1637        \\hint #0x7F
1638        ,
1639        .operands = .empty,
1640    };
1641
1642    try std.testing.expectFmt("nop", "{f}", .{(try as.nextInstruction()).?});
1643    try std.testing.expectFmt("nop", "{f}", .{(try as.nextInstruction()).?});
1644    try std.testing.expectFmt("yield", "{f}", .{(try as.nextInstruction()).?});
1645    try std.testing.expectFmt("yield", "{f}", .{(try as.nextInstruction()).?});
1646    try std.testing.expectFmt("wfe", "{f}", .{(try as.nextInstruction()).?});
1647    try std.testing.expectFmt("wfe", "{f}", .{(try as.nextInstruction()).?});
1648    try std.testing.expectFmt("wfi", "{f}", .{(try as.nextInstruction()).?});
1649    try std.testing.expectFmt("wfi", "{f}", .{(try as.nextInstruction()).?});
1650    try std.testing.expectFmt("sev", "{f}", .{(try as.nextInstruction()).?});
1651    try std.testing.expectFmt("sev", "{f}", .{(try as.nextInstruction()).?});
1652    try std.testing.expectFmt("sevl", "{f}", .{(try as.nextInstruction()).?});
1653    try std.testing.expectFmt("sevl", "{f}", .{(try as.nextInstruction()).?});
1654    try std.testing.expectFmt("hint #0x7f", "{f}", .{(try as.nextInstruction()).?});
1655
1656    try std.testing.expect(null == try as.nextInstruction());
1657}
1658test "load store" {
1659    var as: Assemble = .{
1660        .source =
1661        \\ LDP w0, w1, [x2], #-256
1662        \\ LDP w3, w4, [x5], #0
1663        \\ LDP w6, w7, [sp], #252
1664        \\ LDP w0, w1, [x2, #-0x100]!
1665        \\ LDP w3, w4, [x5, #0]!
1666        \\ LDP w6, w7, [sp, #0xfc]!
1667        \\ LDP w0, w1, [x2, #-256]
1668        \\ LDP w3, w4, [x5]
1669        \\ LDP w6, w7, [x8, #0]
1670        \\ LDP w9, w10, [sp, #252]
1671        \\
1672        \\ LDP x0, x1, [x2], #-512
1673        \\ LDP x3, x4, [x5], #0
1674        \\ LDP x6, x7, [sp], #504
1675        \\ LDP x0, x1, [x2, #-0x200]!
1676        \\ LDP x3, x4, [x5, #0]!
1677        \\ LDP x6, x7, [sp, #0x1f8]!
1678        \\ LDP x0, x1, [x2, #-512]
1679        \\ LDP x3, x4, [x5]
1680        \\ LDP x6, x7, [x8, #0]
1681        \\ LDP x9, x10, [sp, #504]
1682        \\
1683        \\ LDR w0, [x1], #-256
1684        \\ LDR w2, [x3], #0
1685        \\ LDR w4, [sp], #255
1686        \\ LDR w0, [x1, #-0x100]!
1687        \\ LDR w2, [x3, #0]!
1688        \\ LDR w4, [sp, #0xff]!
1689        \\ LDR w0, [x1, #0]
1690        \\ LDR w2, [x3]
1691        \\ LDR w4, [sp, #16380]
1692        \\
1693        \\ LDR x0, [x1], #-256
1694        \\ LDR x2, [x3], #0
1695        \\ LDR x4, [sp], #255
1696        \\ LDR x0, [x1, #-0x100]!
1697        \\ LDR x2, [x3, #0]!
1698        \\ LDR x4, [sp, #0xff]!
1699        \\ LDR x0, [x1, #0]
1700        \\ LDR x2, [x3]
1701        \\ LDR x4, [sp, #32760]
1702        \\
1703        \\ STP w0, w1, [x2], #-256
1704        \\ STP w3, w4, [x5], #0
1705        \\ STP w6, w7, [sp], #252
1706        \\ STP w0, w1, [x2, #-0x100]!
1707        \\ STP w3, w4, [x5, #0]!
1708        \\ STP w6, w7, [sp, #0xfc]!
1709        \\ STP w0, w1, [x2, #-256]
1710        \\ STP w3, w4, [x5]
1711        \\ STP w6, w7, [x8, #0]
1712        \\ STP w9, w10, [sp, #252]
1713        \\
1714        \\ STP x0, x1, [x2], #-512
1715        \\ STP x3, x4, [x5], #0
1716        \\ STP x6, x7, [sp], #504
1717        \\ STP x0, x1, [x2, #-0x200]!
1718        \\ STP x3, x4, [x5, #0]!
1719        \\ STP x6, x7, [sp, #0x1f8]!
1720        \\ STP x0, x1, [x2, #-512]
1721        \\ STP x3, x4, [x5]
1722        \\ STP x6, x7, [x8, #0]
1723        \\ STP x9, x10, [sp, #504]
1724        \\
1725        \\ STR w0, [x1], #-256
1726        \\ STR w2, [x3], #0
1727        \\ STR w4, [sp], #255
1728        \\ STR w0, [x1, #-0x100]!
1729        \\ STR w2, [x3, #0]!
1730        \\ STR w4, [sp, #0xff]!
1731        \\ STR w0, [x1, #0]
1732        \\ STR w2, [x3]
1733        \\ STR w4, [sp, #16380]
1734        \\
1735        \\ STR x0, [x1], #-256
1736        \\ STR x2, [x3], #0
1737        \\ STR x4, [sp], #255
1738        \\ STR x0, [x1, #-0x100]!
1739        \\ STR x2, [x3, #0]!
1740        \\ STR x4, [sp, #0xff]!
1741        \\ STR x0, [x1, #0]
1742        \\ STR x2, [x3]
1743        \\ STR x4, [sp, #32760]
1744        ,
1745        .operands = .empty,
1746    };
1747
1748    try std.testing.expectFmt("ldp w0, w1, [x2], #-0x100", "{f}", .{(try as.nextInstruction()).?});
1749    try std.testing.expectFmt("ldp w3, w4, [x5], #0x0", "{f}", .{(try as.nextInstruction()).?});
1750    try std.testing.expectFmt("ldp w6, w7, [sp], #0xfc", "{f}", .{(try as.nextInstruction()).?});
1751    try std.testing.expectFmt("ldp w0, w1, [x2, #-0x100]!", "{f}", .{(try as.nextInstruction()).?});
1752    try std.testing.expectFmt("ldp w3, w4, [x5, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1753    try std.testing.expectFmt("ldp w6, w7, [sp, #0xfc]!", "{f}", .{(try as.nextInstruction()).?});
1754    try std.testing.expectFmt("ldp w0, w1, [x2, #-0x100]", "{f}", .{(try as.nextInstruction()).?});
1755    try std.testing.expectFmt("ldp w3, w4, [x5]", "{f}", .{(try as.nextInstruction()).?});
1756    try std.testing.expectFmt("ldp w6, w7, [x8]", "{f}", .{(try as.nextInstruction()).?});
1757    try std.testing.expectFmt("ldp w9, w10, [sp, #0xfc]", "{f}", .{(try as.nextInstruction()).?});
1758
1759    try std.testing.expectFmt("ldp x0, x1, [x2], #-0x200", "{f}", .{(try as.nextInstruction()).?});
1760    try std.testing.expectFmt("ldp x3, x4, [x5], #0x0", "{f}", .{(try as.nextInstruction()).?});
1761    try std.testing.expectFmt("ldp x6, x7, [sp], #0x1f8", "{f}", .{(try as.nextInstruction()).?});
1762    try std.testing.expectFmt("ldp x0, x1, [x2, #-0x200]!", "{f}", .{(try as.nextInstruction()).?});
1763    try std.testing.expectFmt("ldp x3, x4, [x5, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1764    try std.testing.expectFmt("ldp x6, x7, [sp, #0x1f8]!", "{f}", .{(try as.nextInstruction()).?});
1765    try std.testing.expectFmt("ldp x0, x1, [x2, #-0x200]", "{f}", .{(try as.nextInstruction()).?});
1766    try std.testing.expectFmt("ldp x3, x4, [x5]", "{f}", .{(try as.nextInstruction()).?});
1767    try std.testing.expectFmt("ldp x6, x7, [x8]", "{f}", .{(try as.nextInstruction()).?});
1768    try std.testing.expectFmt("ldp x9, x10, [sp, #0x1f8]", "{f}", .{(try as.nextInstruction()).?});
1769
1770    try std.testing.expectFmt("ldr w0, [x1], #-0x100", "{f}", .{(try as.nextInstruction()).?});
1771    try std.testing.expectFmt("ldr w2, [x3], #0x0", "{f}", .{(try as.nextInstruction()).?});
1772    try std.testing.expectFmt("ldr w4, [sp], #0xff", "{f}", .{(try as.nextInstruction()).?});
1773    try std.testing.expectFmt("ldr w0, [x1, #-0x100]!", "{f}", .{(try as.nextInstruction()).?});
1774    try std.testing.expectFmt("ldr w2, [x3, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1775    try std.testing.expectFmt("ldr w4, [sp, #0xff]!", "{f}", .{(try as.nextInstruction()).?});
1776    try std.testing.expectFmt("ldr w0, [x1]", "{f}", .{(try as.nextInstruction()).?});
1777    try std.testing.expectFmt("ldr w2, [x3]", "{f}", .{(try as.nextInstruction()).?});
1778    try std.testing.expectFmt("ldr w4, [sp, #0x3ffc]", "{f}", .{(try as.nextInstruction()).?});
1779
1780    try std.testing.expectFmt("ldr x0, [x1], #-0x100", "{f}", .{(try as.nextInstruction()).?});
1781    try std.testing.expectFmt("ldr x2, [x3], #0x0", "{f}", .{(try as.nextInstruction()).?});
1782    try std.testing.expectFmt("ldr x4, [sp], #0xff", "{f}", .{(try as.nextInstruction()).?});
1783    try std.testing.expectFmt("ldr x0, [x1, #-0x100]!", "{f}", .{(try as.nextInstruction()).?});
1784    try std.testing.expectFmt("ldr x2, [x3, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1785    try std.testing.expectFmt("ldr x4, [sp, #0xff]!", "{f}", .{(try as.nextInstruction()).?});
1786    try std.testing.expectFmt("ldr x0, [x1]", "{f}", .{(try as.nextInstruction()).?});
1787    try std.testing.expectFmt("ldr x2, [x3]", "{f}", .{(try as.nextInstruction()).?});
1788    try std.testing.expectFmt("ldr x4, [sp, #0x7ff8]", "{f}", .{(try as.nextInstruction()).?});
1789
1790    try std.testing.expectFmt("stp w0, w1, [x2], #-0x100", "{f}", .{(try as.nextInstruction()).?});
1791    try std.testing.expectFmt("stp w3, w4, [x5], #0x0", "{f}", .{(try as.nextInstruction()).?});
1792    try std.testing.expectFmt("stp w6, w7, [sp], #0xfc", "{f}", .{(try as.nextInstruction()).?});
1793    try std.testing.expectFmt("stp w0, w1, [x2, #-0x100]!", "{f}", .{(try as.nextInstruction()).?});
1794    try std.testing.expectFmt("stp w3, w4, [x5, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1795    try std.testing.expectFmt("stp w6, w7, [sp, #0xfc]!", "{f}", .{(try as.nextInstruction()).?});
1796    try std.testing.expectFmt("stp w0, w1, [x2, #-0x100]", "{f}", .{(try as.nextInstruction()).?});
1797    try std.testing.expectFmt("stp w3, w4, [x5]", "{f}", .{(try as.nextInstruction()).?});
1798    try std.testing.expectFmt("stp w6, w7, [x8]", "{f}", .{(try as.nextInstruction()).?});
1799    try std.testing.expectFmt("stp w9, w10, [sp, #0xfc]", "{f}", .{(try as.nextInstruction()).?});
1800
1801    try std.testing.expectFmt("stp x0, x1, [x2], #-0x200", "{f}", .{(try as.nextInstruction()).?});
1802    try std.testing.expectFmt("stp x3, x4, [x5], #0x0", "{f}", .{(try as.nextInstruction()).?});
1803    try std.testing.expectFmt("stp x6, x7, [sp], #0x1f8", "{f}", .{(try as.nextInstruction()).?});
1804    try std.testing.expectFmt("stp x0, x1, [x2, #-0x200]!", "{f}", .{(try as.nextInstruction()).?});
1805    try std.testing.expectFmt("stp x3, x4, [x5, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1806    try std.testing.expectFmt("stp x6, x7, [sp, #0x1f8]!", "{f}", .{(try as.nextInstruction()).?});
1807    try std.testing.expectFmt("stp x0, x1, [x2, #-0x200]", "{f}", .{(try as.nextInstruction()).?});
1808    try std.testing.expectFmt("stp x3, x4, [x5]", "{f}", .{(try as.nextInstruction()).?});
1809    try std.testing.expectFmt("stp x6, x7, [x8]", "{f}", .{(try as.nextInstruction()).?});
1810    try std.testing.expectFmt("stp x9, x10, [sp, #0x1f8]", "{f}", .{(try as.nextInstruction()).?});
1811
1812    try std.testing.expectFmt("str w0, [x1], #-0x100", "{f}", .{(try as.nextInstruction()).?});
1813    try std.testing.expectFmt("str w2, [x3], #0x0", "{f}", .{(try as.nextInstruction()).?});
1814    try std.testing.expectFmt("str w4, [sp], #0xff", "{f}", .{(try as.nextInstruction()).?});
1815    try std.testing.expectFmt("str w0, [x1, #-0x100]!", "{f}", .{(try as.nextInstruction()).?});
1816    try std.testing.expectFmt("str w2, [x3, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1817    try std.testing.expectFmt("str w4, [sp, #0xff]!", "{f}", .{(try as.nextInstruction()).?});
1818    try std.testing.expectFmt("str w0, [x1]", "{f}", .{(try as.nextInstruction()).?});
1819    try std.testing.expectFmt("str w2, [x3]", "{f}", .{(try as.nextInstruction()).?});
1820    try std.testing.expectFmt("str w4, [sp, #0x3ffc]", "{f}", .{(try as.nextInstruction()).?});
1821
1822    try std.testing.expectFmt("str x0, [x1], #-0x100", "{f}", .{(try as.nextInstruction()).?});
1823    try std.testing.expectFmt("str x2, [x3], #0x0", "{f}", .{(try as.nextInstruction()).?});
1824    try std.testing.expectFmt("str x4, [sp], #0xff", "{f}", .{(try as.nextInstruction()).?});
1825    try std.testing.expectFmt("str x0, [x1, #-0x100]!", "{f}", .{(try as.nextInstruction()).?});
1826    try std.testing.expectFmt("str x2, [x3, #0x0]!", "{f}", .{(try as.nextInstruction()).?});
1827    try std.testing.expectFmt("str x4, [sp, #0xff]!", "{f}", .{(try as.nextInstruction()).?});
1828    try std.testing.expectFmt("str x0, [x1]", "{f}", .{(try as.nextInstruction()).?});
1829    try std.testing.expectFmt("str x2, [x3]", "{f}", .{(try as.nextInstruction()).?});
1830    try std.testing.expectFmt("str x4, [sp, #0x7ff8]", "{f}", .{(try as.nextInstruction()).?});
1831
1832    try std.testing.expect(null == try as.nextInstruction());
1833}
1834test "logical" {
1835    var as: Assemble = .{
1836        .source =
1837        \\ and w0, w0, w0
1838        \\ and w1, w1, w2, lsl #0
1839        \\ and w3, w4, w5, lsl #1
1840        \\ and w6, w6, wzr, lsl #31
1841        \\ and w7, wzr, w8, lsr #0
1842        \\ and w9, wzr, wzr, lsr #30
1843        \\ and wzr, w10, w11, lsr #31
1844        \\ and wzr, w12, wzr, asr #0x0
1845        \\ and wzr, wzr, w13, asr #0x10
1846        \\ and wzr, wzr, wzr, asr #0x1f
1847        \\ and w0, w0, wzr
1848        \\ and w1, w2, wzr, lsl #0
1849        \\ and w3, wzr, w3
1850        \\ and w4, wzr, w5, lsl #0
1851        \\ and w6, wzr, wzr
1852        \\ and w7, wzr, wzr, lsl #0
1853        \\ and wzr, w8, wzr
1854        \\ and wzr, w9, wzr, lsl #0
1855        \\ and wzr, wzr, w10
1856        \\ and wzr, wzr, w11, lsl #0
1857        \\ and wzr, wzr, wzr
1858        \\ and wzr, wzr, wzr, lsl #0
1859        \\
1860        \\ and x0, x0, x0
1861        \\ and x1, x1, x2, lsl #0
1862        \\ and x3, x4, x5, lsl #1
1863        \\ and x6, x6, xzr, lsl #63
1864        \\ and x7, xzr, x8, lsr #0
1865        \\ and x9, xzr, xzr, lsr #62
1866        \\ and xzr, x10, x11, lsr #63
1867        \\ and xzr, x12, xzr, asr #0x0
1868        \\ and xzr, xzr, x13, asr #0x1F
1869        \\ and xzr, xzr, xzr, asr #0x3f
1870        \\ and x0, x0, xzr
1871        \\ and x1, x2, xzr, lsl #0
1872        \\ and x3, xzr, x3
1873        \\ and x4, xzr, x5, lsl #0
1874        \\ and x6, xzr, xzr
1875        \\ and x7, xzr, xzr, lsl #0
1876        \\ and xzr, x8, xzr
1877        \\ and xzr, x9, xzr, lsl #0
1878        \\ and xzr, xzr, x10
1879        \\ and xzr, xzr, x11, lsl #0
1880        \\ and xzr, xzr, xzr
1881        \\ and xzr, xzr, xzr, lsl #0
1882        \\
1883        \\ orr w0, w0, w0
1884        \\ orr w1, w1, w2, lsl #0
1885        \\ orr w3, w4, w5, lsl #1
1886        \\ orr w6, w6, wzr, lsl #31
1887        \\ orr w7, wzr, w8, lsr #0
1888        \\ orr w9, wzr, wzr, lsr #30
1889        \\ orr wzr, w10, w11, lsr #31
1890        \\ orr wzr, w12, wzr, asr #0x0
1891        \\ orr wzr, wzr, w13, asr #0x10
1892        \\ orr wzr, wzr, wzr, asr #0x1f
1893        \\ orr w0, w0, wzr
1894        \\ orr w1, w2, wzr, lsl #0
1895        \\ orr w3, wzr, w3
1896        \\ orr w4, wzr, w5, lsl #0
1897        \\ orr w6, wzr, wzr
1898        \\ orr w7, wzr, wzr, lsl #0
1899        \\ orr wzr, w8, wzr
1900        \\ orr wzr, w9, wzr, lsl #0
1901        \\ orr wzr, wzr, w10
1902        \\ orr wzr, wzr, w11, lsl #0
1903        \\ orr wzr, wzr, wzr
1904        \\ orr wzr, wzr, wzr, lsl #0
1905        \\
1906        \\ orr x0, x0, x0
1907        \\ orr x1, x1, x2, lsl #0
1908        \\ orr x3, x4, x5, lsl #1
1909        \\ orr x6, x6, xzr, lsl #63
1910        \\ orr x7, xzr, x8, lsr #0
1911        \\ orr x9, xzr, xzr, lsr #62
1912        \\ orr xzr, x10, x11, lsr #63
1913        \\ orr xzr, x12, xzr, asr #0x0
1914        \\ orr xzr, xzr, x13, asr #0x1F
1915        \\ orr xzr, xzr, xzr, asr #0x3f
1916        \\ orr x0, x0, xzr
1917        \\ orr x1, x2, xzr, lsl #0
1918        \\ orr x3, xzr, x3
1919        \\ orr x4, xzr, x5, lsl #0
1920        \\ orr x6, xzr, xzr
1921        \\ orr x7, xzr, xzr, lsl #0
1922        \\ orr xzr, x8, xzr
1923        \\ orr xzr, x9, xzr, lsl #0
1924        \\ orr xzr, xzr, x10
1925        \\ orr xzr, xzr, x11, lsl #0
1926        \\ orr xzr, xzr, xzr
1927        \\ orr xzr, xzr, xzr, lsl #0
1928        \\
1929        \\ eor w0, w0, w0
1930        \\ eor w1, w1, w2, lsl #0
1931        \\ eor w3, w4, w5, lsl #1
1932        \\ eor w6, w6, wzr, lsl #31
1933        \\ eor w7, wzr, w8, lsr #0
1934        \\ eor w9, wzr, wzr, lsr #30
1935        \\ eor wzr, w10, w11, lsr #31
1936        \\ eor wzr, w12, wzr, asr #0x0
1937        \\ eor wzr, wzr, w13, asr #0x10
1938        \\ eor wzr, wzr, wzr, asr #0x1f
1939        \\ eor w0, w0, wzr
1940        \\ eor w1, w2, wzr, lsl #0
1941        \\ eor w3, wzr, w3
1942        \\ eor w4, wzr, w5, lsl #0
1943        \\ eor w6, wzr, wzr
1944        \\ eor w7, wzr, wzr, lsl #0
1945        \\ eor wzr, w8, wzr
1946        \\ eor wzr, w9, wzr, lsl #0
1947        \\ eor wzr, wzr, w10
1948        \\ eor wzr, wzr, w11, lsl #0
1949        \\ eor wzr, wzr, wzr
1950        \\ eor wzr, wzr, wzr, lsl #0
1951        \\
1952        \\ eor x0, x0, x0
1953        \\ eor x1, x1, x2, lsl #0
1954        \\ eor x3, x4, x5, lsl #1
1955        \\ eor x6, x6, xzr, lsl #63
1956        \\ eor x7, xzr, x8, lsr #0
1957        \\ eor x9, xzr, xzr, lsr #62
1958        \\ eor xzr, x10, x11, lsr #63
1959        \\ eor xzr, x12, xzr, asr #0x0
1960        \\ eor xzr, xzr, x13, asr #0x1F
1961        \\ eor xzr, xzr, xzr, asr #0x3f
1962        \\ eor x0, x0, xzr
1963        \\ eor x1, x2, xzr, lsl #0
1964        \\ eor x3, xzr, x3
1965        \\ eor x4, xzr, x5, lsl #0
1966        \\ eor x6, xzr, xzr
1967        \\ eor x7, xzr, xzr, lsl #0
1968        \\ eor xzr, x8, xzr
1969        \\ eor xzr, x9, xzr, lsl #0
1970        \\ eor xzr, xzr, x10
1971        \\ eor xzr, xzr, x11, lsl #0
1972        \\ eor xzr, xzr, xzr
1973        \\ eor xzr, xzr, xzr, lsl #0
1974        \\
1975        \\ ands w0, w0, w0
1976        \\ ands w1, w1, w2, lsl #0
1977        \\ ands w3, w4, w5, lsl #1
1978        \\ ands w6, w6, wzr, lsl #31
1979        \\ ands w7, wzr, w8, lsr #0
1980        \\ ands w9, wzr, wzr, lsr #30
1981        \\ ands wzr, w10, w11, lsr #31
1982        \\ ands wzr, w12, wzr, asr #0x0
1983        \\ ands wzr, wzr, w13, asr #0x10
1984        \\ ands wzr, wzr, wzr, asr #0x1f
1985        \\ ands w0, w0, wzr
1986        \\ ands w1, w2, wzr, lsl #0
1987        \\ ands w3, wzr, w3
1988        \\ ands w4, wzr, w5, lsl #0
1989        \\ ands w6, wzr, wzr
1990        \\ ands w7, wzr, wzr, lsl #0
1991        \\ ands wzr, w8, wzr
1992        \\ ands wzr, w9, wzr, lsl #0
1993        \\ ands wzr, wzr, w10
1994        \\ ands wzr, wzr, w11, lsl #0
1995        \\ ands wzr, wzr, wzr
1996        \\ ands wzr, wzr, wzr, lsl #0
1997        \\
1998        \\ ands x0, x0, x0
1999        \\ ands x1, x1, x2, lsl #0
2000        \\ ands x3, x4, x5, lsl #1
2001        \\ ands x6, x6, xzr, lsl #63
2002        \\ ands x7, xzr, x8, lsr #0
2003        \\ ands x9, xzr, xzr, lsr #62
2004        \\ ands xzr, x10, x11, lsr #63
2005        \\ ands xzr, x12, xzr, asr #0x0
2006        \\ ands xzr, xzr, x13, asr #0x1F
2007        \\ ands xzr, xzr, xzr, asr #0x3f
2008        \\ ands x0, x0, xzr
2009        \\ ands x1, x2, xzr, lsl #0
2010        \\ ands x3, xzr, x3
2011        \\ ands x4, xzr, x5, lsl #0
2012        \\ ands x6, xzr, xzr
2013        \\ ands x7, xzr, xzr, lsl #0
2014        \\ ands xzr, x8, xzr
2015        \\ ands xzr, x9, xzr, lsl #0
2016        \\ ands xzr, xzr, x10
2017        \\ ands xzr, xzr, x11, lsl #0
2018        \\ ands xzr, xzr, xzr
2019        \\ ands xzr, xzr, xzr, lsl #0
2020        ,
2021        .operands = .empty,
2022    };
2023
2024    try std.testing.expectFmt("and w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
2025    try std.testing.expectFmt("and w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2026    try std.testing.expectFmt("and w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2027    try std.testing.expectFmt("and w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
2028    try std.testing.expectFmt("and w7, wzr, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2029    try std.testing.expectFmt("and w9, wzr, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
2030    try std.testing.expectFmt("and wzr, w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
2031    try std.testing.expectFmt("and wzr, w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2032    try std.testing.expectFmt("and wzr, wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
2033    try std.testing.expectFmt("and wzr, wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
2034    try std.testing.expectFmt("and w0, w0, wzr", "{f}", .{(try as.nextInstruction()).?});
2035    try std.testing.expectFmt("and w1, w2, wzr", "{f}", .{(try as.nextInstruction()).?});
2036    try std.testing.expectFmt("and w3, wzr, w3", "{f}", .{(try as.nextInstruction()).?});
2037    try std.testing.expectFmt("and w4, wzr, w5", "{f}", .{(try as.nextInstruction()).?});
2038    try std.testing.expectFmt("and w6, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2039    try std.testing.expectFmt("and w7, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2040    try std.testing.expectFmt("and wzr, w8, wzr", "{f}", .{(try as.nextInstruction()).?});
2041    try std.testing.expectFmt("and wzr, w9, wzr", "{f}", .{(try as.nextInstruction()).?});
2042    try std.testing.expectFmt("and wzr, wzr, w10", "{f}", .{(try as.nextInstruction()).?});
2043    try std.testing.expectFmt("and wzr, wzr, w11", "{f}", .{(try as.nextInstruction()).?});
2044    try std.testing.expectFmt("and wzr, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2045    try std.testing.expectFmt("and wzr, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2046
2047    try std.testing.expectFmt("and x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
2048    try std.testing.expectFmt("and x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
2049    try std.testing.expectFmt("and x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2050    try std.testing.expectFmt("and x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
2051    try std.testing.expectFmt("and x7, xzr, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2052    try std.testing.expectFmt("and x9, xzr, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
2053    try std.testing.expectFmt("and xzr, x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
2054    try std.testing.expectFmt("and xzr, x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2055    try std.testing.expectFmt("and xzr, xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
2056    try std.testing.expectFmt("and xzr, xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
2057    try std.testing.expectFmt("and x0, x0, xzr", "{f}", .{(try as.nextInstruction()).?});
2058    try std.testing.expectFmt("and x1, x2, xzr", "{f}", .{(try as.nextInstruction()).?});
2059    try std.testing.expectFmt("and x3, xzr, x3", "{f}", .{(try as.nextInstruction()).?});
2060    try std.testing.expectFmt("and x4, xzr, x5", "{f}", .{(try as.nextInstruction()).?});
2061    try std.testing.expectFmt("and x6, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2062    try std.testing.expectFmt("and x7, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2063    try std.testing.expectFmt("and xzr, x8, xzr", "{f}", .{(try as.nextInstruction()).?});
2064    try std.testing.expectFmt("and xzr, x9, xzr", "{f}", .{(try as.nextInstruction()).?});
2065    try std.testing.expectFmt("and xzr, xzr, x10", "{f}", .{(try as.nextInstruction()).?});
2066    try std.testing.expectFmt("and xzr, xzr, x11", "{f}", .{(try as.nextInstruction()).?});
2067    try std.testing.expectFmt("and xzr, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2068    try std.testing.expectFmt("and xzr, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2069
2070    try std.testing.expectFmt("orr w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
2071    try std.testing.expectFmt("orr w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2072    try std.testing.expectFmt("orr w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2073    try std.testing.expectFmt("orr w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
2074    try std.testing.expectFmt("orr w7, wzr, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2075    try std.testing.expectFmt("orr w9, wzr, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
2076    try std.testing.expectFmt("orr wzr, w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
2077    try std.testing.expectFmt("orr wzr, w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2078    try std.testing.expectFmt("orr wzr, wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
2079    try std.testing.expectFmt("orr wzr, wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
2080    try std.testing.expectFmt("orr w0, w0, wzr", "{f}", .{(try as.nextInstruction()).?});
2081    try std.testing.expectFmt("orr w1, w2, wzr", "{f}", .{(try as.nextInstruction()).?});
2082    try std.testing.expectFmt("mov w3, w3", "{f}", .{(try as.nextInstruction()).?});
2083    try std.testing.expectFmt("mov w4, w5", "{f}", .{(try as.nextInstruction()).?});
2084    try std.testing.expectFmt("mov w6, wzr", "{f}", .{(try as.nextInstruction()).?});
2085    try std.testing.expectFmt("mov w7, wzr", "{f}", .{(try as.nextInstruction()).?});
2086    try std.testing.expectFmt("orr wzr, w8, wzr", "{f}", .{(try as.nextInstruction()).?});
2087    try std.testing.expectFmt("orr wzr, w9, wzr", "{f}", .{(try as.nextInstruction()).?});
2088    try std.testing.expectFmt("mov wzr, w10", "{f}", .{(try as.nextInstruction()).?});
2089    try std.testing.expectFmt("mov wzr, w11", "{f}", .{(try as.nextInstruction()).?});
2090    try std.testing.expectFmt("mov wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2091    try std.testing.expectFmt("mov wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2092
2093    try std.testing.expectFmt("orr x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
2094    try std.testing.expectFmt("orr x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
2095    try std.testing.expectFmt("orr x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2096    try std.testing.expectFmt("orr x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
2097    try std.testing.expectFmt("orr x7, xzr, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2098    try std.testing.expectFmt("orr x9, xzr, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
2099    try std.testing.expectFmt("orr xzr, x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
2100    try std.testing.expectFmt("orr xzr, x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2101    try std.testing.expectFmt("orr xzr, xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
2102    try std.testing.expectFmt("orr xzr, xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
2103    try std.testing.expectFmt("orr x0, x0, xzr", "{f}", .{(try as.nextInstruction()).?});
2104    try std.testing.expectFmt("orr x1, x2, xzr", "{f}", .{(try as.nextInstruction()).?});
2105    try std.testing.expectFmt("mov x3, x3", "{f}", .{(try as.nextInstruction()).?});
2106    try std.testing.expectFmt("mov x4, x5", "{f}", .{(try as.nextInstruction()).?});
2107    try std.testing.expectFmt("mov x6, xzr", "{f}", .{(try as.nextInstruction()).?});
2108    try std.testing.expectFmt("mov x7, xzr", "{f}", .{(try as.nextInstruction()).?});
2109    try std.testing.expectFmt("orr xzr, x8, xzr", "{f}", .{(try as.nextInstruction()).?});
2110    try std.testing.expectFmt("orr xzr, x9, xzr", "{f}", .{(try as.nextInstruction()).?});
2111    try std.testing.expectFmt("mov xzr, x10", "{f}", .{(try as.nextInstruction()).?});
2112    try std.testing.expectFmt("mov xzr, x11", "{f}", .{(try as.nextInstruction()).?});
2113    try std.testing.expectFmt("mov xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2114    try std.testing.expectFmt("mov xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2115
2116    try std.testing.expectFmt("eor w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
2117    try std.testing.expectFmt("eor w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2118    try std.testing.expectFmt("eor w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2119    try std.testing.expectFmt("eor w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
2120    try std.testing.expectFmt("eor w7, wzr, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2121    try std.testing.expectFmt("eor w9, wzr, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
2122    try std.testing.expectFmt("eor wzr, w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
2123    try std.testing.expectFmt("eor wzr, w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2124    try std.testing.expectFmt("eor wzr, wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
2125    try std.testing.expectFmt("eor wzr, wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
2126    try std.testing.expectFmt("eor w0, w0, wzr", "{f}", .{(try as.nextInstruction()).?});
2127    try std.testing.expectFmt("eor w1, w2, wzr", "{f}", .{(try as.nextInstruction()).?});
2128    try std.testing.expectFmt("eor w3, wzr, w3", "{f}", .{(try as.nextInstruction()).?});
2129    try std.testing.expectFmt("eor w4, wzr, w5", "{f}", .{(try as.nextInstruction()).?});
2130    try std.testing.expectFmt("eor w6, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2131    try std.testing.expectFmt("eor w7, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2132    try std.testing.expectFmt("eor wzr, w8, wzr", "{f}", .{(try as.nextInstruction()).?});
2133    try std.testing.expectFmt("eor wzr, w9, wzr", "{f}", .{(try as.nextInstruction()).?});
2134    try std.testing.expectFmt("eor wzr, wzr, w10", "{f}", .{(try as.nextInstruction()).?});
2135    try std.testing.expectFmt("eor wzr, wzr, w11", "{f}", .{(try as.nextInstruction()).?});
2136    try std.testing.expectFmt("eor wzr, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2137    try std.testing.expectFmt("eor wzr, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2138
2139    try std.testing.expectFmt("eor x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
2140    try std.testing.expectFmt("eor x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
2141    try std.testing.expectFmt("eor x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2142    try std.testing.expectFmt("eor x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
2143    try std.testing.expectFmt("eor x7, xzr, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2144    try std.testing.expectFmt("eor x9, xzr, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
2145    try std.testing.expectFmt("eor xzr, x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
2146    try std.testing.expectFmt("eor xzr, x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2147    try std.testing.expectFmt("eor xzr, xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
2148    try std.testing.expectFmt("eor xzr, xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
2149    try std.testing.expectFmt("eor x0, x0, xzr", "{f}", .{(try as.nextInstruction()).?});
2150    try std.testing.expectFmt("eor x1, x2, xzr", "{f}", .{(try as.nextInstruction()).?});
2151    try std.testing.expectFmt("eor x3, xzr, x3", "{f}", .{(try as.nextInstruction()).?});
2152    try std.testing.expectFmt("eor x4, xzr, x5", "{f}", .{(try as.nextInstruction()).?});
2153    try std.testing.expectFmt("eor x6, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2154    try std.testing.expectFmt("eor x7, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2155    try std.testing.expectFmt("eor xzr, x8, xzr", "{f}", .{(try as.nextInstruction()).?});
2156    try std.testing.expectFmt("eor xzr, x9, xzr", "{f}", .{(try as.nextInstruction()).?});
2157    try std.testing.expectFmt("eor xzr, xzr, x10", "{f}", .{(try as.nextInstruction()).?});
2158    try std.testing.expectFmt("eor xzr, xzr, x11", "{f}", .{(try as.nextInstruction()).?});
2159    try std.testing.expectFmt("eor xzr, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2160    try std.testing.expectFmt("eor xzr, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2161
2162    try std.testing.expectFmt("ands w0, w0, w0", "{f}", .{(try as.nextInstruction()).?});
2163    try std.testing.expectFmt("ands w1, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2164    try std.testing.expectFmt("ands w3, w4, w5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2165    try std.testing.expectFmt("ands w6, w6, wzr, lsl #31", "{f}", .{(try as.nextInstruction()).?});
2166    try std.testing.expectFmt("ands w7, wzr, w8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2167    try std.testing.expectFmt("ands w9, wzr, wzr, lsr #30", "{f}", .{(try as.nextInstruction()).?});
2168    try std.testing.expectFmt("tst w10, w11, lsr #31", "{f}", .{(try as.nextInstruction()).?});
2169    try std.testing.expectFmt("tst w12, wzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2170    try std.testing.expectFmt("tst wzr, w13, asr #16", "{f}", .{(try as.nextInstruction()).?});
2171    try std.testing.expectFmt("tst wzr, wzr, asr #31", "{f}", .{(try as.nextInstruction()).?});
2172    try std.testing.expectFmt("ands w0, w0, wzr", "{f}", .{(try as.nextInstruction()).?});
2173    try std.testing.expectFmt("ands w1, w2, wzr", "{f}", .{(try as.nextInstruction()).?});
2174    try std.testing.expectFmt("ands w3, wzr, w3", "{f}", .{(try as.nextInstruction()).?});
2175    try std.testing.expectFmt("ands w4, wzr, w5", "{f}", .{(try as.nextInstruction()).?});
2176    try std.testing.expectFmt("ands w6, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2177    try std.testing.expectFmt("ands w7, wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2178    try std.testing.expectFmt("tst w8, wzr", "{f}", .{(try as.nextInstruction()).?});
2179    try std.testing.expectFmt("tst w9, wzr", "{f}", .{(try as.nextInstruction()).?});
2180    try std.testing.expectFmt("tst wzr, w10", "{f}", .{(try as.nextInstruction()).?});
2181    try std.testing.expectFmt("tst wzr, w11", "{f}", .{(try as.nextInstruction()).?});
2182    try std.testing.expectFmt("tst wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2183    try std.testing.expectFmt("tst wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2184
2185    try std.testing.expectFmt("ands x0, x0, x0", "{f}", .{(try as.nextInstruction()).?});
2186    try std.testing.expectFmt("ands x1, x1, x2", "{f}", .{(try as.nextInstruction()).?});
2187    try std.testing.expectFmt("ands x3, x4, x5, lsl #1", "{f}", .{(try as.nextInstruction()).?});
2188    try std.testing.expectFmt("ands x6, x6, xzr, lsl #63", "{f}", .{(try as.nextInstruction()).?});
2189    try std.testing.expectFmt("ands x7, xzr, x8, lsr #0", "{f}", .{(try as.nextInstruction()).?});
2190    try std.testing.expectFmt("ands x9, xzr, xzr, lsr #62", "{f}", .{(try as.nextInstruction()).?});
2191    try std.testing.expectFmt("tst x10, x11, lsr #63", "{f}", .{(try as.nextInstruction()).?});
2192    try std.testing.expectFmt("tst x12, xzr, asr #0", "{f}", .{(try as.nextInstruction()).?});
2193    try std.testing.expectFmt("tst xzr, x13, asr #31", "{f}", .{(try as.nextInstruction()).?});
2194    try std.testing.expectFmt("tst xzr, xzr, asr #63", "{f}", .{(try as.nextInstruction()).?});
2195    try std.testing.expectFmt("ands x0, x0, xzr", "{f}", .{(try as.nextInstruction()).?});
2196    try std.testing.expectFmt("ands x1, x2, xzr", "{f}", .{(try as.nextInstruction()).?});
2197    try std.testing.expectFmt("ands x3, xzr, x3", "{f}", .{(try as.nextInstruction()).?});
2198    try std.testing.expectFmt("ands x4, xzr, x5", "{f}", .{(try as.nextInstruction()).?});
2199    try std.testing.expectFmt("ands x6, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2200    try std.testing.expectFmt("ands x7, xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2201    try std.testing.expectFmt("tst x8, xzr", "{f}", .{(try as.nextInstruction()).?});
2202    try std.testing.expectFmt("tst x9, xzr", "{f}", .{(try as.nextInstruction()).?});
2203    try std.testing.expectFmt("tst xzr, x10", "{f}", .{(try as.nextInstruction()).?});
2204    try std.testing.expectFmt("tst xzr, x11", "{f}", .{(try as.nextInstruction()).?});
2205    try std.testing.expectFmt("tst xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2206    try std.testing.expectFmt("tst xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2207
2208    try std.testing.expect(null == try as.nextInstruction());
2209}
2210test "mov" {
2211    var as: Assemble = .{
2212        .source =
2213        \\MOV W0, #0
2214        \\MOV WZR, #0xffff
2215        \\
2216        \\MOV X0, #0
2217        \\MOV XZR, #0xffff
2218        \\
2219        \\MOV W0, WSP
2220        \\MOV WSP, W1
2221        \\MOV WSP, WSP
2222        \\MOV X0, SP
2223        \\MOV SP, X1
2224        \\MOV SP, SP
2225        \\
2226        \\MOV W0, W0
2227        \\MOV W1, W2
2228        \\MOV W3, WZR
2229        \\MOV WZR, W4
2230        \\MOV WZR, WZR
2231        \\MOV X0, X0
2232        \\MOV X1, X2
2233        \\MOV X3, XZR
2234        \\MOV XZR, X4
2235        \\MOV XZR, XZR
2236        \\
2237        \\MOVK W0, #0
2238        \\MOVK W1, #1, lsl #0
2239        \\MOVK W2, #2, lsl #16
2240        \\MOVK X3, #3
2241        \\MOVK X4, #4, lsl #0x00
2242        \\MOVK X5, #5, lsl #0x10
2243        \\MOVK X6, #6, lsl #0x20
2244        \\MOVK X7, #7, lsl #0x30
2245        \\
2246        \\MOVN W0, #8
2247        \\MOVN W1, #9, lsl #0
2248        \\MOVN W2, #10, lsl #16
2249        \\MOVN X3, #11
2250        \\MOVN X4, #12, lsl #0x00
2251        \\MOVN X5, #13, lsl #0x10
2252        \\MOVN X6, #14, lsl #0x20
2253        \\MOVN X7, #15, lsl #0x30
2254        \\
2255        \\MOVN WZR, #0, lsl #0
2256        \\MOVN WZR, #0, lsl #16
2257        \\MOVN XZR, #0, lsl #0
2258        \\MOVN XZR, #0, lsl #16
2259        \\MOVN XZR, #0, lsl #32
2260        \\MOVN XZR, #0, lsl #48
2261        \\
2262        \\MOVN WZR, #0xffff, lsl #0
2263        \\MOVN WZR, #0xffff, lsl #16
2264        \\MOVN XZR, #0xffff, lsl #0
2265        \\MOVN XZR, #0xffff, lsl #16
2266        \\MOVN XZR, #0xffff, lsl #32
2267        \\MOVN XZR, #0xffff, lsl #48
2268        \\
2269        \\MOVZ W0, #16
2270        \\MOVZ W1, #17, lsl #0
2271        \\MOVZ W2, #18, lsl #16
2272        \\MOVZ X3, #19
2273        \\MOVZ X4, #20, lsl #0x00
2274        \\MOVZ X5, #21, lsl #0x10
2275        \\MOVZ X6, #22, lsl #0x20
2276        \\MOVZ X7, #23, lsl #0x30
2277        \\
2278        \\MOVZ WZR, #0, lsl #0
2279        \\MOVZ WZR, #0, lsl #16
2280        \\MOVZ XZR, #0, lsl #0
2281        \\MOVZ XZR, #0, lsl #16
2282        \\MOVZ XZR, #0, lsl #32
2283        \\MOVZ XZR, #0, lsl #48
2284        \\
2285        \\MOVZ WZR, #0xffff, lsl #0
2286        \\MOVZ WZR, #0xffff, lsl #16
2287        \\MOVZ XZR, #0xffff, lsl #0
2288        \\MOVZ XZR, #0xffff, lsl #16
2289        \\MOVZ XZR, #0xffff, lsl #32
2290        \\MOVZ XZR, #0xffff, lsl #48
2291        \\
2292        \\DUP B0, V1.B[15]
2293        \\DUP H2, V3.H[7]
2294        \\DUP S4, V5.S[3]
2295        \\DUP D6, V7.D[1]
2296        \\
2297        \\DUP V0.8B, V1.B[0]
2298        \\DUP V2.16B, V3.B[15]
2299        \\DUP V4.4H, V5.H[0]
2300        \\DUP V6.8H, V7.H[7]
2301        \\DUP V8.2S, V9.S[0]
2302        \\DUP V10.4S, V11.S[3]
2303        \\DUP V12.2D, V13.D[1]
2304        \\
2305        \\DUP V0.8B, W1
2306        \\DUP V2.16B, W3
2307        \\DUP V4.4H, W5
2308        \\DUP V6.8H, W7
2309        \\DUP V8.2S, W9
2310        \\DUP V10.4S, W11
2311        \\DUP V12.2D, X13
2312        \\
2313        \\FMOV V0.4H, #-31
2314        \\FMOV V1.8H, #-2.625
2315        \\FMOV V2.2S, #-1
2316        \\FMOV V3.4S, #-.2421875
2317        \\FMOV V4.2D, #.2421875
2318        \\FMOV H5, H6
2319        \\FMOV S7, S8
2320        \\FMOV D9, D10
2321        \\FMOV W11, H12
2322        \\FMOV X13, H14
2323        \\FMOV H15, W16
2324        \\FMOV S17, W18
2325        \\FMOV W19, S20
2326        \\FMOV H21, X22
2327        \\FMOV D23, X24
2328        \\FMOV V25.D[0x1], X26
2329        \\FMOV X27, D28
2330        \\FMOV X29, V30 . D [ 0X1 ]
2331        \\FMOV H31, #1
2332        \\FMOV S30, #2.625
2333        \\FMOV D29, #31
2334        \\
2335        \\INS V0.B[0], V1.B[15]
2336        \\INS V2.H[0], V3.H[7]
2337        \\INS V4.S[0], V5.S[3]
2338        \\INS V6.D[0], V7.D[1]
2339        \\
2340        \\INS V0.B[15], W1
2341        \\INS V2.H[7], W3
2342        \\INS V4.S[3], W5
2343        \\INS V6.D[1], X7
2344        \\
2345        \\MOV B0, V1.B [ 0xf]
2346        \\MOV H2, V3.H [ 0x7]
2347        \\MOV S4, V5.S [ 0x3]
2348        \\MOV D6, V7.D [ 0x1]
2349        \\
2350        \\MOV V0.B[0], V1.B[15]
2351        \\MOV V2.H[0], V3.H[7]
2352        \\MOV V4.S[0], V5.S[3]
2353        \\MOV V6.D[0], V7.D[1]
2354        \\
2355        \\MOV V0.B[15], W1
2356        \\MOV V2.H[7], W3
2357        \\MOV V4.S[3], W5
2358        \\MOV V6.D[1], X7
2359        \\
2360        \\MOV V0.8B, V1.8B
2361        \\MOV V2.16B, V3.16B
2362        \\
2363        \\MOV W0, V1.S[0x3]
2364        \\MOV X2, V3.D[0x1]
2365        \\
2366        \\SMOV W0, V1.B[0xF]
2367        \\SMOV W2, V3.H[0x7]
2368        \\SMOV X4, V5.B[0xF]
2369        \\SMOV X6, V7.H[0x7]
2370        \\SMOV X8, V9.S[0x3]
2371        \\
2372        \\UMOV W0, V1.B[0xF]
2373        \\UMOV W2, V3.H[0x7]
2374        \\UMOV W4, V5.S[0x3]
2375        \\UMOV X6, V7.D[0x1]
2376        ,
2377        .operands = .empty,
2378    };
2379
2380    try std.testing.expectFmt("mov w0, #0x0", "{f}", .{(try as.nextInstruction()).?});
2381    try std.testing.expectFmt("mov wzr, #0xffff", "{f}", .{(try as.nextInstruction()).?});
2382    try std.testing.expectFmt("mov x0, #0x0", "{f}", .{(try as.nextInstruction()).?});
2383    try std.testing.expectFmt("mov xzr, #0xffff", "{f}", .{(try as.nextInstruction()).?});
2384
2385    try std.testing.expectFmt("mov w0, wsp", "{f}", .{(try as.nextInstruction()).?});
2386    try std.testing.expectFmt("mov wsp, w1", "{f}", .{(try as.nextInstruction()).?});
2387    try std.testing.expectFmt("mov wsp, wsp", "{f}", .{(try as.nextInstruction()).?});
2388    try std.testing.expectFmt("mov x0, sp", "{f}", .{(try as.nextInstruction()).?});
2389    try std.testing.expectFmt("mov sp, x1", "{f}", .{(try as.nextInstruction()).?});
2390    try std.testing.expectFmt("mov sp, sp", "{f}", .{(try as.nextInstruction()).?});
2391
2392    try std.testing.expectFmt("mov w0, w0", "{f}", .{(try as.nextInstruction()).?});
2393    try std.testing.expectFmt("mov w1, w2", "{f}", .{(try as.nextInstruction()).?});
2394    try std.testing.expectFmt("mov w3, wzr", "{f}", .{(try as.nextInstruction()).?});
2395    try std.testing.expectFmt("mov wzr, w4", "{f}", .{(try as.nextInstruction()).?});
2396    try std.testing.expectFmt("mov wzr, wzr", "{f}", .{(try as.nextInstruction()).?});
2397    try std.testing.expectFmt("mov x0, x0", "{f}", .{(try as.nextInstruction()).?});
2398    try std.testing.expectFmt("mov x1, x2", "{f}", .{(try as.nextInstruction()).?});
2399    try std.testing.expectFmt("mov x3, xzr", "{f}", .{(try as.nextInstruction()).?});
2400    try std.testing.expectFmt("mov xzr, x4", "{f}", .{(try as.nextInstruction()).?});
2401    try std.testing.expectFmt("mov xzr, xzr", "{f}", .{(try as.nextInstruction()).?});
2402
2403    try std.testing.expectFmt("movk w0, #0x0", "{f}", .{(try as.nextInstruction()).?});
2404    try std.testing.expectFmt("movk w1, #0x1", "{f}", .{(try as.nextInstruction()).?});
2405    try std.testing.expectFmt("movk w2, #0x2, lsl #16", "{f}", .{(try as.nextInstruction()).?});
2406    try std.testing.expectFmt("movk x3, #0x3", "{f}", .{(try as.nextInstruction()).?});
2407    try std.testing.expectFmt("movk x4, #0x4", "{f}", .{(try as.nextInstruction()).?});
2408    try std.testing.expectFmt("movk x5, #0x5, lsl #16", "{f}", .{(try as.nextInstruction()).?});
2409    try std.testing.expectFmt("movk x6, #0x6, lsl #32", "{f}", .{(try as.nextInstruction()).?});
2410    try std.testing.expectFmt("movk x7, #0x7, lsl #48", "{f}", .{(try as.nextInstruction()).?});
2411
2412    try std.testing.expectFmt("mov w0, #-0x9", "{f}", .{(try as.nextInstruction()).?});
2413    try std.testing.expectFmt("mov w1, #-0xa", "{f}", .{(try as.nextInstruction()).?});
2414    try std.testing.expectFmt("mov w2, #-0xa0001", "{f}", .{(try as.nextInstruction()).?});
2415    try std.testing.expectFmt("mov x3, #-0xc", "{f}", .{(try as.nextInstruction()).?});
2416    try std.testing.expectFmt("mov x4, #-0xd", "{f}", .{(try as.nextInstruction()).?});
2417    try std.testing.expectFmt("mov x5, #-0xd0001", "{f}", .{(try as.nextInstruction()).?});
2418    try std.testing.expectFmt("mov x6, #-0xe00000001", "{f}", .{(try as.nextInstruction()).?});
2419    try std.testing.expectFmt("mov x7, #-0xf000000000001", "{f}", .{(try as.nextInstruction()).?});
2420
2421    try std.testing.expectFmt("mov wzr, #-0x1", "{f}", .{(try as.nextInstruction()).?});
2422    try std.testing.expectFmt("movn wzr, #0x0, lsl #16", "{f}", .{(try as.nextInstruction()).?});
2423    try std.testing.expectFmt("mov xzr, #-0x1", "{f}", .{(try as.nextInstruction()).?});
2424    try std.testing.expectFmt("movn xzr, #0x0, lsl #16", "{f}", .{(try as.nextInstruction()).?});
2425    try std.testing.expectFmt("movn xzr, #0x0, lsl #32", "{f}", .{(try as.nextInstruction()).?});
2426    try std.testing.expectFmt("movn xzr, #0x0, lsl #48", "{f}", .{(try as.nextInstruction()).?});
2427
2428    try std.testing.expectFmt("movn wzr, #0xffff", "{f}", .{(try as.nextInstruction()).?});
2429    try std.testing.expectFmt("movn wzr, #0xffff, lsl #16", "{f}", .{(try as.nextInstruction()).?});
2430    try std.testing.expectFmt("mov xzr, #-0x10000", "{f}", .{(try as.nextInstruction()).?});
2431    try std.testing.expectFmt("mov xzr, #-0xffff0001", "{f}", .{(try as.nextInstruction()).?});
2432    try std.testing.expectFmt("mov xzr, #-0xffff00000001", "{f}", .{(try as.nextInstruction()).?});
2433    try std.testing.expectFmt("mov xzr, #0xffffffffffff", "{f}", .{(try as.nextInstruction()).?});
2434
2435    try std.testing.expectFmt("mov w0, #0x10", "{f}", .{(try as.nextInstruction()).?});
2436    try std.testing.expectFmt("mov w1, #0x11", "{f}", .{(try as.nextInstruction()).?});
2437    try std.testing.expectFmt("mov w2, #0x120000", "{f}", .{(try as.nextInstruction()).?});
2438    try std.testing.expectFmt("mov x3, #0x13", "{f}", .{(try as.nextInstruction()).?});
2439    try std.testing.expectFmt("mov x4, #0x14", "{f}", .{(try as.nextInstruction()).?});
2440    try std.testing.expectFmt("mov x5, #0x150000", "{f}", .{(try as.nextInstruction()).?});
2441    try std.testing.expectFmt("mov x6, #0x1600000000", "{f}", .{(try as.nextInstruction()).?});
2442    try std.testing.expectFmt("mov x7, #0x17000000000000", "{f}", .{(try as.nextInstruction()).?});
2443
2444    try std.testing.expectFmt("mov wzr, #0x0", "{f}", .{(try as.nextInstruction()).?});
2445    try std.testing.expectFmt("movz wzr, #0x0, lsl #16", "{f}", .{(try as.nextInstruction()).?});
2446    try std.testing.expectFmt("mov xzr, #0x0", "{f}", .{(try as.nextInstruction()).?});
2447    try std.testing.expectFmt("movz xzr, #0x0, lsl #16", "{f}", .{(try as.nextInstruction()).?});
2448    try std.testing.expectFmt("movz xzr, #0x0, lsl #32", "{f}", .{(try as.nextInstruction()).?});
2449    try std.testing.expectFmt("movz xzr, #0x0, lsl #48", "{f}", .{(try as.nextInstruction()).?});
2450
2451    try std.testing.expectFmt("mov wzr, #0xffff", "{f}", .{(try as.nextInstruction()).?});
2452    try std.testing.expectFmt("mov wzr, #-0x10000", "{f}", .{(try as.nextInstruction()).?});
2453    try std.testing.expectFmt("mov xzr, #0xffff", "{f}", .{(try as.nextInstruction()).?});
2454    try std.testing.expectFmt("mov xzr, #0xffff0000", "{f}", .{(try as.nextInstruction()).?});
2455    try std.testing.expectFmt("mov xzr, #0xffff00000000", "{f}", .{(try as.nextInstruction()).?});
2456    try std.testing.expectFmt("mov xzr, #-0x1000000000000", "{f}", .{(try as.nextInstruction()).?});
2457
2458    try std.testing.expectFmt("mov b0, v1.b[15]", "{f}", .{(try as.nextInstruction()).?});
2459    try std.testing.expectFmt("mov h2, v3.h[7]", "{f}", .{(try as.nextInstruction()).?});
2460    try std.testing.expectFmt("mov s4, v5.s[3]", "{f}", .{(try as.nextInstruction()).?});
2461    try std.testing.expectFmt("mov d6, v7.d[1]", "{f}", .{(try as.nextInstruction()).?});
2462
2463    try std.testing.expectFmt("dup v0.8b, v1.b[0]", "{f}", .{(try as.nextInstruction()).?});
2464    try std.testing.expectFmt("dup v2.16b, v3.b[15]", "{f}", .{(try as.nextInstruction()).?});
2465    try std.testing.expectFmt("dup v4.4h, v5.h[0]", "{f}", .{(try as.nextInstruction()).?});
2466    try std.testing.expectFmt("dup v6.8h, v7.h[7]", "{f}", .{(try as.nextInstruction()).?});
2467    try std.testing.expectFmt("dup v8.2s, v9.s[0]", "{f}", .{(try as.nextInstruction()).?});
2468    try std.testing.expectFmt("dup v10.4s, v11.s[3]", "{f}", .{(try as.nextInstruction()).?});
2469    try std.testing.expectFmt("dup v12.2d, v13.d[1]", "{f}", .{(try as.nextInstruction()).?});
2470
2471    try std.testing.expectFmt("dup v0.8b, w1", "{f}", .{(try as.nextInstruction()).?});
2472    try std.testing.expectFmt("dup v2.16b, w3", "{f}", .{(try as.nextInstruction()).?});
2473    try std.testing.expectFmt("dup v4.4h, w5", "{f}", .{(try as.nextInstruction()).?});
2474    try std.testing.expectFmt("dup v6.8h, w7", "{f}", .{(try as.nextInstruction()).?});
2475    try std.testing.expectFmt("dup v8.2s, w9", "{f}", .{(try as.nextInstruction()).?});
2476    try std.testing.expectFmt("dup v10.4s, w11", "{f}", .{(try as.nextInstruction()).?});
2477    try std.testing.expectFmt("dup v12.2d, x13", "{f}", .{(try as.nextInstruction()).?});
2478
2479    try std.testing.expectFmt("fmov v0.4h, #-31.0", "{f}", .{(try as.nextInstruction()).?});
2480    try std.testing.expectFmt("fmov v1.8h, #-2.625", "{f}", .{(try as.nextInstruction()).?});
2481    try std.testing.expectFmt("fmov v2.2s, #-1.0", "{f}", .{(try as.nextInstruction()).?});
2482    try std.testing.expectFmt("fmov v3.4s, #-0.2421875", "{f}", .{(try as.nextInstruction()).?});
2483    try std.testing.expectFmt("fmov v4.2d, #0.2421875", "{f}", .{(try as.nextInstruction()).?});
2484    try std.testing.expectFmt("fmov h5, h6", "{f}", .{(try as.nextInstruction()).?});
2485    try std.testing.expectFmt("fmov s7, s8", "{f}", .{(try as.nextInstruction()).?});
2486    try std.testing.expectFmt("fmov d9, d10", "{f}", .{(try as.nextInstruction()).?});
2487    try std.testing.expectFmt("fmov w11, h12", "{f}", .{(try as.nextInstruction()).?});
2488    try std.testing.expectFmt("fmov x13, h14", "{f}", .{(try as.nextInstruction()).?});
2489    try std.testing.expectFmt("fmov h15, w16", "{f}", .{(try as.nextInstruction()).?});
2490    try std.testing.expectFmt("fmov s17, w18", "{f}", .{(try as.nextInstruction()).?});
2491    try std.testing.expectFmt("fmov w19, s20", "{f}", .{(try as.nextInstruction()).?});
2492    try std.testing.expectFmt("fmov h21, x22", "{f}", .{(try as.nextInstruction()).?});
2493    try std.testing.expectFmt("fmov d23, x24", "{f}", .{(try as.nextInstruction()).?});
2494    try std.testing.expectFmt("fmov v25.d[1], x26", "{f}", .{(try as.nextInstruction()).?});
2495    try std.testing.expectFmt("fmov x27, d28", "{f}", .{(try as.nextInstruction()).?});
2496    try std.testing.expectFmt("fmov x29, v30.d[1]", "{f}", .{(try as.nextInstruction()).?});
2497    try std.testing.expectFmt("fmov h31, #1.0", "{f}", .{(try as.nextInstruction()).?});
2498    try std.testing.expectFmt("fmov s30, #2.625", "{f}", .{(try as.nextInstruction()).?});
2499    try std.testing.expectFmt("fmov d29, #31.0", "{f}", .{(try as.nextInstruction()).?});
2500
2501    try std.testing.expectFmt("mov v0.b[0], v1.b[15]", "{f}", .{(try as.nextInstruction()).?});
2502    try std.testing.expectFmt("mov v2.h[0], v3.h[7]", "{f}", .{(try as.nextInstruction()).?});
2503    try std.testing.expectFmt("mov v4.s[0], v5.s[3]", "{f}", .{(try as.nextInstruction()).?});
2504    try std.testing.expectFmt("mov v6.d[0], v7.d[1]", "{f}", .{(try as.nextInstruction()).?});
2505
2506    try std.testing.expectFmt("mov v0.b[15], w1", "{f}", .{(try as.nextInstruction()).?});
2507    try std.testing.expectFmt("mov v2.h[7], w3", "{f}", .{(try as.nextInstruction()).?});
2508    try std.testing.expectFmt("mov v4.s[3], w5", "{f}", .{(try as.nextInstruction()).?});
2509    try std.testing.expectFmt("mov v6.d[1], x7", "{f}", .{(try as.nextInstruction()).?});
2510
2511    try std.testing.expectFmt("mov b0, v1.b[15]", "{f}", .{(try as.nextInstruction()).?});
2512    try std.testing.expectFmt("mov h2, v3.h[7]", "{f}", .{(try as.nextInstruction()).?});
2513    try std.testing.expectFmt("mov s4, v5.s[3]", "{f}", .{(try as.nextInstruction()).?});
2514    try std.testing.expectFmt("mov d6, v7.d[1]", "{f}", .{(try as.nextInstruction()).?});
2515
2516    try std.testing.expectFmt("mov v0.b[0], v1.b[15]", "{f}", .{(try as.nextInstruction()).?});
2517    try std.testing.expectFmt("mov v2.h[0], v3.h[7]", "{f}", .{(try as.nextInstruction()).?});
2518    try std.testing.expectFmt("mov v4.s[0], v5.s[3]", "{f}", .{(try as.nextInstruction()).?});
2519    try std.testing.expectFmt("mov v6.d[0], v7.d[1]", "{f}", .{(try as.nextInstruction()).?});
2520
2521    try std.testing.expectFmt("mov v0.b[15], w1", "{f}", .{(try as.nextInstruction()).?});
2522    try std.testing.expectFmt("mov v2.h[7], w3", "{f}", .{(try as.nextInstruction()).?});
2523    try std.testing.expectFmt("mov v4.s[3], w5", "{f}", .{(try as.nextInstruction()).?});
2524    try std.testing.expectFmt("mov v6.d[1], x7", "{f}", .{(try as.nextInstruction()).?});
2525
2526    try std.testing.expectFmt("mov v0.8b, v1.8b", "{f}", .{(try as.nextInstruction()).?});
2527    try std.testing.expectFmt("mov v2.16b, v3.16b", "{f}", .{(try as.nextInstruction()).?});
2528
2529    try std.testing.expectFmt("mov w0, v1.s[3]", "{f}", .{(try as.nextInstruction()).?});
2530    try std.testing.expectFmt("mov x2, v3.d[1]", "{f}", .{(try as.nextInstruction()).?});
2531
2532    try std.testing.expectFmt("smov w0, v1.b[15]", "{f}", .{(try as.nextInstruction()).?});
2533    try std.testing.expectFmt("smov w2, v3.h[7]", "{f}", .{(try as.nextInstruction()).?});
2534    try std.testing.expectFmt("smov x4, v5.b[15]", "{f}", .{(try as.nextInstruction()).?});
2535    try std.testing.expectFmt("smov x6, v7.h[7]", "{f}", .{(try as.nextInstruction()).?});
2536    try std.testing.expectFmt("smov x8, v9.s[3]", "{f}", .{(try as.nextInstruction()).?});
2537
2538    try std.testing.expectFmt("umov w0, v1.b[15]", "{f}", .{(try as.nextInstruction()).?});
2539    try std.testing.expectFmt("umov w2, v3.h[7]", "{f}", .{(try as.nextInstruction()).?});
2540    try std.testing.expectFmt("mov w4, v5.s[3]", "{f}", .{(try as.nextInstruction()).?});
2541    try std.testing.expectFmt("mov x6, v7.d[1]", "{f}", .{(try as.nextInstruction()).?});
2542
2543    try std.testing.expect(null == try as.nextInstruction());
2544}
2545test "multiply" {
2546    var as: Assemble = .{
2547        .source =
2548        \\madd w0, w1, w2, w3
2549        \\madd w4, w5, w6, wzr
2550        \\mul w7, w8, w9
2551        \\madd x10, x11, x12, x13
2552        \\madd x14, x15, x16, xzr
2553        \\mul x17, x18, x19
2554        \\
2555        \\msub w0, w1, w2, w3
2556        \\msub w4, w5, w6, wzr
2557        \\mneg w7, w8, w9
2558        \\msub x10, x11, x12, x13
2559        \\msub x14, x15, x16, xzr
2560        \\mneg x17, x18, x19
2561        \\
2562        \\smaddl x0, w1, w2, x3
2563        \\smaddl x4, w5, w6, xzr
2564        \\smull x7, w8, w9
2565        \\
2566        \\smsubl x0, w1, w2, x3
2567        \\smsubl x4, w5, w6, xzr
2568        \\smnegl x7, w8, w9
2569        \\
2570        \\smulh x0, x1, x2
2571        \\smulh x3, x4, xzr
2572        \\
2573        \\umaddl x0, w1, w2, x3
2574        \\umaddl x4, w5, w6, xzr
2575        \\umull x7, w8, w9
2576        \\
2577        \\umsubl x0, w1, w2, x3
2578        \\umsubl x4, w5, w6, xzr
2579        \\umnegl x7, w8, w9
2580        \\
2581        \\umulh x0, x1, x2
2582        \\umulh x3, x4, xzr
2583        ,
2584        .operands = .empty,
2585    };
2586
2587    try std.testing.expectFmt("madd w0, w1, w2, w3", "{f}", .{(try as.nextInstruction()).?});
2588    try std.testing.expectFmt("mul w4, w5, w6", "{f}", .{(try as.nextInstruction()).?});
2589    try std.testing.expectFmt("mul w7, w8, w9", "{f}", .{(try as.nextInstruction()).?});
2590    try std.testing.expectFmt("madd x10, x11, x12, x13", "{f}", .{(try as.nextInstruction()).?});
2591    try std.testing.expectFmt("mul x14, x15, x16", "{f}", .{(try as.nextInstruction()).?});
2592    try std.testing.expectFmt("mul x17, x18, x19", "{f}", .{(try as.nextInstruction()).?});
2593
2594    try std.testing.expectFmt("msub w0, w1, w2, w3", "{f}", .{(try as.nextInstruction()).?});
2595    try std.testing.expectFmt("mneg w4, w5, w6", "{f}", .{(try as.nextInstruction()).?});
2596    try std.testing.expectFmt("mneg w7, w8, w9", "{f}", .{(try as.nextInstruction()).?});
2597    try std.testing.expectFmt("msub x10, x11, x12, x13", "{f}", .{(try as.nextInstruction()).?});
2598    try std.testing.expectFmt("mneg x14, x15, x16", "{f}", .{(try as.nextInstruction()).?});
2599    try std.testing.expectFmt("mneg x17, x18, x19", "{f}", .{(try as.nextInstruction()).?});
2600
2601    try std.testing.expectFmt("smaddl x0, w1, w2, x3", "{f}", .{(try as.nextInstruction()).?});
2602    try std.testing.expectFmt("smull x4, w5, w6", "{f}", .{(try as.nextInstruction()).?});
2603    try std.testing.expectFmt("smull x7, w8, w9", "{f}", .{(try as.nextInstruction()).?});
2604
2605    try std.testing.expectFmt("smsubl x0, w1, w2, x3", "{f}", .{(try as.nextInstruction()).?});
2606    try std.testing.expectFmt("smnegl x4, w5, w6", "{f}", .{(try as.nextInstruction()).?});
2607    try std.testing.expectFmt("smnegl x7, w8, w9", "{f}", .{(try as.nextInstruction()).?});
2608
2609    try std.testing.expectFmt("smulh x0, x1, x2", "{f}", .{(try as.nextInstruction()).?});
2610    try std.testing.expectFmt("smulh x3, x4, xzr", "{f}", .{(try as.nextInstruction()).?});
2611
2612    try std.testing.expectFmt("umaddl x0, w1, w2, x3", "{f}", .{(try as.nextInstruction()).?});
2613    try std.testing.expectFmt("umull x4, w5, w6", "{f}", .{(try as.nextInstruction()).?});
2614    try std.testing.expectFmt("umull x7, w8, w9", "{f}", .{(try as.nextInstruction()).?});
2615
2616    try std.testing.expectFmt("umsubl x0, w1, w2, x3", "{f}", .{(try as.nextInstruction()).?});
2617    try std.testing.expectFmt("umnegl x4, w5, w6", "{f}", .{(try as.nextInstruction()).?});
2618    try std.testing.expectFmt("umnegl x7, w8, w9", "{f}", .{(try as.nextInstruction()).?});
2619
2620    try std.testing.expectFmt("umulh x0, x1, x2", "{f}", .{(try as.nextInstruction()).?});
2621    try std.testing.expectFmt("umulh x3, x4, xzr", "{f}", .{(try as.nextInstruction()).?});
2622
2623    try std.testing.expect(null == try as.nextInstruction());
2624}
2625test "reserved" {
2626    var as: Assemble = .{
2627        .source = "\n\nudf #0x0\n\t\n\tudf\t#01234\n    \nudf#65535",
2628        .operands = .empty,
2629    };
2630
2631    try std.testing.expectFmt("udf #0x0", "{f}", .{(try as.nextInstruction()).?});
2632    try std.testing.expectFmt("udf #0x4d2", "{f}", .{(try as.nextInstruction()).?});
2633    try std.testing.expectFmt("udf #0xffff", "{f}", .{(try as.nextInstruction()).?});
2634
2635    try std.testing.expect(null == try as.nextInstruction());
2636}
2637test "shift" {
2638    var as: Assemble = .{
2639        .source =
2640        \\lsl w0, w1, w2
2641        \\lslv w3, w4, wzr
2642        \\lsl x5, x6, xzr
2643        \\lslv x7, x8, x9
2644        \\
2645        \\lsr w0, w1, w2
2646        \\lsrv w3, w4, wzr
2647        \\lsr x5, x6, xzr
2648        \\lsrv x7, x8, x9
2649        \\
2650        \\asr w0, w1, w2
2651        \\asrv w3, w4, wzr
2652        \\asr x5, x6, xzr
2653        \\asrv x7, x8, x9
2654        \\
2655        \\ror w0, w1, w2
2656        \\rorv w3, w4, wzr
2657        \\ror x5, x6, xzr
2658        \\rorv x7, x8, x9
2659        ,
2660        .operands = .empty,
2661    };
2662
2663    try std.testing.expectFmt("lsl w0, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2664    try std.testing.expectFmt("lsl w3, w4, wzr", "{f}", .{(try as.nextInstruction()).?});
2665    try std.testing.expectFmt("lsl x5, x6, xzr", "{f}", .{(try as.nextInstruction()).?});
2666    try std.testing.expectFmt("lsl x7, x8, x9", "{f}", .{(try as.nextInstruction()).?});
2667
2668    try std.testing.expectFmt("lsr w0, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2669    try std.testing.expectFmt("lsr w3, w4, wzr", "{f}", .{(try as.nextInstruction()).?});
2670    try std.testing.expectFmt("lsr x5, x6, xzr", "{f}", .{(try as.nextInstruction()).?});
2671    try std.testing.expectFmt("lsr x7, x8, x9", "{f}", .{(try as.nextInstruction()).?});
2672
2673    try std.testing.expectFmt("asr w0, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2674    try std.testing.expectFmt("asr w3, w4, wzr", "{f}", .{(try as.nextInstruction()).?});
2675    try std.testing.expectFmt("asr x5, x6, xzr", "{f}", .{(try as.nextInstruction()).?});
2676    try std.testing.expectFmt("asr x7, x8, x9", "{f}", .{(try as.nextInstruction()).?});
2677
2678    try std.testing.expectFmt("ror w0, w1, w2", "{f}", .{(try as.nextInstruction()).?});
2679    try std.testing.expectFmt("ror w3, w4, wzr", "{f}", .{(try as.nextInstruction()).?});
2680    try std.testing.expectFmt("ror x5, x6, xzr", "{f}", .{(try as.nextInstruction()).?});
2681    try std.testing.expectFmt("ror x7, x8, x9", "{f}", .{(try as.nextInstruction()).?});
2682
2683    try std.testing.expect(null == try as.nextInstruction());
2684}
2685test "unary vector" {
2686    var as: Assemble = .{
2687        .source =
2688        \\SUQADD B0, B1
2689        \\SUQADD H2, H3
2690        \\SUQADD S4, S5
2691        \\SUQADD D6, D7
2692        \\SUQADD V8.8B, V9.8B
2693        \\SUQADD V10.16B, V11.16B
2694        \\SUQADD V12.4H, V13.4H
2695        \\SUQADD V14.8H, V15.8H
2696        \\SUQADD V16.2S, V17.2S
2697        \\SUQADD V18.4S, V19.4S
2698        \\SUQADD V20.2D, V21.2D
2699        \\
2700        \\CNT V0.8B, V1.8B
2701        \\CNT V2.16B, V3.16B
2702        \\
2703        \\SQABS B0, B1
2704        \\SQABS H2, H3
2705        \\SQABS S4, S5
2706        \\SQABS D6, D7
2707        \\SQABS V8.8B, V9.8B
2708        \\SQABS V10.16B, V11.16B
2709        \\SQABS V12.4H, V13.4H
2710        \\SQABS V14.8H, V15.8H
2711        \\SQABS V16.2S, V17.2S
2712        \\SQABS V18.4S, V19.4S
2713        \\SQABS V20.2D, V21.2D
2714        \\
2715        \\CMGT D0, D1, #00
2716        \\CMGT V2.8B, V3.8B, #0
2717        \\CMGT V4.16B, V5.16B, #0
2718        \\CMGT V6.4H, V7.4H, #0
2719        \\CMGT V8.8H, V9.8H, #0
2720        \\CMGT V10.2S, V11.2S, #0
2721        \\CMGT V12.4S, V13.4S, #0
2722        \\CMGT V14.2D, V15.2D, #0
2723        \\
2724        \\CMEQ D0, D1, #00
2725        \\CMEQ V2.8B, V3.8B, #0
2726        \\CMEQ V4.16B, V5.16B, #0
2727        \\CMEQ V6.4H, V7.4H, #0
2728        \\CMEQ V8.8H, V9.8H, #0
2729        \\CMEQ V10.2S, V11.2S, #0
2730        \\CMEQ V12.4S, V13.4S, #0
2731        \\CMEQ V14.2D, V15.2D, #0
2732        \\
2733        \\CMLT D0, D1, #00
2734        \\CMLT V2.8B, V3.8B, #0
2735        \\CMLT V4.16B, V5.16B, #0
2736        \\CMLT V6.4H, V7.4H, #0
2737        \\CMLT V8.8H, V9.8H, #0
2738        \\CMLT V10.2S, V11.2S, #0
2739        \\CMLT V12.4S, V13.4S, #0
2740        \\CMLT V14.2D, V15.2D, #0
2741        \\
2742        \\ABS D0, D1
2743        \\ABS V2.8B, V3.8B
2744        \\ABS V4.16B, V5.16B
2745        \\ABS V6.4H, V7.4H
2746        \\ABS V8.8H, V9.8H
2747        \\ABS V10.2S, V11.2S
2748        \\ABS V12.4S, V13.4S
2749        \\ABS V14.2D, V15.2D
2750        \\
2751        \\SQXTN B0, H1
2752        \\SQXTN H2, S3
2753        \\SQXTN S4, D5
2754        \\SQXTN V6.8B, V7.8H
2755        \\SQXTN2 V8.16B, V9.8H
2756        \\SQXTN V10.4H, V11.4S
2757        \\SQXTN2 V12.8H, V13.4S
2758        \\SQXTN V14.2S, V15.2D
2759        \\SQXTN2 V16.4S, V17.2D
2760        \\
2761        \\FRINTN V0.4H, V1.4H
2762        \\FRINTN V2.8H, V3.8H
2763        \\FRINTN V4.2S, V5.2S
2764        \\FRINTN V6.4S, V7.4S
2765        \\FRINTN V8.2D, V9.2D
2766        \\FRINTN H10, H11
2767        \\FRINTN S12, S13
2768        \\FRINTN D14, D15
2769        \\
2770        \\FRINTM V0.4H, V1.4H
2771        \\FRINTM V2.8H, V3.8H
2772        \\FRINTM V4.2S, V5.2S
2773        \\FRINTM V6.4S, V7.4S
2774        \\FRINTM V8.2D, V9.2D
2775        \\FRINTM H10, H11
2776        \\FRINTM S12, S13
2777        \\FRINTM D14, D15
2778        \\
2779        \\FCVTNS H0, H1
2780        \\FCVTNS S2, S3
2781        \\FCVTNS D4, D5
2782        \\FCVTNS V6.4H, V7.4H
2783        \\FCVTNS V8.8H, V9.8H
2784        \\FCVTNS V10.2S, V11.2S
2785        \\FCVTNS V12.4S, V13.4S
2786        \\FCVTNS V14.2D, V15.2D
2787        \\FCVTNS W16, H17
2788        \\FCVTNS X18, H19
2789        \\FCVTNS W20, S21
2790        \\FCVTNS X22, S23
2791        \\FCVTNS W24, D25
2792        \\FCVTNS X26, D27
2793        \\
2794        \\FCVTMS H0, H1
2795        \\FCVTMS S2, S3
2796        \\FCVTMS D4, D5
2797        \\FCVTMS V6.4H, V7.4H
2798        \\FCVTMS V8.8H, V9.8H
2799        \\FCVTMS V10.2S, V11.2S
2800        \\FCVTMS V12.4S, V13.4S
2801        \\FCVTMS V14.2D, V15.2D
2802        \\FCVTMS W16, H17
2803        \\FCVTMS X18, H19
2804        \\FCVTMS W20, S21
2805        \\FCVTMS X22, S23
2806        \\FCVTMS W24, D25
2807        \\FCVTMS X26, D27
2808        \\
2809        \\FCVTAS H0, H1
2810        \\FCVTAS S2, S3
2811        \\FCVTAS D4, D5
2812        \\FCVTAS V6.4H, V7.4H
2813        \\FCVTAS V8.8H, V9.8H
2814        \\FCVTAS V10.2S, V11.2S
2815        \\FCVTAS V12.4S, V13.4S
2816        \\FCVTAS V14.2D, V15.2D
2817        \\FCVTAS W16, H17
2818        \\FCVTAS X18, H19
2819        \\FCVTAS W20, S21
2820        \\FCVTAS X22, S23
2821        \\FCVTAS W24, D25
2822        \\FCVTAS X26, D27
2823        \\
2824        \\SCVTF H0, H1
2825        \\SCVTF S2, S3
2826        \\SCVTF D4, D5
2827        \\SCVTF V6.4H, V7.4H
2828        \\SCVTF V8.8H, V9.8H
2829        \\SCVTF V10.2S, V11.2S
2830        \\SCVTF V12.4S, V13.4S
2831        \\SCVTF V14.2D, V15.2D
2832        \\SCVTF H16, W17
2833        \\SCVTF H18, X19
2834        \\SCVTF S20, W21
2835        \\SCVTF S22, X23
2836        \\SCVTF D24, W25
2837        \\SCVTF D26, X27
2838        \\
2839        \\FCMGT H0, H1, #0.0
2840        \\FCMGT S2, S3, # 0.0
2841        \\FCMGT D4, D5, #+0.0
2842        \\FCMGT V6.4H, V7.4H, # +0.0
2843        \\FCMGT V8.8H, V9.8H, #0
2844        \\FCMGT V10.2S, V11.2S, # 0
2845        \\FCMGT V12.4S, V13.4S, #+0
2846        \\FCMGT V14.2D, V15.2D, # +0
2847        \\
2848        \\FCMEQ H0, H1, #0.0
2849        \\FCMEQ S2, S3, # 0.0
2850        \\FCMEQ D4, D5, #+0.0
2851        \\FCMEQ V6.4H, V7.4H, # +0.0
2852        \\FCMEQ V8.8H, V9.8H, #0
2853        \\FCMEQ V10.2S, V11.2S, # 0
2854        \\FCMEQ V12.4S, V13.4S, #+0
2855        \\FCMEQ V14.2D, V15.2D, # +0
2856        \\
2857        \\FCMLT H0, H1, #0.0
2858        \\FCMLT S2, S3, # 0.0
2859        \\FCMLT D4, D5, #+0.0
2860        \\FCMLT V6.4H, V7.4H, # +0.0
2861        \\FCMLT V8.8H, V9.8H, #0
2862        \\FCMLT V10.2S, V11.2S, # 0
2863        \\FCMLT V12.4S, V13.4S, #+0
2864        \\FCMLT V14.2D, V15.2D, # +0
2865        \\
2866        \\FRINTP V0.4H, V1.4H
2867        \\FRINTP V2.8H, V3.8H
2868        \\FRINTP V4.2S, V5.2S
2869        \\FRINTP V6.4S, V7.4S
2870        \\FRINTP V8.2D, V9.2D
2871        \\FRINTP H10, H11
2872        \\FRINTP S12, S13
2873        \\FRINTP D14, D15
2874        \\
2875        \\FRINTZ V0.4H, V1.4H
2876        \\FRINTZ V2.8H, V3.8H
2877        \\FRINTZ V4.2S, V5.2S
2878        \\FRINTZ V6.4S, V7.4S
2879        \\FRINTZ V8.2D, V9.2D
2880        \\FRINTZ H10, H11
2881        \\FRINTZ S12, S13
2882        \\FRINTZ D14, D15
2883        \\
2884        \\FCVTPS H0, H1
2885        \\FCVTPS S2, S3
2886        \\FCVTPS D4, D5
2887        \\FCVTPS V6.4H, V7.4H
2888        \\FCVTPS V8.8H, V9.8H
2889        \\FCVTPS V10.2S, V11.2S
2890        \\FCVTPS V12.4S, V13.4S
2891        \\FCVTPS V14.2D, V15.2D
2892        \\FCVTPS W16, H17
2893        \\FCVTPS X18, H19
2894        \\FCVTPS W20, S21
2895        \\FCVTPS X22, S23
2896        \\FCVTPS W24, D25
2897        \\FCVTPS X26, D27
2898        \\
2899        \\FCVTZS H0, H1
2900        \\FCVTZS S2, S3
2901        \\FCVTZS D4, D5
2902        \\FCVTZS V6.4H, V7.4H
2903        \\FCVTZS V8.8H, V9.8H
2904        \\FCVTZS V10.2S, V11.2S
2905        \\FCVTZS V12.4S, V13.4S
2906        \\FCVTZS V14.2D, V15.2D
2907        \\FCVTZS W16, H17
2908        \\FCVTZS X18, H19
2909        \\FCVTZS W20, S21
2910        \\FCVTZS X22, S23
2911        \\FCVTZS W24, D25
2912        \\FCVTZS X26, D27
2913        \\
2914        \\CMGE D0, D1, #00
2915        \\CMGE V2.8B, V3.8B, #0
2916        \\CMGE V4.16B, V5.16B, #0
2917        \\CMGE V6.4H, V7.4H, #0
2918        \\CMGE V8.8H, V9.8H, #0
2919        \\CMGE V10.2S, V11.2S, #0
2920        \\CMGE V12.4S, V13.4S, #0
2921        \\CMGE V14.2D, V15.2D, #0
2922        \\
2923        \\CMLE D0, D1, #00
2924        \\CMLE V2.8B, V3.8B, #0
2925        \\CMLE V4.16B, V5.16B, #0
2926        \\CMLE V6.4H, V7.4H, #0
2927        \\CMLE V8.8H, V9.8H, #0
2928        \\CMLE V10.2S, V11.2S, #0
2929        \\CMLE V12.4S, V13.4S, #0
2930        \\CMLE V14.2D, V15.2D, #0
2931        \\
2932        \\NEG D0, D1
2933        \\NEG V2.8B, V3.8B
2934        \\NEG V4.16B, V5.16B
2935        \\NEG V6.4H, V7.4H
2936        \\NEG V8.8H, V9.8H
2937        \\NEG V10.2S, V11.2S
2938        \\NEG V12.4S, V13.4S
2939        \\NEG V14.2D, V15.2D
2940        \\
2941        \\FCVTNU H0, H1
2942        \\FCVTNU S2, S3
2943        \\FCVTNU D4, D5
2944        \\FCVTNU V6.4H, V7.4H
2945        \\FCVTNU V8.8H, V9.8H
2946        \\FCVTNU V10.2S, V11.2S
2947        \\FCVTNU V12.4S, V13.4S
2948        \\FCVTNU V14.2D, V15.2D
2949        \\FCVTNU W16, H17
2950        \\FCVTNU X18, H19
2951        \\FCVTNU W20, S21
2952        \\FCVTNU X22, S23
2953        \\FCVTNU W24, D25
2954        \\FCVTNU X26, D27
2955        \\
2956        \\FCVTMU H0, H1
2957        \\FCVTMU S2, S3
2958        \\FCVTMU D4, D5
2959        \\FCVTMU V6.4H, V7.4H
2960        \\FCVTMU V8.8H, V9.8H
2961        \\FCVTMU V10.2S, V11.2S
2962        \\FCVTMU V12.4S, V13.4S
2963        \\FCVTMU V14.2D, V15.2D
2964        \\FCVTMU W16, H17
2965        \\FCVTMU X18, H19
2966        \\FCVTMU W20, S21
2967        \\FCVTMU X22, S23
2968        \\FCVTMU W24, D25
2969        \\FCVTMU X26, D27
2970        \\
2971        \\FCVTAU H0, H1
2972        \\FCVTAU S2, S3
2973        \\FCVTAU D4, D5
2974        \\FCVTAU V6.4H, V7.4H
2975        \\FCVTAU V8.8H, V9.8H
2976        \\FCVTAU V10.2S, V11.2S
2977        \\FCVTAU V12.4S, V13.4S
2978        \\FCVTAU V14.2D, V15.2D
2979        \\FCVTAU W16, H17
2980        \\FCVTAU X18, H19
2981        \\FCVTAU W20, S21
2982        \\FCVTAU X22, S23
2983        \\FCVTAU W24, D25
2984        \\FCVTAU X26, D27
2985        \\
2986        \\UCVTF H0, H1
2987        \\UCVTF S2, S3
2988        \\UCVTF D4, D5
2989        \\UCVTF V6.4H, V7.4H
2990        \\UCVTF V8.8H, V9.8H
2991        \\UCVTF V10.2S, V11.2S
2992        \\UCVTF V12.4S, V13.4S
2993        \\UCVTF V14.2D, V15.2D
2994        \\UCVTF H16, W17
2995        \\UCVTF H18, X19
2996        \\UCVTF S20, W21
2997        \\UCVTF S22, X23
2998        \\UCVTF D24, W25
2999        \\UCVTF D26, X27
3000        \\
3001        \\NOT V0.8B, V1.8B
3002        \\NOT V2.16B, V3.16B
3003        \\
3004        \\FCMGE H0, H1, #0.0
3005        \\FCMGE S2, S3, # 0.0
3006        \\FCMGE D4, D5, #+0.0
3007        \\FCMGE V6.4H, V7.4H, # +0.0
3008        \\FCMGE V8.8H, V9.8H, #0
3009        \\FCMGE V10.2S, V11.2S, # 0
3010        \\FCMGE V12.4S, V13.4S, #+0
3011        \\FCMGE V14.2D, V15.2D, # +0
3012        \\
3013        \\FCMLE H0, H1, #0.0
3014        \\FCMLE S2, S3, # 0.0
3015        \\FCMLE D4, D5, #+0.0
3016        \\FCMLE V6.4H, V7.4H, # +0.0
3017        \\FCMLE V8.8H, V9.8H, #0
3018        \\FCMLE V10.2S, V11.2S, # 0
3019        \\FCMLE V12.4S, V13.4S, #+0
3020        \\FCMLE V14.2D, V15.2D, # +0
3021        \\
3022        \\FRINTI V0.4H, V1.4H
3023        \\FRINTI V2.8H, V3.8H
3024        \\FRINTI V4.2S, V5.2S
3025        \\FRINTI V6.4S, V7.4S
3026        \\FRINTI V8.2D, V9.2D
3027        \\FRINTI H10, H11
3028        \\FRINTI S12, S13
3029        \\FRINTI D14, D15
3030        \\
3031        \\FCVTPU H0, H1
3032        \\FCVTPU S2, S3
3033        \\FCVTPU D4, D5
3034        \\FCVTPU V6.4H, V7.4H
3035        \\FCVTPU V8.8H, V9.8H
3036        \\FCVTPU V10.2S, V11.2S
3037        \\FCVTPU V12.4S, V13.4S
3038        \\FCVTPU V14.2D, V15.2D
3039        \\FCVTPU W16, H17
3040        \\FCVTPU X18, H19
3041        \\FCVTPU W20, S21
3042        \\FCVTPU X22, S23
3043        \\FCVTPU W24, D25
3044        \\FCVTPU X26, D27
3045        \\
3046        \\FCVTZU H0, H1
3047        \\FCVTZU S2, S3
3048        \\FCVTZU D4, D5
3049        \\FCVTZU V6.4H, V7.4H
3050        \\FCVTZU V8.8H, V9.8H
3051        \\FCVTZU V10.2S, V11.2S
3052        \\FCVTZU V12.4S, V13.4S
3053        \\FCVTZU V14.2D, V15.2D
3054        \\FCVTZU W16, H17
3055        \\FCVTZU X18, H19
3056        \\FCVTZU W20, S21
3057        \\FCVTZU X22, S23
3058        \\FCVTZU W24, D25
3059        \\FCVTZU X26, D27
3060        ,
3061        .operands = .empty,
3062    };
3063
3064    try std.testing.expectFmt("suqadd b0, b1", "{f}", .{(try as.nextInstruction()).?});
3065    try std.testing.expectFmt("suqadd h2, h3", "{f}", .{(try as.nextInstruction()).?});
3066    try std.testing.expectFmt("suqadd s4, s5", "{f}", .{(try as.nextInstruction()).?});
3067    try std.testing.expectFmt("suqadd d6, d7", "{f}", .{(try as.nextInstruction()).?});
3068    try std.testing.expectFmt("suqadd v8.8b, v9.8b", "{f}", .{(try as.nextInstruction()).?});
3069    try std.testing.expectFmt("suqadd v10.16b, v11.16b", "{f}", .{(try as.nextInstruction()).?});
3070    try std.testing.expectFmt("suqadd v12.4h, v13.4h", "{f}", .{(try as.nextInstruction()).?});
3071    try std.testing.expectFmt("suqadd v14.8h, v15.8h", "{f}", .{(try as.nextInstruction()).?});
3072    try std.testing.expectFmt("suqadd v16.2s, v17.2s", "{f}", .{(try as.nextInstruction()).?});
3073    try std.testing.expectFmt("suqadd v18.4s, v19.4s", "{f}", .{(try as.nextInstruction()).?});
3074    try std.testing.expectFmt("suqadd v20.2d, v21.2d", "{f}", .{(try as.nextInstruction()).?});
3075
3076    try std.testing.expectFmt("cnt v0.8b, v1.8b", "{f}", .{(try as.nextInstruction()).?});
3077    try std.testing.expectFmt("cnt v2.16b, v3.16b", "{f}", .{(try as.nextInstruction()).?});
3078
3079    try std.testing.expectFmt("sqabs b0, b1", "{f}", .{(try as.nextInstruction()).?});
3080    try std.testing.expectFmt("sqabs h2, h3", "{f}", .{(try as.nextInstruction()).?});
3081    try std.testing.expectFmt("sqabs s4, s5", "{f}", .{(try as.nextInstruction()).?});
3082    try std.testing.expectFmt("sqabs d6, d7", "{f}", .{(try as.nextInstruction()).?});
3083    try std.testing.expectFmt("sqabs v8.8b, v9.8b", "{f}", .{(try as.nextInstruction()).?});
3084    try std.testing.expectFmt("sqabs v10.16b, v11.16b", "{f}", .{(try as.nextInstruction()).?});
3085    try std.testing.expectFmt("sqabs v12.4h, v13.4h", "{f}", .{(try as.nextInstruction()).?});
3086    try std.testing.expectFmt("sqabs v14.8h, v15.8h", "{f}", .{(try as.nextInstruction()).?});
3087    try std.testing.expectFmt("sqabs v16.2s, v17.2s", "{f}", .{(try as.nextInstruction()).?});
3088    try std.testing.expectFmt("sqabs v18.4s, v19.4s", "{f}", .{(try as.nextInstruction()).?});
3089    try std.testing.expectFmt("sqabs v20.2d, v21.2d", "{f}", .{(try as.nextInstruction()).?});
3090
3091    try std.testing.expectFmt("cmgt d0, d1, #0", "{f}", .{(try as.nextInstruction()).?});
3092    try std.testing.expectFmt("cmgt v2.8b, v3.8b, #0", "{f}", .{(try as.nextInstruction()).?});
3093    try std.testing.expectFmt("cmgt v4.16b, v5.16b, #0", "{f}", .{(try as.nextInstruction()).?});
3094    try std.testing.expectFmt("cmgt v6.4h, v7.4h, #0", "{f}", .{(try as.nextInstruction()).?});
3095    try std.testing.expectFmt("cmgt v8.8h, v9.8h, #0", "{f}", .{(try as.nextInstruction()).?});
3096    try std.testing.expectFmt("cmgt v10.2s, v11.2s, #0", "{f}", .{(try as.nextInstruction()).?});
3097    try std.testing.expectFmt("cmgt v12.4s, v13.4s, #0", "{f}", .{(try as.nextInstruction()).?});
3098    try std.testing.expectFmt("cmgt v14.2d, v15.2d, #0", "{f}", .{(try as.nextInstruction()).?});
3099
3100    try std.testing.expectFmt("cmeq d0, d1, #0", "{f}", .{(try as.nextInstruction()).?});
3101    try std.testing.expectFmt("cmeq v2.8b, v3.8b, #0", "{f}", .{(try as.nextInstruction()).?});
3102    try std.testing.expectFmt("cmeq v4.16b, v5.16b, #0", "{f}", .{(try as.nextInstruction()).?});
3103    try std.testing.expectFmt("cmeq v6.4h, v7.4h, #0", "{f}", .{(try as.nextInstruction()).?});
3104    try std.testing.expectFmt("cmeq v8.8h, v9.8h, #0", "{f}", .{(try as.nextInstruction()).?});
3105    try std.testing.expectFmt("cmeq v10.2s, v11.2s, #0", "{f}", .{(try as.nextInstruction()).?});
3106    try std.testing.expectFmt("cmeq v12.4s, v13.4s, #0", "{f}", .{(try as.nextInstruction()).?});
3107    try std.testing.expectFmt("cmeq v14.2d, v15.2d, #0", "{f}", .{(try as.nextInstruction()).?});
3108
3109    try std.testing.expectFmt("cmlt d0, d1, #0", "{f}", .{(try as.nextInstruction()).?});
3110    try std.testing.expectFmt("cmlt v2.8b, v3.8b, #0", "{f}", .{(try as.nextInstruction()).?});
3111    try std.testing.expectFmt("cmlt v4.16b, v5.16b, #0", "{f}", .{(try as.nextInstruction()).?});
3112    try std.testing.expectFmt("cmlt v6.4h, v7.4h, #0", "{f}", .{(try as.nextInstruction()).?});
3113    try std.testing.expectFmt("cmlt v8.8h, v9.8h, #0", "{f}", .{(try as.nextInstruction()).?});
3114    try std.testing.expectFmt("cmlt v10.2s, v11.2s, #0", "{f}", .{(try as.nextInstruction()).?});
3115    try std.testing.expectFmt("cmlt v12.4s, v13.4s, #0", "{f}", .{(try as.nextInstruction()).?});
3116    try std.testing.expectFmt("cmlt v14.2d, v15.2d, #0", "{f}", .{(try as.nextInstruction()).?});
3117
3118    try std.testing.expectFmt("abs d0, d1", "{f}", .{(try as.nextInstruction()).?});
3119    try std.testing.expectFmt("abs v2.8b, v3.8b", "{f}", .{(try as.nextInstruction()).?});
3120    try std.testing.expectFmt("abs v4.16b, v5.16b", "{f}", .{(try as.nextInstruction()).?});
3121    try std.testing.expectFmt("abs v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3122    try std.testing.expectFmt("abs v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3123    try std.testing.expectFmt("abs v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3124    try std.testing.expectFmt("abs v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3125    try std.testing.expectFmt("abs v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3126
3127    try std.testing.expectFmt("sqxtn b0, h1", "{f}", .{(try as.nextInstruction()).?});
3128    try std.testing.expectFmt("sqxtn h2, s3", "{f}", .{(try as.nextInstruction()).?});
3129    try std.testing.expectFmt("sqxtn s4, d5", "{f}", .{(try as.nextInstruction()).?});
3130    try std.testing.expectFmt("sqxtn v6.8b, v7.8h", "{f}", .{(try as.nextInstruction()).?});
3131    try std.testing.expectFmt("sqxtn2 v8.16b, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3132    try std.testing.expectFmt("sqxtn v10.4h, v11.4s", "{f}", .{(try as.nextInstruction()).?});
3133    try std.testing.expectFmt("sqxtn2 v12.8h, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3134    try std.testing.expectFmt("sqxtn v14.2s, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3135    try std.testing.expectFmt("sqxtn2 v16.4s, v17.2d", "{f}", .{(try as.nextInstruction()).?});
3136
3137    try std.testing.expectFmt("frintn v0.4h, v1.4h", "{f}", .{(try as.nextInstruction()).?});
3138    try std.testing.expectFmt("frintn v2.8h, v3.8h", "{f}", .{(try as.nextInstruction()).?});
3139    try std.testing.expectFmt("frintn v4.2s, v5.2s", "{f}", .{(try as.nextInstruction()).?});
3140    try std.testing.expectFmt("frintn v6.4s, v7.4s", "{f}", .{(try as.nextInstruction()).?});
3141    try std.testing.expectFmt("frintn v8.2d, v9.2d", "{f}", .{(try as.nextInstruction()).?});
3142    try std.testing.expectFmt("frintn h10, h11", "{f}", .{(try as.nextInstruction()).?});
3143    try std.testing.expectFmt("frintn s12, s13", "{f}", .{(try as.nextInstruction()).?});
3144    try std.testing.expectFmt("frintn d14, d15", "{f}", .{(try as.nextInstruction()).?});
3145
3146    try std.testing.expectFmt("frintm v0.4h, v1.4h", "{f}", .{(try as.nextInstruction()).?});
3147    try std.testing.expectFmt("frintm v2.8h, v3.8h", "{f}", .{(try as.nextInstruction()).?});
3148    try std.testing.expectFmt("frintm v4.2s, v5.2s", "{f}", .{(try as.nextInstruction()).?});
3149    try std.testing.expectFmt("frintm v6.4s, v7.4s", "{f}", .{(try as.nextInstruction()).?});
3150    try std.testing.expectFmt("frintm v8.2d, v9.2d", "{f}", .{(try as.nextInstruction()).?});
3151    try std.testing.expectFmt("frintm h10, h11", "{f}", .{(try as.nextInstruction()).?});
3152    try std.testing.expectFmt("frintm s12, s13", "{f}", .{(try as.nextInstruction()).?});
3153    try std.testing.expectFmt("frintm d14, d15", "{f}", .{(try as.nextInstruction()).?});
3154
3155    try std.testing.expectFmt("fcvtns h0, h1", "{f}", .{(try as.nextInstruction()).?});
3156    try std.testing.expectFmt("fcvtns s2, s3", "{f}", .{(try as.nextInstruction()).?});
3157    try std.testing.expectFmt("fcvtns d4, d5", "{f}", .{(try as.nextInstruction()).?});
3158    try std.testing.expectFmt("fcvtns v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3159    try std.testing.expectFmt("fcvtns v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3160    try std.testing.expectFmt("fcvtns v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3161    try std.testing.expectFmt("fcvtns v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3162    try std.testing.expectFmt("fcvtns v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3163    try std.testing.expectFmt("fcvtns w16, h17", "{f}", .{(try as.nextInstruction()).?});
3164    try std.testing.expectFmt("fcvtns x18, h19", "{f}", .{(try as.nextInstruction()).?});
3165    try std.testing.expectFmt("fcvtns w20, s21", "{f}", .{(try as.nextInstruction()).?});
3166    try std.testing.expectFmt("fcvtns x22, s23", "{f}", .{(try as.nextInstruction()).?});
3167    try std.testing.expectFmt("fcvtns w24, d25", "{f}", .{(try as.nextInstruction()).?});
3168    try std.testing.expectFmt("fcvtns x26, d27", "{f}", .{(try as.nextInstruction()).?});
3169
3170    try std.testing.expectFmt("fcvtms h0, h1", "{f}", .{(try as.nextInstruction()).?});
3171    try std.testing.expectFmt("fcvtms s2, s3", "{f}", .{(try as.nextInstruction()).?});
3172    try std.testing.expectFmt("fcvtms d4, d5", "{f}", .{(try as.nextInstruction()).?});
3173    try std.testing.expectFmt("fcvtms v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3174    try std.testing.expectFmt("fcvtms v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3175    try std.testing.expectFmt("fcvtms v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3176    try std.testing.expectFmt("fcvtms v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3177    try std.testing.expectFmt("fcvtms v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3178    try std.testing.expectFmt("fcvtms w16, h17", "{f}", .{(try as.nextInstruction()).?});
3179    try std.testing.expectFmt("fcvtms x18, h19", "{f}", .{(try as.nextInstruction()).?});
3180    try std.testing.expectFmt("fcvtms w20, s21", "{f}", .{(try as.nextInstruction()).?});
3181    try std.testing.expectFmt("fcvtms x22, s23", "{f}", .{(try as.nextInstruction()).?});
3182    try std.testing.expectFmt("fcvtms w24, d25", "{f}", .{(try as.nextInstruction()).?});
3183    try std.testing.expectFmt("fcvtms x26, d27", "{f}", .{(try as.nextInstruction()).?});
3184
3185    try std.testing.expectFmt("fcvtas h0, h1", "{f}", .{(try as.nextInstruction()).?});
3186    try std.testing.expectFmt("fcvtas s2, s3", "{f}", .{(try as.nextInstruction()).?});
3187    try std.testing.expectFmt("fcvtas d4, d5", "{f}", .{(try as.nextInstruction()).?});
3188    try std.testing.expectFmt("fcvtas v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3189    try std.testing.expectFmt("fcvtas v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3190    try std.testing.expectFmt("fcvtas v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3191    try std.testing.expectFmt("fcvtas v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3192    try std.testing.expectFmt("fcvtas v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3193    try std.testing.expectFmt("fcvtas w16, h17", "{f}", .{(try as.nextInstruction()).?});
3194    try std.testing.expectFmt("fcvtas x18, h19", "{f}", .{(try as.nextInstruction()).?});
3195    try std.testing.expectFmt("fcvtas w20, s21", "{f}", .{(try as.nextInstruction()).?});
3196    try std.testing.expectFmt("fcvtas x22, s23", "{f}", .{(try as.nextInstruction()).?});
3197    try std.testing.expectFmt("fcvtas w24, d25", "{f}", .{(try as.nextInstruction()).?});
3198    try std.testing.expectFmt("fcvtas x26, d27", "{f}", .{(try as.nextInstruction()).?});
3199
3200    try std.testing.expectFmt("scvtf h0, h1", "{f}", .{(try as.nextInstruction()).?});
3201    try std.testing.expectFmt("scvtf s2, s3", "{f}", .{(try as.nextInstruction()).?});
3202    try std.testing.expectFmt("scvtf d4, d5", "{f}", .{(try as.nextInstruction()).?});
3203    try std.testing.expectFmt("scvtf v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3204    try std.testing.expectFmt("scvtf v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3205    try std.testing.expectFmt("scvtf v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3206    try std.testing.expectFmt("scvtf v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3207    try std.testing.expectFmt("scvtf v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3208    try std.testing.expectFmt("scvtf h16, w17", "{f}", .{(try as.nextInstruction()).?});
3209    try std.testing.expectFmt("scvtf h18, x19", "{f}", .{(try as.nextInstruction()).?});
3210    try std.testing.expectFmt("scvtf s20, w21", "{f}", .{(try as.nextInstruction()).?});
3211    try std.testing.expectFmt("scvtf s22, x23", "{f}", .{(try as.nextInstruction()).?});
3212    try std.testing.expectFmt("scvtf d24, w25", "{f}", .{(try as.nextInstruction()).?});
3213    try std.testing.expectFmt("scvtf d26, x27", "{f}", .{(try as.nextInstruction()).?});
3214
3215    try std.testing.expectFmt("fcmgt h0, h1, #0.0", "{f}", .{(try as.nextInstruction()).?});
3216    try std.testing.expectFmt("fcmgt s2, s3, #0.0", "{f}", .{(try as.nextInstruction()).?});
3217    try std.testing.expectFmt("fcmgt d4, d5, #0.0", "{f}", .{(try as.nextInstruction()).?});
3218    try std.testing.expectFmt("fcmgt v6.4h, v7.4h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3219    try std.testing.expectFmt("fcmgt v8.8h, v9.8h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3220    try std.testing.expectFmt("fcmgt v10.2s, v11.2s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3221    try std.testing.expectFmt("fcmgt v12.4s, v13.4s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3222    try std.testing.expectFmt("fcmgt v14.2d, v15.2d, #0.0", "{f}", .{(try as.nextInstruction()).?});
3223
3224    try std.testing.expectFmt("fcmeq h0, h1, #0.0", "{f}", .{(try as.nextInstruction()).?});
3225    try std.testing.expectFmt("fcmeq s2, s3, #0.0", "{f}", .{(try as.nextInstruction()).?});
3226    try std.testing.expectFmt("fcmeq d4, d5, #0.0", "{f}", .{(try as.nextInstruction()).?});
3227    try std.testing.expectFmt("fcmeq v6.4h, v7.4h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3228    try std.testing.expectFmt("fcmeq v8.8h, v9.8h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3229    try std.testing.expectFmt("fcmeq v10.2s, v11.2s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3230    try std.testing.expectFmt("fcmeq v12.4s, v13.4s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3231    try std.testing.expectFmt("fcmeq v14.2d, v15.2d, #0.0", "{f}", .{(try as.nextInstruction()).?});
3232
3233    try std.testing.expectFmt("fcmlt h0, h1, #0.0", "{f}", .{(try as.nextInstruction()).?});
3234    try std.testing.expectFmt("fcmlt s2, s3, #0.0", "{f}", .{(try as.nextInstruction()).?});
3235    try std.testing.expectFmt("fcmlt d4, d5, #0.0", "{f}", .{(try as.nextInstruction()).?});
3236    try std.testing.expectFmt("fcmlt v6.4h, v7.4h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3237    try std.testing.expectFmt("fcmlt v8.8h, v9.8h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3238    try std.testing.expectFmt("fcmlt v10.2s, v11.2s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3239    try std.testing.expectFmt("fcmlt v12.4s, v13.4s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3240    try std.testing.expectFmt("fcmlt v14.2d, v15.2d, #0.0", "{f}", .{(try as.nextInstruction()).?});
3241
3242    try std.testing.expectFmt("frintp v0.4h, v1.4h", "{f}", .{(try as.nextInstruction()).?});
3243    try std.testing.expectFmt("frintp v2.8h, v3.8h", "{f}", .{(try as.nextInstruction()).?});
3244    try std.testing.expectFmt("frintp v4.2s, v5.2s", "{f}", .{(try as.nextInstruction()).?});
3245    try std.testing.expectFmt("frintp v6.4s, v7.4s", "{f}", .{(try as.nextInstruction()).?});
3246    try std.testing.expectFmt("frintp v8.2d, v9.2d", "{f}", .{(try as.nextInstruction()).?});
3247    try std.testing.expectFmt("frintp h10, h11", "{f}", .{(try as.nextInstruction()).?});
3248    try std.testing.expectFmt("frintp s12, s13", "{f}", .{(try as.nextInstruction()).?});
3249    try std.testing.expectFmt("frintp d14, d15", "{f}", .{(try as.nextInstruction()).?});
3250
3251    try std.testing.expectFmt("frintz v0.4h, v1.4h", "{f}", .{(try as.nextInstruction()).?});
3252    try std.testing.expectFmt("frintz v2.8h, v3.8h", "{f}", .{(try as.nextInstruction()).?});
3253    try std.testing.expectFmt("frintz v4.2s, v5.2s", "{f}", .{(try as.nextInstruction()).?});
3254    try std.testing.expectFmt("frintz v6.4s, v7.4s", "{f}", .{(try as.nextInstruction()).?});
3255    try std.testing.expectFmt("frintz v8.2d, v9.2d", "{f}", .{(try as.nextInstruction()).?});
3256    try std.testing.expectFmt("frintz h10, h11", "{f}", .{(try as.nextInstruction()).?});
3257    try std.testing.expectFmt("frintz s12, s13", "{f}", .{(try as.nextInstruction()).?});
3258    try std.testing.expectFmt("frintz d14, d15", "{f}", .{(try as.nextInstruction()).?});
3259
3260    try std.testing.expectFmt("fcvtps h0, h1", "{f}", .{(try as.nextInstruction()).?});
3261    try std.testing.expectFmt("fcvtps s2, s3", "{f}", .{(try as.nextInstruction()).?});
3262    try std.testing.expectFmt("fcvtps d4, d5", "{f}", .{(try as.nextInstruction()).?});
3263    try std.testing.expectFmt("fcvtps v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3264    try std.testing.expectFmt("fcvtps v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3265    try std.testing.expectFmt("fcvtps v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3266    try std.testing.expectFmt("fcvtps v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3267    try std.testing.expectFmt("fcvtps v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3268    try std.testing.expectFmt("fcvtps w16, h17", "{f}", .{(try as.nextInstruction()).?});
3269    try std.testing.expectFmt("fcvtps x18, h19", "{f}", .{(try as.nextInstruction()).?});
3270    try std.testing.expectFmt("fcvtps w20, s21", "{f}", .{(try as.nextInstruction()).?});
3271    try std.testing.expectFmt("fcvtps x22, s23", "{f}", .{(try as.nextInstruction()).?});
3272    try std.testing.expectFmt("fcvtps w24, d25", "{f}", .{(try as.nextInstruction()).?});
3273    try std.testing.expectFmt("fcvtps x26, d27", "{f}", .{(try as.nextInstruction()).?});
3274
3275    try std.testing.expectFmt("fcvtzs h0, h1", "{f}", .{(try as.nextInstruction()).?});
3276    try std.testing.expectFmt("fcvtzs s2, s3", "{f}", .{(try as.nextInstruction()).?});
3277    try std.testing.expectFmt("fcvtzs d4, d5", "{f}", .{(try as.nextInstruction()).?});
3278    try std.testing.expectFmt("fcvtzs v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3279    try std.testing.expectFmt("fcvtzs v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3280    try std.testing.expectFmt("fcvtzs v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3281    try std.testing.expectFmt("fcvtzs v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3282    try std.testing.expectFmt("fcvtzs v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3283    try std.testing.expectFmt("fcvtzs w16, h17", "{f}", .{(try as.nextInstruction()).?});
3284    try std.testing.expectFmt("fcvtzs x18, h19", "{f}", .{(try as.nextInstruction()).?});
3285    try std.testing.expectFmt("fcvtzs w20, s21", "{f}", .{(try as.nextInstruction()).?});
3286    try std.testing.expectFmt("fcvtzs x22, s23", "{f}", .{(try as.nextInstruction()).?});
3287    try std.testing.expectFmt("fcvtzs w24, d25", "{f}", .{(try as.nextInstruction()).?});
3288    try std.testing.expectFmt("fcvtzs x26, d27", "{f}", .{(try as.nextInstruction()).?});
3289
3290    try std.testing.expectFmt("cmge d0, d1, #0", "{f}", .{(try as.nextInstruction()).?});
3291    try std.testing.expectFmt("cmge v2.8b, v3.8b, #0", "{f}", .{(try as.nextInstruction()).?});
3292    try std.testing.expectFmt("cmge v4.16b, v5.16b, #0", "{f}", .{(try as.nextInstruction()).?});
3293    try std.testing.expectFmt("cmge v6.4h, v7.4h, #0", "{f}", .{(try as.nextInstruction()).?});
3294    try std.testing.expectFmt("cmge v8.8h, v9.8h, #0", "{f}", .{(try as.nextInstruction()).?});
3295    try std.testing.expectFmt("cmge v10.2s, v11.2s, #0", "{f}", .{(try as.nextInstruction()).?});
3296    try std.testing.expectFmt("cmge v12.4s, v13.4s, #0", "{f}", .{(try as.nextInstruction()).?});
3297    try std.testing.expectFmt("cmge v14.2d, v15.2d, #0", "{f}", .{(try as.nextInstruction()).?});
3298
3299    try std.testing.expectFmt("cmle d0, d1, #0", "{f}", .{(try as.nextInstruction()).?});
3300    try std.testing.expectFmt("cmle v2.8b, v3.8b, #0", "{f}", .{(try as.nextInstruction()).?});
3301    try std.testing.expectFmt("cmle v4.16b, v5.16b, #0", "{f}", .{(try as.nextInstruction()).?});
3302    try std.testing.expectFmt("cmle v6.4h, v7.4h, #0", "{f}", .{(try as.nextInstruction()).?});
3303    try std.testing.expectFmt("cmle v8.8h, v9.8h, #0", "{f}", .{(try as.nextInstruction()).?});
3304    try std.testing.expectFmt("cmle v10.2s, v11.2s, #0", "{f}", .{(try as.nextInstruction()).?});
3305    try std.testing.expectFmt("cmle v12.4s, v13.4s, #0", "{f}", .{(try as.nextInstruction()).?});
3306    try std.testing.expectFmt("cmle v14.2d, v15.2d, #0", "{f}", .{(try as.nextInstruction()).?});
3307
3308    try std.testing.expectFmt("neg d0, d1", "{f}", .{(try as.nextInstruction()).?});
3309    try std.testing.expectFmt("neg v2.8b, v3.8b", "{f}", .{(try as.nextInstruction()).?});
3310    try std.testing.expectFmt("neg v4.16b, v5.16b", "{f}", .{(try as.nextInstruction()).?});
3311    try std.testing.expectFmt("neg v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3312    try std.testing.expectFmt("neg v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3313    try std.testing.expectFmt("neg v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3314    try std.testing.expectFmt("neg v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3315    try std.testing.expectFmt("neg v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3316
3317    try std.testing.expectFmt("fcvtnu h0, h1", "{f}", .{(try as.nextInstruction()).?});
3318    try std.testing.expectFmt("fcvtnu s2, s3", "{f}", .{(try as.nextInstruction()).?});
3319    try std.testing.expectFmt("fcvtnu d4, d5", "{f}", .{(try as.nextInstruction()).?});
3320    try std.testing.expectFmt("fcvtnu v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3321    try std.testing.expectFmt("fcvtnu v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3322    try std.testing.expectFmt("fcvtnu v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3323    try std.testing.expectFmt("fcvtnu v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3324    try std.testing.expectFmt("fcvtnu v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3325    try std.testing.expectFmt("fcvtnu w16, h17", "{f}", .{(try as.nextInstruction()).?});
3326    try std.testing.expectFmt("fcvtnu x18, h19", "{f}", .{(try as.nextInstruction()).?});
3327    try std.testing.expectFmt("fcvtnu w20, s21", "{f}", .{(try as.nextInstruction()).?});
3328    try std.testing.expectFmt("fcvtnu x22, s23", "{f}", .{(try as.nextInstruction()).?});
3329    try std.testing.expectFmt("fcvtnu w24, d25", "{f}", .{(try as.nextInstruction()).?});
3330    try std.testing.expectFmt("fcvtnu x26, d27", "{f}", .{(try as.nextInstruction()).?});
3331
3332    try std.testing.expectFmt("fcvtmu h0, h1", "{f}", .{(try as.nextInstruction()).?});
3333    try std.testing.expectFmt("fcvtmu s2, s3", "{f}", .{(try as.nextInstruction()).?});
3334    try std.testing.expectFmt("fcvtmu d4, d5", "{f}", .{(try as.nextInstruction()).?});
3335    try std.testing.expectFmt("fcvtmu v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3336    try std.testing.expectFmt("fcvtmu v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3337    try std.testing.expectFmt("fcvtmu v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3338    try std.testing.expectFmt("fcvtmu v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3339    try std.testing.expectFmt("fcvtmu v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3340    try std.testing.expectFmt("fcvtmu w16, h17", "{f}", .{(try as.nextInstruction()).?});
3341    try std.testing.expectFmt("fcvtmu x18, h19", "{f}", .{(try as.nextInstruction()).?});
3342    try std.testing.expectFmt("fcvtmu w20, s21", "{f}", .{(try as.nextInstruction()).?});
3343    try std.testing.expectFmt("fcvtmu x22, s23", "{f}", .{(try as.nextInstruction()).?});
3344    try std.testing.expectFmt("fcvtmu w24, d25", "{f}", .{(try as.nextInstruction()).?});
3345    try std.testing.expectFmt("fcvtmu x26, d27", "{f}", .{(try as.nextInstruction()).?});
3346
3347    try std.testing.expectFmt("fcvtau h0, h1", "{f}", .{(try as.nextInstruction()).?});
3348    try std.testing.expectFmt("fcvtau s2, s3", "{f}", .{(try as.nextInstruction()).?});
3349    try std.testing.expectFmt("fcvtau d4, d5", "{f}", .{(try as.nextInstruction()).?});
3350    try std.testing.expectFmt("fcvtau v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3351    try std.testing.expectFmt("fcvtau v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3352    try std.testing.expectFmt("fcvtau v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3353    try std.testing.expectFmt("fcvtau v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3354    try std.testing.expectFmt("fcvtau v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3355    try std.testing.expectFmt("fcvtau w16, h17", "{f}", .{(try as.nextInstruction()).?});
3356    try std.testing.expectFmt("fcvtau x18, h19", "{f}", .{(try as.nextInstruction()).?});
3357    try std.testing.expectFmt("fcvtau w20, s21", "{f}", .{(try as.nextInstruction()).?});
3358    try std.testing.expectFmt("fcvtau x22, s23", "{f}", .{(try as.nextInstruction()).?});
3359    try std.testing.expectFmt("fcvtau w24, d25", "{f}", .{(try as.nextInstruction()).?});
3360    try std.testing.expectFmt("fcvtau x26, d27", "{f}", .{(try as.nextInstruction()).?});
3361
3362    try std.testing.expectFmt("ucvtf h0, h1", "{f}", .{(try as.nextInstruction()).?});
3363    try std.testing.expectFmt("ucvtf s2, s3", "{f}", .{(try as.nextInstruction()).?});
3364    try std.testing.expectFmt("ucvtf d4, d5", "{f}", .{(try as.nextInstruction()).?});
3365    try std.testing.expectFmt("ucvtf v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3366    try std.testing.expectFmt("ucvtf v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3367    try std.testing.expectFmt("ucvtf v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3368    try std.testing.expectFmt("ucvtf v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3369    try std.testing.expectFmt("ucvtf v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3370    try std.testing.expectFmt("ucvtf h16, w17", "{f}", .{(try as.nextInstruction()).?});
3371    try std.testing.expectFmt("ucvtf h18, x19", "{f}", .{(try as.nextInstruction()).?});
3372    try std.testing.expectFmt("ucvtf s20, w21", "{f}", .{(try as.nextInstruction()).?});
3373    try std.testing.expectFmt("ucvtf s22, x23", "{f}", .{(try as.nextInstruction()).?});
3374    try std.testing.expectFmt("ucvtf d24, w25", "{f}", .{(try as.nextInstruction()).?});
3375    try std.testing.expectFmt("ucvtf d26, x27", "{f}", .{(try as.nextInstruction()).?});
3376
3377    try std.testing.expectFmt("not v0.8b, v1.8b", "{f}", .{(try as.nextInstruction()).?});
3378    try std.testing.expectFmt("not v2.16b, v3.16b", "{f}", .{(try as.nextInstruction()).?});
3379
3380    try std.testing.expectFmt("fcmge h0, h1, #0.0", "{f}", .{(try as.nextInstruction()).?});
3381    try std.testing.expectFmt("fcmge s2, s3, #0.0", "{f}", .{(try as.nextInstruction()).?});
3382    try std.testing.expectFmt("fcmge d4, d5, #0.0", "{f}", .{(try as.nextInstruction()).?});
3383    try std.testing.expectFmt("fcmge v6.4h, v7.4h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3384    try std.testing.expectFmt("fcmge v8.8h, v9.8h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3385    try std.testing.expectFmt("fcmge v10.2s, v11.2s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3386    try std.testing.expectFmt("fcmge v12.4s, v13.4s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3387    try std.testing.expectFmt("fcmge v14.2d, v15.2d, #0.0", "{f}", .{(try as.nextInstruction()).?});
3388
3389    try std.testing.expectFmt("fcmle h0, h1, #0.0", "{f}", .{(try as.nextInstruction()).?});
3390    try std.testing.expectFmt("fcmle s2, s3, #0.0", "{f}", .{(try as.nextInstruction()).?});
3391    try std.testing.expectFmt("fcmle d4, d5, #0.0", "{f}", .{(try as.nextInstruction()).?});
3392    try std.testing.expectFmt("fcmle v6.4h, v7.4h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3393    try std.testing.expectFmt("fcmle v8.8h, v9.8h, #0.0", "{f}", .{(try as.nextInstruction()).?});
3394    try std.testing.expectFmt("fcmle v10.2s, v11.2s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3395    try std.testing.expectFmt("fcmle v12.4s, v13.4s, #0.0", "{f}", .{(try as.nextInstruction()).?});
3396    try std.testing.expectFmt("fcmle v14.2d, v15.2d, #0.0", "{f}", .{(try as.nextInstruction()).?});
3397
3398    try std.testing.expectFmt("frinti v0.4h, v1.4h", "{f}", .{(try as.nextInstruction()).?});
3399    try std.testing.expectFmt("frinti v2.8h, v3.8h", "{f}", .{(try as.nextInstruction()).?});
3400    try std.testing.expectFmt("frinti v4.2s, v5.2s", "{f}", .{(try as.nextInstruction()).?});
3401    try std.testing.expectFmt("frinti v6.4s, v7.4s", "{f}", .{(try as.nextInstruction()).?});
3402    try std.testing.expectFmt("frinti v8.2d, v9.2d", "{f}", .{(try as.nextInstruction()).?});
3403    try std.testing.expectFmt("frinti h10, h11", "{f}", .{(try as.nextInstruction()).?});
3404    try std.testing.expectFmt("frinti s12, s13", "{f}", .{(try as.nextInstruction()).?});
3405    try std.testing.expectFmt("frinti d14, d15", "{f}", .{(try as.nextInstruction()).?});
3406
3407    try std.testing.expectFmt("fcvtpu h0, h1", "{f}", .{(try as.nextInstruction()).?});
3408    try std.testing.expectFmt("fcvtpu s2, s3", "{f}", .{(try as.nextInstruction()).?});
3409    try std.testing.expectFmt("fcvtpu d4, d5", "{f}", .{(try as.nextInstruction()).?});
3410    try std.testing.expectFmt("fcvtpu v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3411    try std.testing.expectFmt("fcvtpu v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3412    try std.testing.expectFmt("fcvtpu v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3413    try std.testing.expectFmt("fcvtpu v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3414    try std.testing.expectFmt("fcvtpu v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3415    try std.testing.expectFmt("fcvtpu w16, h17", "{f}", .{(try as.nextInstruction()).?});
3416    try std.testing.expectFmt("fcvtpu x18, h19", "{f}", .{(try as.nextInstruction()).?});
3417    try std.testing.expectFmt("fcvtpu w20, s21", "{f}", .{(try as.nextInstruction()).?});
3418    try std.testing.expectFmt("fcvtpu x22, s23", "{f}", .{(try as.nextInstruction()).?});
3419    try std.testing.expectFmt("fcvtpu w24, d25", "{f}", .{(try as.nextInstruction()).?});
3420    try std.testing.expectFmt("fcvtpu x26, d27", "{f}", .{(try as.nextInstruction()).?});
3421
3422    try std.testing.expectFmt("fcvtzu h0, h1", "{f}", .{(try as.nextInstruction()).?});
3423    try std.testing.expectFmt("fcvtzu s2, s3", "{f}", .{(try as.nextInstruction()).?});
3424    try std.testing.expectFmt("fcvtzu d4, d5", "{f}", .{(try as.nextInstruction()).?});
3425    try std.testing.expectFmt("fcvtzu v6.4h, v7.4h", "{f}", .{(try as.nextInstruction()).?});
3426    try std.testing.expectFmt("fcvtzu v8.8h, v9.8h", "{f}", .{(try as.nextInstruction()).?});
3427    try std.testing.expectFmt("fcvtzu v10.2s, v11.2s", "{f}", .{(try as.nextInstruction()).?});
3428    try std.testing.expectFmt("fcvtzu v12.4s, v13.4s", "{f}", .{(try as.nextInstruction()).?});
3429    try std.testing.expectFmt("fcvtzu v14.2d, v15.2d", "{f}", .{(try as.nextInstruction()).?});
3430    try std.testing.expectFmt("fcvtzu w16, h17", "{f}", .{(try as.nextInstruction()).?});
3431    try std.testing.expectFmt("fcvtzu x18, h19", "{f}", .{(try as.nextInstruction()).?});
3432    try std.testing.expectFmt("fcvtzu w20, s21", "{f}", .{(try as.nextInstruction()).?});
3433    try std.testing.expectFmt("fcvtzu x22, s23", "{f}", .{(try as.nextInstruction()).?});
3434    try std.testing.expectFmt("fcvtzu w24, d25", "{f}", .{(try as.nextInstruction()).?});
3435    try std.testing.expectFmt("fcvtzu x26, d27", "{f}", .{(try as.nextInstruction()).?});
3436
3437    try std.testing.expect(null == try as.nextInstruction());
3438}
3439
3440const aarch64 = @import("../aarch64.zig");
3441const Assemble = @This();
3442const assert = std.debug.assert;
3443const Instruction = aarch64.encoding.Instruction;
3444const std = @import("std");
3445const log = std.log.scoped(.@"asm");