Class: AArch64::Assembler

Inherits:
Object
  • Object
show all
Includes:
Instructions, Registers
Defined in:
lib/aarch64.rb

Defined Under Namespace

Classes: Immediate, Label

Constant Summary

Constants included from Registers

Registers::SP, Registers::WSP, Registers::WZR, Registers::XZR

Instance Method Summary collapse

Constructor Details

#initializeAssembler

Returns a new instance of Assembler.



170
171
172
# File 'lib/aarch64.rb', line 170

def initialize
  @insns = []
end

Instance Method Details

#adc(d, n, m) ⇒ Object



197
198
199
# File 'lib/aarch64.rb', line 197

def adc d, n, m
  a ADC.new(d, n, m, d.sf)
end

#adcs(d, n, m) ⇒ Object



201
202
203
# File 'lib/aarch64.rb', line 201

def adcs d, n, m
  a ADCS.new(d, n, m, d.sf)
end

#add(d, n, m, extend: nil, amount: 0, lsl: 0, shift: :lsl) ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/aarch64.rb', line 205

def add d, n, m, extend: nil, amount: 0, lsl: 0, shift: :lsl
  if extend
    extend = case extend
             when :uxtb then 0b000
             when :uxth then 0b001
             when :uxtw then 0b010
             when :lsl  then 0b010
             when :uxtx then 0b011
             when :sxtb then 0b100
             when :sxth then 0b101
             when :sxtw then 0b110
             when :sxtx then 0b111
             else
               raise "Unknown extend #{extend}"
             end

    a ADD_addsub_ext.new(d, n, m, extend, amount, d.sf)
  else
    if m.integer?
      # add immediate
      a ADD_addsub_imm.new(d, n, m, (lsl || 0) / 12, d.sf)
    else
      shift = [:lsl, :lsr, :asr].index(shift) || raise(NotImplementedError)
      a ADD_addsub_shift.new(d, n, m, shift, amount, d.sf)
    end
  end
end

#addg(xd, xn, imm6, imm4) ⇒ Object



233
234
235
# File 'lib/aarch64.rb', line 233

def addg xd, xn, imm6, imm4
  a ADDG.new(xd, xn, imm6, imm4)
end

#adds(d, n, m, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl) ⇒ Object



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/aarch64.rb', line 237

def adds d, n, m, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl
  if n.sp? && !m.integer?
    if n.x?
      extend ||= :uxtx
    else
      extend ||= :uxtw
    end
  end

  if option
    if option.extend?
      extend = option.name
      amount = option.amount
    else
      if m.integer?
        lsl = option.amount
      else
        shift = option.name
        amount = option.amount
      end
    end
  end

  if extend
    extend = case extend
             when :uxtb then 0b000
             when :uxth then 0b001
             when :uxtw then 0b010
             when :lsl then 0b010
             when :uxtx then 0b011
             when :sxtb then 0b100
             when :sxth then 0b101
             when :sxtw then 0b110
             when :sxtx then 0b111
             else
               raise "Unknown extend #{extend}"
             end
    a ADDS_addsub_ext.new(d, n, m, extend, amount, d.sf)
  else
    if m.integer?
      a ADDS_addsub_imm.new(d, n, m, lsl / 12, d.sf)
    else
      shift = [:lsl, :lsr, :asr].index(shift) || raise(NotImplementedError)
      a ADDS_addsub_shift.new(d, n, m, shift, amount, d.sf)
    end
  end
end

#adr(xd, label) ⇒ Object



285
286
287
288
# File 'lib/aarch64.rb', line 285

def adr xd, label
  label = Immediate.new(label) if label.integer?
  a ADR.new(xd, label)
end

#adrp(xd, label) ⇒ Object



290
291
292
293
# File 'lib/aarch64.rb', line 290

def adrp xd, label
  label = Immediate.new(label) if label.integer?
  a ADRP.new(xd, label)
end

#and(d, n, m, shift: :lsl, amount: 0) ⇒ Object



295
296
297
298
299
300
301
302
303
# File 'lib/aarch64.rb', line 295

def and d, n, m, shift: :lsl, amount: 0
  if m.integer?
    enc = Utils.encode_mask(m, d.size) || raise("Can't encode mask #{m}")
    a AND_log_imm.new(d, n, enc.immr, enc.imms, enc.n, d.sf)
  else
    shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)
    a AND_log_shift.new(d, n, m, shift, amount, d.sf)
  end
end

#ands(d, n, m, shift: :lsl, amount: 0) ⇒ Object



305
306
307
308
309
310
311
312
313
# File 'lib/aarch64.rb', line 305

def ands d, n, m, shift: :lsl, amount: 0
  if m.integer?
    enc = Utils.encode_mask(m, d.size) || raise("Can't encode mask #{m}")
    a ANDS_log_imm.new(d, n, enc.immr, enc.imms, enc.n, d.sf)
  else
    shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)
    a ANDS_log_shift.new(d, n, m, shift, amount, d.sf)
  end
end

#asr(d, n, m) ⇒ Object



315
316
317
318
319
320
321
# File 'lib/aarch64.rb', line 315

def asr d, n, m
  if m.integer?
    sbfm d, n, m, d.size - 1
  else
    asrv d, n, m
  end
end

#asrv(d, n, m) ⇒ Object



323
324
325
# File 'lib/aarch64.rb', line 323

def asrv d, n, m
  a ASRV.new(d, n, m, d.sf)
end

#at(at_op, t) ⇒ Object



327
328
329
330
# File 'lib/aarch64.rb', line 327

def at at_op, t
  op = Utils.at_op(at_op)
  sys op[:op1], Names::C7, op[:crm], op[:op2], t
end

#autda(d, n) ⇒ Object



332
333
334
335
336
337
338
# File 'lib/aarch64.rb', line 332

def autda d, n
  if n.integer?
    a AUTDA.new(1, d, n)
  else
    a AUTDA.new(0, d, n)
  end
end

#autdb(d, n) ⇒ Object



344
345
346
347
348
349
350
# File 'lib/aarch64.rb', line 344

def autdb d, n
  if n.integer?
    a AUTDB.new(1, d, n)
  else
    a AUTDB.new(0, d, n)
  end
end

#autdza(d) ⇒ Object



340
341
342
# File 'lib/aarch64.rb', line 340

def autdza d
  a AUTDA.new(1, d, 0b11111)
end

#autdzb(d) ⇒ Object



352
353
354
# File 'lib/aarch64.rb', line 352

def autdzb d
  a AUTDB.new(1, d, 0b11111)
end

#autia(d, n) ⇒ Object



356
357
358
359
360
361
362
# File 'lib/aarch64.rb', line 356

def autia d, n
  if n.integer?
    a AUTIA.new(1, d, n)
  else
    a AUTIA.new(0, d, n)
  end
end

#autia1716Object



368
369
370
# File 'lib/aarch64.rb', line 368

def autia1716
  a HINT.new(0b0001, 0b100)
end

#autiaspObject



372
373
374
# File 'lib/aarch64.rb', line 372

def autiasp
  a HINT.new(0b0011, 0b101)
end

#autiazObject



376
377
378
# File 'lib/aarch64.rb', line 376

def autiaz
  a HINT.new(0b0011, 0b100)
end

#autib(d, n) ⇒ Object



380
381
382
383
384
385
386
# File 'lib/aarch64.rb', line 380

def autib d, n
  if n.integer?
    a AUTIB.new(1, d, n)
  else
    a AUTIB.new(0, d, n)
  end
end

#autib1716Object



392
393
394
# File 'lib/aarch64.rb', line 392

def autib1716
  a HINT.new(0b0001, 0b110)
end

#autibspObject



396
397
398
# File 'lib/aarch64.rb', line 396

def autibsp
  a HINT.new(0b0011, 0b111)
end

#autibzObject



400
401
402
# File 'lib/aarch64.rb', line 400

def autibz
  a HINT.new(0b0011, 0b110)
end

#autiza(d) ⇒ Object



364
365
366
# File 'lib/aarch64.rb', line 364

def autiza d
  a AUTIA.new(1, d, 0b11111)
end

#autizb(d) ⇒ Object



388
389
390
# File 'lib/aarch64.rb', line 388

def autizb d
  a AUTIB.new(1, d, 0b11111)
end

#axflagObject



404
405
406
# File 'lib/aarch64.rb', line 404

def axflag
  a AXFLAG.new
end

#b(label, cond: nil) ⇒ Object



408
409
410
411
412
413
414
415
416
417
418
# File 'lib/aarch64.rb', line 408

def b label, cond: nil
  if label.integer?
    label = wrap_offset_with_label label
  end

  if cond
    a B_cond.new(Utils.cond2bin(cond), label)
  else
    a B_uncond.new(label)
  end
end

#bc(label, cond:) ⇒ Object



420
421
422
423
424
425
# File 'lib/aarch64.rb', line 420

def bc label, cond:
  if label.integer?
    label = wrap_offset_with_label label
  end
  a BC_cond.new(Utils.cond2bin(cond), label)
end

#bfc(rd, lsb, width) ⇒ Object



427
428
429
# File 'lib/aarch64.rb', line 427

def bfc rd, lsb, width
  bfm(rd, rd.zr, -lsb % rd.size, width - 1)
end

#bfi(rd, rn, lsb, width) ⇒ Object



431
432
433
# File 'lib/aarch64.rb', line 431

def bfi rd, rn, lsb, width
  bfm(rd, rn, -lsb % rd.size, width - 1)
end

#bfm(d, n, immr, imms) ⇒ Object



435
436
437
# File 'lib/aarch64.rb', line 435

def bfm d, n, immr, imms
  a BFM.new(d, n, immr, imms, d.sf)
end

#bfxil(d, n, lsb, width) ⇒ Object



439
440
441
# File 'lib/aarch64.rb', line 439

def bfxil d, n, lsb, width
  bfm d, n, lsb, lsb + width - 1
end

#bic(d, n, m, option = nil, shift: :lsl, amount: 0) ⇒ Object



443
444
445
446
447
448
449
450
451
# File 'lib/aarch64.rb', line 443

def bic d, n, m, option = nil, shift: :lsl, amount: 0
  if option
    shift = option.name
    amount = option.amount
  end

  shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)
  a BIC_log_shift.new(d, n, m, shift, amount, d.sf)
end

#bics(d, n, m, option = nil, shift: :lsl, amount: 0) ⇒ Object



453
454
455
456
457
458
459
460
461
# File 'lib/aarch64.rb', line 453

def bics d, n, m, option = nil, shift: :lsl, amount: 0
  if option
    shift = option.name
    amount = option.amount
  end

  shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)
  a BICS.new(d, n, m, shift, amount, d.sf)
end

#bl(label) ⇒ Object



463
464
465
466
467
468
469
# File 'lib/aarch64.rb', line 463

def bl label
  if label.integer?
    label = wrap_offset_with_label label
  end

  a BL.new(label)
end

#blr(n) ⇒ Object



471
472
473
# File 'lib/aarch64.rb', line 471

def blr n
  a BLR.new(n)
end

#blraa(rn, rm) ⇒ Object



479
480
481
# File 'lib/aarch64.rb', line 479

def blraa rn, rm
  a BLRA.new(rn, rm, 1, 0)
end

#blraaz(rn) ⇒ Object



475
476
477
# File 'lib/aarch64.rb', line 475

def blraaz rn
  a BLRA.new(rn, 0b11111, 0, 0)
end

#blrab(rn, rm) ⇒ Object



487
488
489
# File 'lib/aarch64.rb', line 487

def blrab rn, rm
  a BLRA.new(rn, rm, 1, 1)
end

#blrabz(rn) ⇒ Object



483
484
485
# File 'lib/aarch64.rb', line 483

def blrabz rn
  a BLRA.new(rn, 0b11111, 0, 1)
end

#br(rn) ⇒ Object



491
492
493
# File 'lib/aarch64.rb', line 491

def br rn
  a BR.new(rn)
end

#braa(rn, rm) ⇒ Object



499
500
501
# File 'lib/aarch64.rb', line 499

def braa rn, rm
  a BRA.new(rn, rm, 1, 0)
end

#braaz(rn) ⇒ Object



495
496
497
# File 'lib/aarch64.rb', line 495

def braaz rn
  a BRA.new(rn, 0b11111, 0, 0)
end

#brab(rn, rm) ⇒ Object



507
508
509
# File 'lib/aarch64.rb', line 507

def brab rn, rm
  a BRA.new(rn, rm, 1, 1)
end

#brabz(rn) ⇒ Object



503
504
505
# File 'lib/aarch64.rb', line 503

def brabz rn
  a BRA.new(rn, 0b11111, 0, 1)
end

#brk(imm) ⇒ Object



511
512
513
# File 'lib/aarch64.rb', line 511

def brk imm
  a BRK.new(imm)
end

#bti(target) ⇒ Object



515
516
517
518
# File 'lib/aarch64.rb', line 515

def bti target
  target = [:c, :j, :jc].index(target) || raise(NotImplementedError)
  a BTI.new(target)
end

#cas(s, t, n_list) ⇒ Object



520
521
522
# File 'lib/aarch64.rb', line 520

def cas s, t, n_list
  a CAS.new(s, t, n_list[0], 0, 0, s.sf)
end

#casa(s, t, n_list) ⇒ Object



524
525
526
# File 'lib/aarch64.rb', line 524

def casa s, t, n_list
  a CAS.new(s, t, n_list[0], 1, 0, s.sf)
end

#casah(rs, rt, rn_list) ⇒ Object



548
549
550
# File 'lib/aarch64.rb', line 548

def casah rs, rt, rn_list
  a CASH.new(rs, rt, rn_list[0], 1, 0)
end

#casal(s, t, n_list) ⇒ Object



532
533
534
# File 'lib/aarch64.rb', line 532

def casal s, t, n_list
  a CAS.new(s, t, n_list[0], 1, 1, s.sf)
end

#casalb(rs, rt, rn_list) ⇒ Object



540
541
542
# File 'lib/aarch64.rb', line 540

def casalb rs, rt, rn_list
  a CASB.new(rs, rt, rn_list[0], 1, 1)
end

#casalh(rs, rt, rn_list) ⇒ Object



552
553
554
# File 'lib/aarch64.rb', line 552

def casalh rs, rt, rn_list
  a CASH.new(rs, rt, rn_list[0], 1, 1)
end

#casb(rs, rt, rn_list) ⇒ Object



536
537
538
# File 'lib/aarch64.rb', line 536

def casb rs, rt, rn_list
  a CASB.new(rs, rt, rn_list[0], 0, 0)
end

#cash(rs, rt, rn_list) ⇒ Object



556
557
558
# File 'lib/aarch64.rb', line 556

def cash rs, rt, rn_list
  a CASH.new(rs, rt, rn_list[0], 0, 0)
end

#casl(s, t, n_list) ⇒ Object



528
529
530
# File 'lib/aarch64.rb', line 528

def casl s, t, n_list
  a CAS.new(s, t, n_list[0], 0, 1, s.sf)
end

#caslb(rs, rt, rn_list) ⇒ Object



544
545
546
# File 'lib/aarch64.rb', line 544

def caslb rs, rt, rn_list
  a CASB.new(rs, rt, rn_list[0], 0, 1)
end

#caslh(rs, rt, rn_list) ⇒ Object



560
561
562
# File 'lib/aarch64.rb', line 560

def caslh rs, rt, rn_list
  a CASH.new(rs, rt, rn_list[0], 0, 1)
end

#casp(rs, rs1, rt, rt1, rn_list) ⇒ Object



564
565
566
# File 'lib/aarch64.rb', line 564

def casp rs, rs1, rt, rt1, rn_list
  a CASP.new(rs, rt, rn_list[0], 0, 0, rs.sf)
end

#caspa(rs, rs1, rt, rt1, rn_list) ⇒ Object



568
569
570
# File 'lib/aarch64.rb', line 568

def caspa rs, rs1, rt, rt1, rn_list
  a CASP.new(rs, rt, rn_list[0], 1, 0, rs.sf)
end

#caspal(rs, rs1, rt, rt1, rn_list) ⇒ Object



576
577
578
# File 'lib/aarch64.rb', line 576

def caspal rs, rs1, rt, rt1, rn_list
  a CASP.new(rs, rt, rn_list[0], 1, 1, rs.sf)
end

#caspl(rs, rs1, rt, rt1, rn_list) ⇒ Object



572
573
574
# File 'lib/aarch64.rb', line 572

def caspl rs, rs1, rt, rt1, rn_list
  a CASP.new(rs, rt, rn_list[0], 0, 1, rs.sf)
end

#cbnz(rt, label) ⇒ Object



580
581
582
583
584
585
# File 'lib/aarch64.rb', line 580

def cbnz rt, label
  if label.integer?
    label = wrap_offset_with_label label
  end
  a CBNZ.new(rt, label, rt.sf)
end

#cbz(rt, label) ⇒ Object



587
588
589
590
591
592
# File 'lib/aarch64.rb', line 587

def cbz rt, label
  if label.integer?
    label = wrap_offset_with_label label
  end
  a CBZ.new(rt, label, rt.sf)
end

#ccmn(rn, rm, nzcv, cond) ⇒ Object



594
595
596
597
598
599
600
601
602
# File 'lib/aarch64.rb', line 594

def ccmn rn, rm, nzcv, cond
  cond = Utils.cond2bin(cond)

  if rm.integer?
    a CCMN_imm.new(rn, rm, nzcv, cond, rn.sf)
  else
    a CCMN_reg.new(rn, rm, nzcv, cond, rn.sf)
  end
end

#ccmp(rn, rm, nzcv, cond) ⇒ Object



604
605
606
607
608
609
610
611
612
# File 'lib/aarch64.rb', line 604

def ccmp rn, rm, nzcv, cond
  cond = Utils.cond2bin(cond)

  if rm.integer?
    a CCMP_imm.new(rn, rm, nzcv, cond, rn.sf)
  else
    a CCMP_reg.new(rn, rm, nzcv, cond, rn.sf)
  end
end

#cfinvObject



614
615
616
# File 'lib/aarch64.rb', line 614

def cfinv
  a CFINV.new
end

#cfp_rcfx(rt) ⇒ Object



618
619
620
# File 'lib/aarch64.rb', line 618

def cfp_rcfx rt
  sys 3, Names::C7, Names::C3, 4, rt
end

#cinc(rd, rn, cond) ⇒ Object



622
623
624
# File 'lib/aarch64.rb', line 622

def cinc rd, rn, cond
  a CSINC.new(rd, rn, rn, Utils.cond2bin(cond) ^ 1, rd.sf)
end

#cinv(rd, rn, cond) ⇒ Object



639
640
641
# File 'lib/aarch64.rb', line 639

def cinv rd, rn, cond
  a CSINV.new(rd, rn, rn, Utils.cond2bin(cond) ^ 1, rd.sf)
end

#clrex(imm = 15) ⇒ Object



647
648
649
# File 'lib/aarch64.rb', line 647

def clrex imm = 15
  a CLREX.new(imm)
end

#cls(rd, rn) ⇒ Object



651
652
653
# File 'lib/aarch64.rb', line 651

def cls rd, rn
  a CLS_int.new(rd, rn, rd.sf)
end

#clz(rd, rn) ⇒ Object



655
656
657
# File 'lib/aarch64.rb', line 655

def clz rd, rn
  a CLZ_int.new(rd, rn, rd.sf)
end

#cmn(rn, rm, option = nil, extend: nil, amount: 0, shift: :lsl, lsl: 0) ⇒ Object



659
660
661
# File 'lib/aarch64.rb', line 659

def cmn rn, rm, option = nil, extend: nil, amount: 0, shift: :lsl, lsl: 0
  adds(rn.zr, rn, rm, option, extend: extend, amount: amount, shift: shift, lsl: lsl)
end

#cmp(rn, rm, option = nil, extend: nil, amount: 0, shift: :lsl, lsl: 0) ⇒ Object



663
664
665
# File 'lib/aarch64.rb', line 663

def cmp rn, rm, option = nil, extend: nil, amount: 0, shift: :lsl, lsl: 0
  subs(rn.zr, rn, rm, option, extend: extend, amount: amount, shift: shift, lsl: lsl)
end

#cmpp(xn, xm) ⇒ Object



667
668
669
# File 'lib/aarch64.rb', line 667

def cmpp xn, xm
  subps XZR, xn, xm
end

#cneg(rd, rn, cond) ⇒ Object



671
672
673
# File 'lib/aarch64.rb', line 671

def cneg rd, rn, cond
  a CSNEG.new(rd, rn, rn, Utils.cond2bin(cond) ^ 1, rd.sf)
end

#cpp(_, xn) ⇒ Object



675
676
677
# File 'lib/aarch64.rb', line 675

def cpp _, xn
  sys 3, Names::C7, Names::C3, 7, xn
end

#crc32b(rd, rn, rm) ⇒ Object



679
680
681
# File 'lib/aarch64.rb', line 679

def crc32b rd, rn, rm
  a CRC32.new(rd, rn, rm, 0x00, 0b0)
end

#crc32cb(rd, rn, rm) ⇒ Object



695
696
697
# File 'lib/aarch64.rb', line 695

def crc32cb rd, rn, rm
  a CRC32C.new(rd, rn, rm, 0x00, 0b0)
end

#crc32ch(rd, rn, rm) ⇒ Object



699
700
701
# File 'lib/aarch64.rb', line 699

def crc32ch rd, rn, rm
  a CRC32C.new(rd, rn, rm, 0x01, 0b0)
end

#crc32cw(rd, rn, rm) ⇒ Object



703
704
705
# File 'lib/aarch64.rb', line 703

def crc32cw rd, rn, rm
  a CRC32C.new(rd, rn, rm, 0x02, 0b0)
end

#crc32cx(rd, rn, rm) ⇒ Object



707
708
709
# File 'lib/aarch64.rb', line 707

def crc32cx rd, rn, rm
  a CRC32C.new(rd, rn, rm, 0x03, 0b1)
end

#crc32h(rd, rn, rm) ⇒ Object



683
684
685
# File 'lib/aarch64.rb', line 683

def crc32h rd, rn, rm
  a CRC32.new(rd, rn, rm, 0x01, 0b0)
end

#crc32w(rd, rn, rm) ⇒ Object



687
688
689
# File 'lib/aarch64.rb', line 687

def crc32w rd, rn, rm
  a CRC32.new(rd, rn, rm, 0x02, 0b0)
end

#crc32x(rd, rn, rm) ⇒ Object



691
692
693
# File 'lib/aarch64.rb', line 691

def crc32x rd, rn, rm
  a CRC32.new(rd, rn, rm, 0x03, 0b1)
end

#csdbObject



711
712
713
# File 'lib/aarch64.rb', line 711

def csdb
  a CSDB.new
end

#csel(rd, rn, rm, cond) ⇒ Object



715
716
717
# File 'lib/aarch64.rb', line 715

def csel rd, rn, rm, cond
  a CSEL.new(rd, rn, rm, Utils.cond2bin(cond), rd.sf)
end

#cset(rd, cond) ⇒ Object



626
627
628
# File 'lib/aarch64.rb', line 626

def cset rd, cond
  a CSINC.new(rd, WZR, WZR, Utils.cond2bin(cond) ^ 1, rd.sf)
end

#csetm(rd, cond) ⇒ Object



630
631
632
633
# File 'lib/aarch64.rb', line 630

def csetm rd, cond
  reg = rd.zr
  a CSINV.new(rd, reg, reg, Utils.cond2bin(cond) ^ 1, rd.sf)
end

#csinc(rd, rn, rm, cond) ⇒ Object



635
636
637
# File 'lib/aarch64.rb', line 635

def csinc rd, rn, rm, cond
  a CSINC.new(rd, rn, rm, Utils.cond2bin(cond), rd.sf)
end

#csinv(rd, rn, rm, cond) ⇒ Object



643
644
645
# File 'lib/aarch64.rb', line 643

def csinv rd, rn, rm, cond
  a CSINV.new(rd, rn, rm, Utils.cond2bin(cond), rd.sf)
end

#csneg(rd, rn, rm, cond) ⇒ Object



719
720
721
# File 'lib/aarch64.rb', line 719

def csneg rd, rn, rm, cond
  a CSNEG.new(rd, rn, rm, Utils.cond2bin(cond), rd.sf)
end

#dc(dc_op, xt) ⇒ Object



723
724
725
726
# File 'lib/aarch64.rb', line 723

def dc dc_op, xt
  op1, cm, op2 = Utils.dc_op(dc_op)
  sys op1, Names::C7, cm, op2, xt
end

#dcps1(imm = 0) ⇒ Object



728
729
730
# File 'lib/aarch64.rb', line 728

def dcps1 imm = 0
  a DCPS.new(imm, 0x1)
end

#dcps2(imm = 0) ⇒ Object



732
733
734
# File 'lib/aarch64.rb', line 732

def dcps2 imm = 0
  a DCPS.new(imm, 0x2)
end

#dcps3(imm = 0) ⇒ Object



736
737
738
# File 'lib/aarch64.rb', line 736

def dcps3 imm = 0
  a DCPS.new(imm, 0x3)
end

#dghObject



740
741
742
# File 'lib/aarch64.rb', line 740

def dgh
  a DGH.new
end

#dmb(option) ⇒ Object



744
745
746
747
748
749
750
# File 'lib/aarch64.rb', line 744

def dmb option
  if Numeric === option
    a DMB.new(option)
  else
    a DMB.new(Utils.dmb2imm(option))
  end
end

#drpsObject



752
753
754
# File 'lib/aarch64.rb', line 752

def drps
  a DRPS.new
end

#dsb(option) ⇒ Object



756
757
758
759
760
761
762
# File 'lib/aarch64.rb', line 756

def dsb option
  if Numeric === option
    a DSB.new(option)
  else
    a DSB.new(Utils.dmb2imm(option))
  end
end

#dvp(_, xt) ⇒ Object



764
765
766
# File 'lib/aarch64.rb', line 764

def dvp _, xt
  sys 3, Names::C7, Names::C3, 5, xt
end

#eon(d, n, m, option = nil, amount: 0, shift: :lsl) ⇒ Object



768
769
770
771
772
773
774
775
776
# File 'lib/aarch64.rb', line 768

def eon d, n, m, option = nil, amount: 0, shift: :lsl
  if option
    shift = option.name
    amount = option.amount
  end

  shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)
  a EON.new(d, n, m, shift, amount, d.sf)
end

#eor(rd, rn, rm, options = nil, shift: :lsl, amount: 0) ⇒ Object



778
779
780
781
782
783
784
785
786
787
788
789
790
791
# File 'lib/aarch64.rb', line 778

def eor rd, rn, rm, options = nil, shift: :lsl, amount: 0
  if options
    shift = options.name
    amount = options.amount
  end

  if rm.integer?
    encoding = Utils.encode_mask(rm, rd.size)
    a EOR_log_imm.new(rd, rn, encoding.n, encoding.immr, encoding.imms, rd.sf)
  else
    shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)
    a EOR_log_shift.new(rd, rn, rm, shift, amount, rd.sf)
  end
end

#eretObject



793
794
795
# File 'lib/aarch64.rb', line 793

def eret
  a ERET.new
end

#eretaaObject



797
798
799
# File 'lib/aarch64.rb', line 797

def eretaa
  a ERETA.new(0)
end

#eretabObject



801
802
803
# File 'lib/aarch64.rb', line 801

def eretab
  a ERETA.new(1)
end

#esbObject



805
806
807
# File 'lib/aarch64.rb', line 805

def esb
  a ESB.new
end

#extr(rd, rn, rm, lsb) ⇒ Object



809
810
811
# File 'lib/aarch64.rb', line 809

def extr rd, rn, rm, lsb
  a EXTR.new(rd, rn, rm, lsb, rd.sf)
end

#gmi(rd, rn, rm) ⇒ Object



813
814
815
# File 'lib/aarch64.rb', line 813

def gmi rd, rn, rm
  a GMI.new(rd, rn, rm)
end

#hint(imm) ⇒ Object



817
818
819
# File 'lib/aarch64.rb', line 817

def hint imm
  a HINT.new(imm >> 3, imm & 0b111)
end

#hlt(imm) ⇒ Object



821
822
823
# File 'lib/aarch64.rb', line 821

def hlt imm
  a HLT.new(imm)
end

#hvc(imm) ⇒ Object



825
826
827
# File 'lib/aarch64.rb', line 825

def hvc imm
  a HVC.new(imm)
end

#ic(op, xt = SP) ⇒ Object



829
830
831
832
# File 'lib/aarch64.rb', line 829

def ic op, xt = SP
  op1, crm, op2 = Utils.ic_op(op)
  sys op1, Names::C7, crm, op2, xt
end

#irg(rd, rn, rm = XZR) ⇒ Object



834
835
836
# File 'lib/aarch64.rb', line 834

def irg rd, rn, rm = XZR
  a IRG.new(rd, rn, rm)
end

#isb(option = 0b1111) ⇒ Object



838
839
840
# File 'lib/aarch64.rb', line 838

def isb option = 0b1111
  a ISB.new(option)
end

#ld64b(rt, rn) ⇒ Object



842
843
844
# File 'lib/aarch64.rb', line 842

def ld64b rt, rn
  a LD64B.new(rt, rn.first)
end

#ldadd(rs, rt, rn) ⇒ Object



846
847
848
# File 'lib/aarch64.rb', line 846

def ldadd rs, rt, rn
  a LDADD.new(rs, rt, rn.first, rs.opc2, 0, 0)
end

#ldadda(rs, rt, rn) ⇒ Object



850
851
852
# File 'lib/aarch64.rb', line 850

def ldadda rs, rt, rn
  a LDADD.new(rs, rt, rn.first, rs.opc2, 1, 0)
end

#ldaddab(rs, rt, rn) ⇒ Object



862
863
864
# File 'lib/aarch64.rb', line 862

def ldaddab rs, rt, rn
  a LDADDB.new(rs, rt, rn.first, 1, 0)
end

#ldaddah(rs, rt, rn) ⇒ Object



878
879
880
# File 'lib/aarch64.rb', line 878

def ldaddah rs, rt, rn
  a LDADDH.new(rs, rt, rn.first, 1, 0)
end

#ldaddal(rs, rt, rn) ⇒ Object



854
855
856
# File 'lib/aarch64.rb', line 854

def ldaddal rs, rt, rn
  a LDADD.new(rs, rt, rn.first, rs.opc2, 1, 1)
end

#ldaddalb(rs, rt, rn) ⇒ Object



866
867
868
# File 'lib/aarch64.rb', line 866

def ldaddalb rs, rt, rn
  a LDADDB.new(rs, rt, rn.first, 1, 1)
end

#ldaddalh(rs, rt, rn) ⇒ Object



882
883
884
# File 'lib/aarch64.rb', line 882

def ldaddalh rs, rt, rn
  a LDADDH.new(rs, rt, rn.first, 1, 1)
end

#ldaddb(rs, rt, rn) ⇒ Object



870
871
872
# File 'lib/aarch64.rb', line 870

def ldaddb rs, rt, rn
  a LDADDB.new(rs, rt, rn.first, 0, 0)
end

#ldaddh(rs, rt, rn) ⇒ Object



886
887
888
# File 'lib/aarch64.rb', line 886

def ldaddh rs, rt, rn
  a LDADDH.new(rs, rt, rn.first, 0, 0)
end

#ldaddl(rs, rt, rn) ⇒ Object



858
859
860
# File 'lib/aarch64.rb', line 858

def ldaddl rs, rt, rn
  a LDADD.new(rs, rt, rn.first, rs.opc2, 0, 1)
end

#ldaddlb(rs, rt, rn) ⇒ Object



874
875
876
# File 'lib/aarch64.rb', line 874

def ldaddlb rs, rt, rn
  a LDADDB.new(rs, rt, rn.first, 0, 1)
end

#ldaddlh(rs, rt, rn) ⇒ Object



890
891
892
# File 'lib/aarch64.rb', line 890

def ldaddlh rs, rt, rn
  a LDADDH.new(rs, rt, rn.first, 0, 1)
end

#ldapr(rt, rn) ⇒ Object



894
895
896
# File 'lib/aarch64.rb', line 894

def ldapr rt, rn
  a LDAPR.new(rt, rn.first, rt.opc2)
end

#ldaprb(rt, rn) ⇒ Object



898
899
900
# File 'lib/aarch64.rb', line 898

def ldaprb rt, rn
  a LDAPRB.new(rt, rn.first)
end

#ldaprh(rt, rn) ⇒ Object



902
903
904
# File 'lib/aarch64.rb', line 902

def ldaprh rt, rn
  a LDAPRH.new(rt, rn.first)
end

#ldapur(rt, rn) ⇒ Object



906
907
908
# File 'lib/aarch64.rb', line 906

def ldapur rt, rn
  a LDAPUR_gen.new(rt.opc2, 0b01, rt, rn.first, rn[1] || 0)
end

#ldapurb(rt, rn) ⇒ Object



910
911
912
# File 'lib/aarch64.rb', line 910

def ldapurb rt, rn
  a LDAPUR_gen.new(0b00, 0b01, rt, rn.first, rn[1] || 0)
end

#ldapurh(rt, rn) ⇒ Object



914
915
916
# File 'lib/aarch64.rb', line 914

def ldapurh rt, rn
  a LDAPUR_gen.new(0b01, 0b01, rt, rn.first, rn[1] || 0)
end

#ldapursb(rt, rn) ⇒ Object



918
919
920
# File 'lib/aarch64.rb', line 918

def ldapursb rt, rn
  a LDAPUR_gen.new(0b00, rt.opc, rt, rn.first, rn[1] || 0)
end

#ldapursh(rt, rn) ⇒ Object



922
923
924
# File 'lib/aarch64.rb', line 922

def ldapursh rt, rn
  a LDAPUR_gen.new(0b01, rt.opc, rt, rn.first, rn[1] || 0)
end

#ldapursw(rt, rn) ⇒ Object



926
927
928
# File 'lib/aarch64.rb', line 926

def ldapursw rt, rn
  a LDAPUR_gen.new(0b10, 0b10, rt, rn.first, rn[1] || 0)
end

#ldar(rt, rn) ⇒ Object



930
931
932
# File 'lib/aarch64.rb', line 930

def ldar rt, rn
  a LDAR.new(rt, rn.first, rt.opc2)
end

#ldarb(rt, rn) ⇒ Object



934
935
936
# File 'lib/aarch64.rb', line 934

def ldarb rt, rn
  a LDAR.new(rt, rn.first, 0x00)
end

#ldarh(rt, rn) ⇒ Object



938
939
940
# File 'lib/aarch64.rb', line 938

def ldarh rt, rn
  a LDAR.new(rt, rn.first, 0x01)
end

#ldaxp(rt1, rt2, xn) ⇒ Object



942
943
944
# File 'lib/aarch64.rb', line 942

def ldaxp rt1, rt2, xn
  a LDAXP.new(rt1, rt2, xn.first, rt1.sf)
end

#ldaxr(rt1, xn) ⇒ Object



946
947
948
# File 'lib/aarch64.rb', line 946

def ldaxr rt1, xn
  a LDAXR.new(rt1, xn.first, rt1.opc2)
end

#ldaxrb(rt1, xn) ⇒ Object



950
951
952
# File 'lib/aarch64.rb', line 950

def ldaxrb rt1, xn
  a LDAXR.new(rt1, xn.first, 0b00)
end

#ldaxrh(rt1, xn) ⇒ Object



954
955
956
# File 'lib/aarch64.rb', line 954

def ldaxrh rt1, xn
  a LDAXR.new(rt1, xn.first, 0b01)
end

#ldclr(rs, rt, rn) ⇒ Object



958
959
960
# File 'lib/aarch64.rb', line 958

def ldclr rs, rt, rn
  a LDCLR.new(rs, rt, rn.first, 0, 0, rs.opc2)
end

#ldclra(rs, rt, rn) ⇒ Object



962
963
964
# File 'lib/aarch64.rb', line 962

def ldclra rs, rt, rn
  a LDCLR.new(rs, rt, rn.first, 1, 0, rs.opc2)
end

#ldclrab(rs, rt, rn) ⇒ Object



974
975
976
# File 'lib/aarch64.rb', line 974

def ldclrab rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 1, 0, 0b00)
end

#ldclrah(rs, rt, rn) ⇒ Object



990
991
992
# File 'lib/aarch64.rb', line 990

def ldclrah rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 1, 0, 0b01)
end

#ldclral(rs, rt, rn) ⇒ Object



966
967
968
# File 'lib/aarch64.rb', line 966

def ldclral rs, rt, rn
  a LDCLR.new(rs, rt, rn.first, 1, 1, rs.opc2)
end

#ldclralb(rs, rt, rn) ⇒ Object



978
979
980
# File 'lib/aarch64.rb', line 978

def ldclralb rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 1, 1, 0b00)
end

#ldclralh(rs, rt, rn) ⇒ Object



994
995
996
# File 'lib/aarch64.rb', line 994

def ldclralh rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 1, 1, 0b01)
end

#ldclrb(rs, rt, rn) ⇒ Object



982
983
984
# File 'lib/aarch64.rb', line 982

def ldclrb rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 0, 0, 0b00)
end

#ldclrh(rs, rt, rn) ⇒ Object



998
999
1000
# File 'lib/aarch64.rb', line 998

def ldclrh rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 0, 0, 0b01)
end

#ldclrl(rs, rt, rn) ⇒ Object



970
971
972
# File 'lib/aarch64.rb', line 970

def ldclrl rs, rt, rn
  a LDCLR.new(rs, rt, rn.first, 0, 1, rs.opc2)
end

#ldclrlb(rs, rt, rn) ⇒ Object



986
987
988
# File 'lib/aarch64.rb', line 986

def ldclrlb rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 0, 1, 0b00)
end

#ldclrlh(rs, rt, rn) ⇒ Object



1002
1003
1004
# File 'lib/aarch64.rb', line 1002

def ldclrlh rs, rt, rn
  a LDCLRB.new(rs, rt, rn.first, 0, 1, 0b01)
end

#ldeor(rs, rt, rn) ⇒ Object



1006
1007
1008
# File 'lib/aarch64.rb', line 1006

def ldeor rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 0, 0, rs.opc2)
end

#ldeora(rs, rt, rn) ⇒ Object



1010
1011
1012
# File 'lib/aarch64.rb', line 1010

def ldeora rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 1, 0, rs.opc2)
end

#ldeorab(rs, rt, rn) ⇒ Object



1022
1023
1024
# File 'lib/aarch64.rb', line 1022

def ldeorab rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 1, 0, 0b00)
end

#ldeorah(rs, rt, rn) ⇒ Object



1038
1039
1040
# File 'lib/aarch64.rb', line 1038

def ldeorah rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 1, 0, 0b01)
end

#ldeoral(rs, rt, rn) ⇒ Object



1014
1015
1016
# File 'lib/aarch64.rb', line 1014

def ldeoral rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 1, 1, rs.opc2)
end

#ldeoralb(rs, rt, rn) ⇒ Object



1026
1027
1028
# File 'lib/aarch64.rb', line 1026

def ldeoralb rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 1, 1, 0b00)
end

#ldeoralh(rs, rt, rn) ⇒ Object



1042
1043
1044
# File 'lib/aarch64.rb', line 1042

def ldeoralh rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 1, 1, 0b01)
end

#ldeorb(rs, rt, rn) ⇒ Object



1030
1031
1032
# File 'lib/aarch64.rb', line 1030

def ldeorb rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 0, 0, 0b00)
end

#ldeorh(rs, rt, rn) ⇒ Object



1046
1047
1048
# File 'lib/aarch64.rb', line 1046

def ldeorh rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 0, 0, 0b01)
end

#ldeorl(rs, rt, rn) ⇒ Object



1018
1019
1020
# File 'lib/aarch64.rb', line 1018

def ldeorl rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 0, 1, rs.opc2)
end

#ldeorlb(rs, rt, rn) ⇒ Object



1034
1035
1036
# File 'lib/aarch64.rb', line 1034

def ldeorlb rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 0, 1, 0b00)
end

#ldeorlh(rs, rt, rn) ⇒ Object



1050
1051
1052
# File 'lib/aarch64.rb', line 1050

def ldeorlh rs, rt, rn
  a LDEOR.new(rs, rt, rn.first, 0, 1, 0b01)
end

#ldg(xt, xn) ⇒ Object



1054
1055
1056
# File 'lib/aarch64.rb', line 1054

def ldg xt, xn
  a LDG.new(xt, xn.first, xn[1] || 0)
end

#ldgm(xt, xn) ⇒ Object



1058
1059
1060
# File 'lib/aarch64.rb', line 1058

def ldgm xt, xn
  a LDGM.new(xt, xn.first)
end

#ldlar(rt, rn) ⇒ Object



1062
1063
1064
# File 'lib/aarch64.rb', line 1062

def ldlar rt, rn
  a LDLAR.new(rt, rn.first, rt.opc2)
end

#ldlarb(rt, rn) ⇒ Object



1066
1067
1068
# File 'lib/aarch64.rb', line 1066

def ldlarb rt, rn
  a LDLAR.new(rt, rn.first, 0b00)
end

#ldlarh(rt, rn) ⇒ Object



1070
1071
1072
# File 'lib/aarch64.rb', line 1070

def ldlarh rt, rn
  a LDLAR.new(rt, rn.first, 0b01)
end

#ldnp(rt1, rt2, rn) ⇒ Object



1074
1075
1076
1077
# File 'lib/aarch64.rb', line 1074

def ldnp rt1, rt2, rn
  div = rt1.size / 8
  a LDNP_gen.new(rt1, rt2, rn.first, (rn[1] || 0) / div, rt1.opc3)
end

#ldp(rt1, rt2, rn, imm = nil) ⇒ Object



1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
# File 'lib/aarch64.rb', line 1079

def ldp rt1, rt2, rn, imm = nil
  opc = rt1.opc3
  div = rt1.size / 8

  if imm
    if imm == :!
      # pre-index
      a LDP_gen.new(rt1, rt2, rn.first, (rn[1] || 0) / div, 0b011, opc)
    else
      # post-index
      a LDP_gen.new(rt1, rt2, rn.first, (imm || 0) / div, 0b001, opc)
    end
  else
    # signed offset
    a LDP_gen.new(rt1, rt2, rn.first, (rn[1] || 0) / div, 0b010, opc)
  end
end

#ldpsw(rt, rt2, rn, imm = nil) ⇒ Object



1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
# File 'lib/aarch64.rb', line 1097

def ldpsw rt, rt2, rn, imm = nil
  div = 4

  if imm
    if imm == :!
      # pre-index
      a LDPSW.new(rt, rt2, rn.first, (rn[1] || 0) / div, 0b011)
    else
      # post-index
      a LDPSW.new(rt, rt2, rn.first, (imm || 0) / div, 0b001)
    end
  else
    # signed offset
    a LDPSW.new(rt, rt2, rn.first, (rn[1] || 0) / div, 0b010)
  end
end

#ldr(rt, rn, simm = nil) ⇒ Object



1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
# File 'lib/aarch64.rb', line 1114

def ldr rt, rn, simm = nil
  size = rt.opc2

  if simm
    if simm == :!
      a LDR_imm_gen.new(rt, rn.first, (rn[1] || 0), size, 0b11)
    else
      if simm.integer?
        a LDR_imm_gen.new(rt, rn.first, simm, size, 0b01)
      else
        raise
      end
    end
  else
    if rn.is_a?(Array)
      simm = rn[1] || 0
      if simm.integer?
        div = rt.size / 8
        a LDR_imm_unsigned.new(rt, rn.first, simm / div, size)
      else
        rn, rm, option = *rn
        option ||= Shifts::Shift.new(0, 0, :lsl)
        extend = case option.name
                 when :uxtw then 0b010
                 when :lsl  then 0b011
                 when :sxtw then 0b110
                 when :sxtx then 0b111
                 else
                   raise option.name
                 end

        amount = if rt.x?
                   if option.amount == 3
                     1
                   else
                     0
                   end
                 else
                   if option.amount == 2
                     1
                   else
                     0
                   end
                 end

        a LDR_reg_gen.new(rt, rn, rm, size, extend, amount)
      end
    else
      if rn.integer?
        rn = wrap_offset_with_label rn
      end
      a LDR_lit_gen.new(rt, rn, rt.sf)
    end
  end
end

#ldraa(xt, xn, option = nil) ⇒ Object



1170
1171
1172
1173
1174
# File 'lib/aarch64.rb', line 1170

def ldraa xt, xn, option = nil
  imm = xn[1] || 0
  s = imm < 0 ? 1 : 0
  a LDRA.new(xt, xn.first, imm / 8, 0, option == :! ? 1 : 0, s)
end

#ldrab(xt, xn, option = nil) ⇒ Object



1176
1177
1178
1179
1180
# File 'lib/aarch64.rb', line 1176

def ldrab xt, xn, option = nil
  imm = xn[1] || 0
  s = imm < 0 ? 1 : 0
  a LDRA.new(xt, xn.first, imm / 8, 1, option == :! ? 1 : 0, s)
end

#ldrb(wt, xn, imm = nil) ⇒ Object



1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
# File 'lib/aarch64.rb', line 1182

def ldrb wt, xn, imm = nil
  if imm
    if imm == :!
      a LDRB_imm.new(wt, xn.first, xn[1], 0b11)
    else
      # Post index
      a LDRB_imm.new(wt, xn.first, imm, 0b01)
    end
  else
    xn, imm, option = *xn
    imm ||= 0
    if imm.integer?
      a LDRB_unsigned.new(wt, xn, imm)
    else
      if option
        option_name = option ? option.name : :lsl

        val = case option_name
              when :lsl then 0b011
              when :uxtw then 0b010
              when :sxtw then 0b110
              when :sxtx then 0b111
              end

        s = if option.shift?
          !!option.amount
        else
          false
        end
        a LDRB_reg.new(wt, xn, imm, s ? 1 : 0, val)
      else
        a LDRB_reg.new(wt, xn, imm, 0, 0b11)
      end
    end
  end
end

#ldrh(wt, xn, imm = nil) ⇒ Object



1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
# File 'lib/aarch64.rb', line 1219

def ldrh wt, xn, imm = nil
  if imm
    if imm == :!
      a LDRH_imm.new(wt, xn.first, xn[1], 0b11)
    else
      # Post index
      a LDRH_imm.new(wt, xn.first, imm, 0b01)
    end
  else
    xn, imm, option = *xn
    imm ||= 0
    if imm.integer?
      a LDRH_unsigned.new(wt, xn, imm)
    else
      if option
        option_name = option ? option.name : :lsl

        val = case option_name
              when :lsl then 0b011
              when :uxtw then 0b010
              when :sxtw then 0b110
              when :sxtx then 0b111
              end

        s = if option.shift?
          !!option.amount
        else
          false
        end
        a LDRH_reg.new(wt, xn, imm, s ? 1 : 0, val)
      else
        a LDRH_reg.new(wt, xn, imm, 0, 0b11)
      end
    end
  end
end

#ldrsb(wt, xn, imm = nil) ⇒ Object



1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
# File 'lib/aarch64.rb', line 1256

def ldrsb wt, xn, imm = nil
  opc = wt.opc

  if imm
    if imm == :!
      a LDRSB_imm.new(wt, xn.first, xn[1], 0b11, opc)
    else
      # Post index
      a LDRSB_imm.new(wt, xn.first, imm, 0b01, opc)
    end
  else
    xn, imm, option = *xn
    imm ||= 0
    if imm.integer?
      a LDRSB_unsigned.new(wt, xn, imm, opc)
    else
      if option
        option_name = option ? option.name : :lsl

        val = case option_name
              when :uxtw then 0b010
              when :sxtw then 0b110
              when :sxtx then 0b111
              end

        a LDRSB_reg.new(wt, xn, imm, 1, val, opc)
      else
        a LDRSB_reg.new(wt, xn, imm, 0, 0b11, opc)
      end
    end
  end
end

#ldrsh(wt, xn, imm = nil) ⇒ Object



1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
# File 'lib/aarch64.rb', line 1289

def ldrsh wt, xn, imm = nil
  opc = wt.opc

  if imm
    if imm == :!
      a LDRSH_imm.new(wt, xn.first, xn[1] || 0, 0b11, opc)
    else
      a LDRSH_imm.new(wt, xn.first, imm, 0b01, opc)
    end
  else
    xn, imm, option = *xn
    imm ||= 0
    if imm.integer?
      a LDRSH_unsigned.new(wt, xn, imm / 2, opc)
    else
      if option
        option_name = option ? option.name : :lsl

        val = case option_name
              when :uxtw then 0b010
              when :sxtw then 0b110
              when :sxtx then 0b111
              end

        a LDRSH_reg.new(wt, xn, imm, 1, val, opc)
      else
        a LDRSH_reg.new(wt, xn, imm, 0, 0b11, opc)
      end
    end
  end
end

#ldrsw(xt, xn, imm = nil) ⇒ Object



1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
# File 'lib/aarch64.rb', line 1321

def ldrsw xt, xn, imm = nil
  if imm
    if imm == :!
      a LDRSW_imm.new(xt, xn.first, xn[1] || 0, 0b11)
    else
      a LDRSW_imm.new(xt, xn.first, imm, 0b01)
    end
  else
    if xn.is_a?(Array)
      xn, imm, option = *xn
      imm ||= 0
      if imm.integer?
        a LDRSW_unsigned.new(xt, xn, imm / 4)
      else
        if option
          option_name = option ? option.name : :lsl

          val = case option_name
                when :uxtw then 0b010
                when :lsl  then 0b011
                when :sxtw then 0b110
                when :sxtx then 0b111
                end

          a LDRSW_reg.new(xt, xn, imm, (option.amount || 0) / 2, val)
        else
          a LDRSW_reg.new(xt, xn, imm, 0, 0b11)
        end
      end
    else
      if xn.integer?
        xn = wrap_offset_with_label xn
      end
      a LDRSW_lit.new(xt, xn)
    end
  end
end

#ldset(rs, rt, rn) ⇒ Object



1359
1360
1361
# File 'lib/aarch64.rb', line 1359

def ldset rs, rt, rn
  a LDSET.new(rs, rt, rn.first, rs.opc2, 0, 0)
end

#ldseta(rs, rt, rn) ⇒ Object



1363
1364
1365
# File 'lib/aarch64.rb', line 1363

def ldseta rs, rt, rn
  a LDSET.new(rs, rt, rn.first, rs.opc2, 1, 0)
end

#ldsetab(rs, rt, rn) ⇒ Object



1379
1380
1381
# File 'lib/aarch64.rb', line 1379

def ldsetab rs, rt, rn
  a LDSETB.new(rs, rt, rn.first, 1, 0)
end

#ldsetah(rs, rt, rn) ⇒ Object



1395
1396
1397
# File 'lib/aarch64.rb', line 1395

def ldsetah rs, rt, rn
  a LDSETH.new(rs, rt, rn.first, 1, 0)
end

#ldsetal(rs, rt, rn) ⇒ Object



1367
1368
1369
# File 'lib/aarch64.rb', line 1367

def ldsetal rs, rt, rn
  a LDSET.new(rs, rt, rn.first, rs.opc2, 1, 1)
end

#ldsetalb(rs, rt, rn) ⇒ Object



1383
1384
1385
# File 'lib/aarch64.rb', line 1383

def ldsetalb rs, rt, rn
  a LDSETB.new(rs, rt, rn.first, 1, 1)
end

#ldsetalh(rs, rt, rn) ⇒ Object



1399
1400
1401
# File 'lib/aarch64.rb', line 1399

def ldsetalh rs, rt, rn
  a LDSETH.new(rs, rt, rn.first, 1, 1)
end

#ldsetb(rs, rt, rn) ⇒ Object



1375
1376
1377
# File 'lib/aarch64.rb', line 1375

def ldsetb rs, rt, rn
  a LDSETB.new(rs, rt, rn.first, 0, 0)
end

#ldseth(rs, rt, rn) ⇒ Object



1391
1392
1393
# File 'lib/aarch64.rb', line 1391

def ldseth rs, rt, rn
  a LDSETH.new(rs, rt, rn.first, 0, 0)
end

#ldsetl(rs, rt, rn) ⇒ Object



1371
1372
1373
# File 'lib/aarch64.rb', line 1371

def ldsetl rs, rt, rn
  a LDSET.new(rs, rt, rn.first, rs.opc2, 0, 1)
end

#ldsetlb(rs, rt, rn) ⇒ Object



1387
1388
1389
# File 'lib/aarch64.rb', line 1387

def ldsetlb rs, rt, rn
  a LDSETB.new(rs, rt, rn.first, 0, 1)
end

#ldsetlh(rs, rt, rn) ⇒ Object



1403
1404
1405
# File 'lib/aarch64.rb', line 1403

def ldsetlh rs, rt, rn
  a LDSETH.new(rs, rt, rn.first, 0, 1)
end

#ldsmax(rs, rt, rn) ⇒ Object



1407
1408
1409
# File 'lib/aarch64.rb', line 1407

def ldsmax rs, rt, rn
  a LDSMAX.new(rs, rt, rn.first, rs.opc2, 0, 0)
end

#ldsmaxa(rs, rt, rn) ⇒ Object



1411
1412
1413
# File 'lib/aarch64.rb', line 1411

def ldsmaxa rs, rt, rn
  a LDSMAX.new(rs, rt, rn.first, rs.opc2, 1, 0)
end

#ldsmaxab(rs, rt, rn) ⇒ Object



1423
1424
1425
# File 'lib/aarch64.rb', line 1423

def ldsmaxab rs, rt, rn
  a LDSMAXB.new(rs, rt, rn.first, 1, 0)
end

#ldsmaxah(rs, rt, rn) ⇒ Object



1439
1440
1441
# File 'lib/aarch64.rb', line 1439

def ldsmaxah rs, rt, rn
  a LDSMAXH.new(rs, rt, rn.first, 1, 0)
end

#ldsmaxal(rs, rt, rn) ⇒ Object



1415
1416
1417
# File 'lib/aarch64.rb', line 1415

def ldsmaxal rs, rt, rn
  a LDSMAX.new(rs, rt, rn.first, rs.opc2, 1, 1)
end

#ldsmaxalb(rs, rt, rn) ⇒ Object



1427
1428
1429
# File 'lib/aarch64.rb', line 1427

def ldsmaxalb rs, rt, rn
  a LDSMAXB.new(rs, rt, rn.first, 1, 1)
end

#ldsmaxalh(rs, rt, rn) ⇒ Object



1443
1444
1445
# File 'lib/aarch64.rb', line 1443

def ldsmaxalh rs, rt, rn
  a LDSMAXH.new(rs, rt, rn.first, 1, 1)
end

#ldsmaxb(rs, rt, rn) ⇒ Object



1431
1432
1433
# File 'lib/aarch64.rb', line 1431

def ldsmaxb rs, rt, rn
  a LDSMAXB.new(rs, rt, rn.first, 0, 0)
end

#ldsmaxh(rs, rt, rn) ⇒ Object



1447
1448
1449
# File 'lib/aarch64.rb', line 1447

def ldsmaxh rs, rt, rn
  a LDSMAXH.new(rs, rt, rn.first, 0, 0)
end

#ldsmaxl(rs, rt, rn) ⇒ Object



1419
1420
1421
# File 'lib/aarch64.rb', line 1419

def ldsmaxl rs, rt, rn
  a LDSMAX.new(rs, rt, rn.first, rs.opc2, 0, 1)
end

#ldsmaxlb(rs, rt, rn) ⇒ Object



1435
1436
1437
# File 'lib/aarch64.rb', line 1435

def ldsmaxlb rs, rt, rn
  a LDSMAXB.new(rs, rt, rn.first, 0, 1)
end

#ldsmaxlh(rs, rt, rn) ⇒ Object



1451
1452
1453
# File 'lib/aarch64.rb', line 1451

def ldsmaxlh rs, rt, rn
  a LDSMAXH.new(rs, rt, rn.first, 0, 1)
end

#ldsmin(rs, rt, rn) ⇒ Object



1455
1456
1457
# File 'lib/aarch64.rb', line 1455

def ldsmin rs, rt, rn
  a LDSMIN.new(rs, rt, rn.first, rs.opc2, 0, 0)
end

#ldsmina(rs, rt, rn) ⇒ Object



1459
1460
1461
# File 'lib/aarch64.rb', line 1459

def ldsmina rs, rt, rn
  a LDSMIN.new(rs, rt, rn.first, rs.opc2, 1, 0)
end

#ldsminab(rs, rt, rn) ⇒ Object



1475
1476
1477
# File 'lib/aarch64.rb', line 1475

def ldsminab rs, rt, rn
  a LDSMINB.new(rs, rt, rn.first, 1, 0)
end

#ldsminah(rs, rt, rn) ⇒ Object



1491
1492
1493
# File 'lib/aarch64.rb', line 1491

def ldsminah rs, rt, rn
  a LDSMINH.new(rs, rt, rn.first, 1, 0)
end

#ldsminal(rs, rt, rn) ⇒ Object



1463
1464
1465
# File 'lib/aarch64.rb', line 1463

def ldsminal rs, rt, rn
  a LDSMIN.new(rs, rt, rn.first, rs.opc2, 1, 1)
end

#ldsminalb(rs, rt, rn) ⇒ Object



1479
1480
1481
# File 'lib/aarch64.rb', line 1479

def ldsminalb rs, rt, rn
  a LDSMINB.new(rs, rt, rn.first, 1, 1)
end

#ldsminalh(rs, rt, rn) ⇒ Object



1495
1496
1497
# File 'lib/aarch64.rb', line 1495

def ldsminalh rs, rt, rn
  a LDSMINH.new(rs, rt, rn.first, 1, 1)
end

#ldsminb(rs, rt, rn) ⇒ Object



1471
1472
1473
# File 'lib/aarch64.rb', line 1471

def ldsminb rs, rt, rn
  a LDSMINB.new(rs, rt, rn.first, 0, 0)
end

#ldsminh(rs, rt, rn) ⇒ Object



1487
1488
1489
# File 'lib/aarch64.rb', line 1487

def ldsminh rs, rt, rn
  a LDSMINH.new(rs, rt, rn.first, 0, 0)
end

#ldsminl(rs, rt, rn) ⇒ Object



1467
1468
1469
# File 'lib/aarch64.rb', line 1467

def ldsminl rs, rt, rn
  a LDSMIN.new(rs, rt, rn.first, rs.opc2, 0, 1)
end

#ldsminlb(rs, rt, rn) ⇒ Object



1483
1484
1485
# File 'lib/aarch64.rb', line 1483

def ldsminlb rs, rt, rn
  a LDSMINB.new(rs, rt, rn.first, 0, 1)
end

#ldsminlh(rs, rt, rn) ⇒ Object



1499
1500
1501
# File 'lib/aarch64.rb', line 1499

def ldsminlh rs, rt, rn
  a LDSMINH.new(rs, rt, rn.first, 0, 1)
end

#ldtr(rt, rn) ⇒ Object



1503
1504
1505
# File 'lib/aarch64.rb', line 1503

def ldtr rt, rn
  a LDTR.new(rt, rn.first, rn[1] || 0, rt.opc2)
end

#ldtrb(rt, rn) ⇒ Object



1507
1508
1509
# File 'lib/aarch64.rb', line 1507

def ldtrb rt, rn
  a LDTRB.new(rt, rn.first, rn[1] || 0)
end

#ldtrh(rt, rn) ⇒ Object



1511
1512
1513
# File 'lib/aarch64.rb', line 1511

def ldtrh rt, rn
  a LDTRH.new(rt, rn.first, rn[1] || 0)
end

#ldtrsb(rt, rn) ⇒ Object



1515
1516
1517
# File 'lib/aarch64.rb', line 1515

def ldtrsb rt, rn
  a LDTRSB.new(rt, rn.first, rn[1] || 0, rt.opc)
end

#ldtrsh(rt, rn) ⇒ Object



1519
1520
1521
# File 'lib/aarch64.rb', line 1519

def ldtrsh rt, rn
  a LDTRSH.new(rt, rn.first, rn[1] || 0, rt.opc)
end

#ldtrsw(rt, rn) ⇒ Object



1523
1524
1525
# File 'lib/aarch64.rb', line 1523

def ldtrsw rt, rn
  a LDTRSW.new(rt, rn.first, rn[1] || 0)
end

#ldumax(rs, rt, rn) ⇒ Object



1527
1528
1529
# File 'lib/aarch64.rb', line 1527

def ldumax rs, rt, rn
  a LDUMAX.new(rs, rt, rn.first, rt.opc2, 0, 0)
end

#ldumaxa(rs, rt, rn) ⇒ Object



1531
1532
1533
# File 'lib/aarch64.rb', line 1531

def ldumaxa rs, rt, rn
  a LDUMAX.new(rs, rt, rn.first, rt.opc2, 1, 0)
end

#ldumaxab(rs, rt, rn) ⇒ Object



1543
1544
1545
# File 'lib/aarch64.rb', line 1543

def ldumaxab rs, rt, rn
  a LDUMAXB.new(rs, rt, rn.first, 1, 0)
end

#ldumaxah(rs, rt, rn) ⇒ Object



1559
1560
1561
# File 'lib/aarch64.rb', line 1559

def ldumaxah rs, rt, rn
  a LDUMAXH.new(rs, rt, rn.first, 1, 0)
end

#ldumaxal(rs, rt, rn) ⇒ Object



1535
1536
1537
# File 'lib/aarch64.rb', line 1535

def ldumaxal rs, rt, rn
  a LDUMAX.new(rs, rt, rn.first, rt.opc2, 1, 1)
end

#ldumaxalb(rs, rt, rn) ⇒ Object



1547
1548
1549
# File 'lib/aarch64.rb', line 1547

def ldumaxalb rs, rt, rn
  a LDUMAXB.new(rs, rt, rn.first, 1, 1)
end

#ldumaxalh(rs, rt, rn) ⇒ Object



1563
1564
1565
# File 'lib/aarch64.rb', line 1563

def ldumaxalh rs, rt, rn
  a LDUMAXH.new(rs, rt, rn.first, 1, 1)
end

#ldumaxb(rs, rt, rn) ⇒ Object



1551
1552
1553
# File 'lib/aarch64.rb', line 1551

def ldumaxb rs, rt, rn
  a LDUMAXB.new(rs, rt, rn.first, 0, 0)
end

#ldumaxh(rs, rt, rn) ⇒ Object



1567
1568
1569
# File 'lib/aarch64.rb', line 1567

def ldumaxh rs, rt, rn
  a LDUMAXH.new(rs, rt, rn.first, 0, 0)
end

#ldumaxl(rs, rt, rn) ⇒ Object



1539
1540
1541
# File 'lib/aarch64.rb', line 1539

def ldumaxl rs, rt, rn
  a LDUMAX.new(rs, rt, rn.first, rt.opc2, 0, 1)
end

#ldumaxlb(rs, rt, rn) ⇒ Object



1555
1556
1557
# File 'lib/aarch64.rb', line 1555

def ldumaxlb rs, rt, rn
  a LDUMAXB.new(rs, rt, rn.first, 0, 1)
end

#ldumaxlh(rs, rt, rn) ⇒ Object



1571
1572
1573
# File 'lib/aarch64.rb', line 1571

def ldumaxlh rs, rt, rn
  a LDUMAXH.new(rs, rt, rn.first, 0, 1)
end

#ldumin(rs, rt, rn) ⇒ Object



1575
1576
1577
# File 'lib/aarch64.rb', line 1575

def ldumin rs, rt, rn
  a LDUMIN.new(rs, rt, rn.first, rs.sizeb, 0, 0)
end

#ldumina(rs, rt, rn) ⇒ Object



1579
1580
1581
# File 'lib/aarch64.rb', line 1579

def ldumina rs, rt, rn
  a LDUMIN.new(rs, rt, rn.first, rs.sizeb, 1, 0)
end

#lduminab(rs, rt, rn) ⇒ Object



1591
1592
1593
# File 'lib/aarch64.rb', line 1591

def lduminab rs, rt, rn
  a LDUMINB.new(rs, rt, rn.first, 1, 0)
end

#lduminah(rs, rt, rn) ⇒ Object



1607
1608
1609
# File 'lib/aarch64.rb', line 1607

def lduminah rs, rt, rn
  a LDUMINH.new(rs, rt, rn.first, 1, 0)
end

#lduminal(rs, rt, rn) ⇒ Object



1583
1584
1585
# File 'lib/aarch64.rb', line 1583

def lduminal rs, rt, rn
  a LDUMIN.new(rs, rt, rn.first, rs.sizeb, 1, 1)
end

#lduminalb(rs, rt, rn) ⇒ Object



1595
1596
1597
# File 'lib/aarch64.rb', line 1595

def lduminalb rs, rt, rn
  a LDUMINB.new(rs, rt, rn.first, 1, 1)
end

#lduminalh(rs, rt, rn) ⇒ Object



1611
1612
1613
# File 'lib/aarch64.rb', line 1611

def lduminalh rs, rt, rn
  a LDUMINH.new(rs, rt, rn.first, 1, 1)
end

#lduminb(rs, rt, rn) ⇒ Object



1599
1600
1601
# File 'lib/aarch64.rb', line 1599

def lduminb rs, rt, rn
  a LDUMINB.new(rs, rt, rn.first, 0, 0)
end

#lduminh(rs, rt, rn) ⇒ Object



1615
1616
1617
# File 'lib/aarch64.rb', line 1615

def lduminh rs, rt, rn
  a LDUMINH.new(rs, rt, rn.first, 0, 0)
end

#lduminl(rs, rt, rn) ⇒ Object



1587
1588
1589
# File 'lib/aarch64.rb', line 1587

def lduminl rs, rt, rn
  a LDUMIN.new(rs, rt, rn.first, rs.sizeb, 0, 1)
end

#lduminlb(rs, rt, rn) ⇒ Object



1603
1604
1605
# File 'lib/aarch64.rb', line 1603

def lduminlb rs, rt, rn
  a LDUMINB.new(rs, rt, rn.first, 0, 1)
end

#lduminlh(rs, rt, rn) ⇒ Object



1619
1620
1621
# File 'lib/aarch64.rb', line 1619

def lduminlh rs, rt, rn
  a LDUMINH.new(rs, rt, rn.first, 0, 1)
end

#ldur(rt, rn) ⇒ Object



1639
1640
1641
# File 'lib/aarch64.rb', line 1639

def ldur rt, rn
  a LDUR_gen.new(rt, rn.first, rn[1] || 0, rt.opc2)
end

#ldurb(rt, rn) ⇒ Object



1643
1644
1645
# File 'lib/aarch64.rb', line 1643

def ldurb rt, rn
  a LDUR_gen.new(rt, rn.first, rn[1] || 0, 0b00)
end

#ldurh(rt, rn) ⇒ Object



1647
1648
1649
# File 'lib/aarch64.rb', line 1647

def ldurh rt, rn
  a LDUR_gen.new(rt, rn.first, rn[1] || 0, 0b01)
end

#ldursb(rt, rn) ⇒ Object



1623
1624
1625
# File 'lib/aarch64.rb', line 1623

def ldursb rt, rn
  a LDURSB.new(rt, rn.first, rn[1] || 0, rt.opc)
end

#ldursh(rt, rn) ⇒ Object



1627
1628
1629
# File 'lib/aarch64.rb', line 1627

def ldursh rt, rn
  a LDURSH.new(rt, rn.first, rn[1] || 0, rt.opc)
end

#ldursw(rt, rn) ⇒ Object



1631
1632
1633
# File 'lib/aarch64.rb', line 1631

def ldursw rt, rn
  a LDURSW.new(rt, rn.first, rn[1] || 0)
end

#ldxp(rt, rt2, rn) ⇒ Object



1635
1636
1637
# File 'lib/aarch64.rb', line 1635

def ldxp rt, rt2, rn
  a LDXP.new(rt, rt2, rn.first, rt.sf)
end

#ldxr(rt, rn) ⇒ Object



1651
1652
1653
# File 'lib/aarch64.rb', line 1651

def ldxr rt, rn
  a LDXR.new(rt, rn.first, rt.opc2)
end

#ldxrb(rt, rn) ⇒ Object



1655
1656
1657
# File 'lib/aarch64.rb', line 1655

def ldxrb rt, rn
  a LDXR.new(rt, rn.first, 0b00)
end

#ldxrh(rt, rn) ⇒ Object



1659
1660
1661
# File 'lib/aarch64.rb', line 1659

def ldxrh rt, rn
  a LDXR.new(rt, rn.first, 0b01)
end

#lsl(rd, rn, rm) ⇒ Object



1663
1664
1665
1666
1667
1668
1669
# File 'lib/aarch64.rb', line 1663

def lsl rd, rn, rm
  if rm.integer?
    ubfm rd, rn, -rm % rd.size, (rd.size - 1) - rm
  else
    lslv rd, rn, rm
  end
end

#lslv(rd, rn, rm) ⇒ Object



1671
1672
1673
# File 'lib/aarch64.rb', line 1671

def lslv rd, rn, rm
  a LSLV.new(rd, rn, rm, rd.sf)
end

#lsr(rd, rn, rm) ⇒ Object



1675
1676
1677
1678
1679
1680
1681
# File 'lib/aarch64.rb', line 1675

def lsr rd, rn, rm
  if rm.integer?
    ubfm rd, rn, rm, rd.size - 1
  else
    lsrv rd, rn, rm
  end
end

#lsrv(rd, rn, rm) ⇒ Object



1683
1684
1685
# File 'lib/aarch64.rb', line 1683

def lsrv rd, rn, rm
  a LSRV.new(rd, rn, rm, rd.sf)
end

#madd(rd, rn, rm, ra) ⇒ Object



1687
1688
1689
# File 'lib/aarch64.rb', line 1687

def madd rd, rn, rm, ra
  a MADD.new(rd, rn, rm, ra, rd.sf)
end

#make_label(name) ⇒ Object

Makes a new label with name. Place the label using the put_label method.



187
188
189
# File 'lib/aarch64.rb', line 187

def make_label name
  Label.new name
end

#mneg(rd, rn, rm) ⇒ Object



1691
1692
1693
# File 'lib/aarch64.rb', line 1691

def mneg rd, rn, rm
  msub rd, rn, rm, rd.zr
end

#mov(rd, rm) ⇒ Object



1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
# File 'lib/aarch64.rb', line 1695

def mov rd, rm
  if rm.integer?
    if rm < 0
      rm = ~rm
      if rm < 65536 || rm % 65536 == 0
        movn(rd, rm)
      else
        orr(rd, rd.zr, ~rm)
      end
    else
      if rm < 65536 || rm % 65536 == 0
        movz(rd, rm)
      else
        orr(rd, rd.zr, rm)
      end
    end
  else
    if rd.sp? || rm.sp?
      add rd, rm, 0
    else
      orr(rd, rd.zr, rm)
    end
  end
end

#movk(reg, imm, option = nil, lsl: 0) ⇒ Object



1742
1743
1744
1745
# File 'lib/aarch64.rb', line 1742

def movk reg, imm, option = nil, lsl: 0
  lsl = option.amount if option
  a MOVK.new(reg, imm, lsl / 16, reg.sf)
end

#movn(rd, imm, option = nil, lsl: 0) ⇒ Object



1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
# File 'lib/aarch64.rb', line 1720

def movn rd, imm, option = nil, lsl: 0
  lsl = option.amount if option

  lsl /= 16
  while imm > 65535
    lsl += 1
    imm >>= 16
  end
  a MOVN.new(rd, imm, lsl, rd.sf)
end

#movz(reg, imm, option = nil, lsl: 0) ⇒ Object



1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
# File 'lib/aarch64.rb', line 1731

def movz reg, imm, option = nil, lsl: 0
  lsl = option.amount if option

  lsl /= 16
  while imm > 65535
    lsl += 1
    imm >>= 16
  end
  a MOVZ.new(reg, imm, lsl, reg.sf)
end

#mrs(rt, reg) ⇒ Object



1747
1748
1749
1750
1751
1752
1753
1754
1755
# File 'lib/aarch64.rb', line 1747

def mrs rt, reg
  o0 = case reg.op0
       when 2 then 0
       when 3 then 1
       else
         raise
       end
  a MRS.new(o0, reg.op1, reg.CRn, reg.CRm, reg.op2, rt)
end

#msr(reg, rt) ⇒ Object



1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
# File 'lib/aarch64.rb', line 1757

def msr reg, rt
  if rt.integer?
    raise NotImplementedError
  else
    o0 = case reg.op0
         when 2 then 0
         when 3 then 1
         else
           raise
         end

    a MSR_reg.new(o0, reg.op1, reg.CRn, reg.CRm, reg.op2, rt)
  end
end

#msub(rd, rn, rm, ra) ⇒ Object



1772
1773
1774
# File 'lib/aarch64.rb', line 1772

def msub rd, rn, rm, ra
  a MSUB.new(rd, rn, rm, ra, rd.sf)
end

#mul(rd, rn, rm) ⇒ Object



1776
1777
1778
# File 'lib/aarch64.rb', line 1776

def mul rd, rn, rm
  madd rd, rn, rm, rd.zr
end

#mvn(rd, rm, option = nil, shift: :lsl, amount: 0) ⇒ Object



1780
1781
1782
# File 'lib/aarch64.rb', line 1780

def mvn rd, rm, option = nil, shift: :lsl, amount: 0
  orn rd, rd.zr, rm, option, shift: shift, amount: amount
end

#neg(rd, rm, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl) ⇒ Object



1784
1785
1786
# File 'lib/aarch64.rb', line 1784

def neg rd, rm, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl
  sub rd, rd.zr, rm, option, extend: extend, amount: amount, lsl: lsl, shift: shift
end

#negs(rd, rm, option = nil, shift: :lsl, amount: 0) ⇒ Object



1788
1789
1790
# File 'lib/aarch64.rb', line 1788

def negs rd, rm, option = nil, shift: :lsl, amount: 0
  subs rd, rd.zr, rm, option, shift: shift, amount: amount
end

#ngc(rd, rm) ⇒ Object



1792
1793
1794
# File 'lib/aarch64.rb', line 1792

def ngc rd, rm
  sbc rd, rd.zr, rm
end

#ngcs(rd, rm) ⇒ Object



1796
1797
1798
# File 'lib/aarch64.rb', line 1796

def ngcs rd, rm
  sbcs rd, rd.zr, rm
end

#nopObject



1800
1801
1802
# File 'lib/aarch64.rb', line 1800

def nop
  a NOP.new
end

#orn(rd, rn, rm, option = nil, shift: :lsl, amount: 0) ⇒ Object



1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
# File 'lib/aarch64.rb', line 1804

def orn rd, rn, rm, option = nil, shift: :lsl, amount: 0
  if option
    shift = option.name
    amount = option.amount
  end

  shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)

  a ORN_log_shift.new(rd, rn, rm, shift, amount, rd.sf)
end

#orr(rd, rn, rm, option = nil, shift: :lsl, amount: 0) ⇒ Object



1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
# File 'lib/aarch64.rb', line 1815

def orr rd, rn, rm, option = nil, shift: :lsl, amount: 0
  if rm.integer?
    encoding = Utils.encode_mask(rm, rd.size)
    a ORR_log_imm.new(rd, rn, encoding.n, encoding.immr, encoding.imms, rd.sf)
  else
    if option
      shift = option.name
      amount = option.amount
    end

    shift = [:lsl, :lsr, :asr, :ror].index(shift) || raise(NotImplementedError)

    a ORR_log_shift.new(rd, rn, rm, shift, amount, rd.sf)
  end
end

#pacda(xd, xn) ⇒ Object



1831
1832
1833
# File 'lib/aarch64.rb', line 1831

def pacda xd, xn
  a PACDA.new(xd, xn, 0)
end

#pacdb(xd, xn) ⇒ Object



1839
1840
1841
# File 'lib/aarch64.rb', line 1839

def pacdb xd, xn
  a PACDB.new(xd, xn, 0)
end

#pacdza(xd) ⇒ Object



1835
1836
1837
# File 'lib/aarch64.rb', line 1835

def pacdza xd
  a PACDA.new(xd, xd.zr, 1)
end

#pacdzb(xd) ⇒ Object



1843
1844
1845
# File 'lib/aarch64.rb', line 1843

def pacdzb xd
  a PACDB.new(xd, xd.zr, 1)
end

#pacga(xd, xn, xm) ⇒ Object



1847
1848
1849
# File 'lib/aarch64.rb', line 1847

def pacga xd, xn, xm
  a PACGA.new(xd, xn, xm)
end

#pacia(xd, xn) ⇒ Object



1851
1852
1853
# File 'lib/aarch64.rb', line 1851

def pacia xd, xn
  a PACIA.new(xd, xn, 0)
end

#pacia1716Object



1859
1860
1861
# File 'lib/aarch64.rb', line 1859

def pacia1716
  a PACIA2.new(0b0001, 0b000)
end

#paciaspObject



1863
1864
1865
# File 'lib/aarch64.rb', line 1863

def paciasp
  a PACIA2.new(0b0011, 0b001)
end

#paciazObject



1867
1868
1869
# File 'lib/aarch64.rb', line 1867

def paciaz
  a PACIA2.new(0b0011, 0b000)
end

#pacib(xd, xn) ⇒ Object



1871
1872
1873
# File 'lib/aarch64.rb', line 1871

def pacib xd, xn
  a PACIB.new(xd, xn, 0)
end

#pacib1716Object



1879
1880
1881
# File 'lib/aarch64.rb', line 1879

def pacib1716
  a PACIA2.new(0b0001, 0b010)
end

#pacibspObject



1883
1884
1885
# File 'lib/aarch64.rb', line 1883

def pacibsp
  a PACIA2.new(0b0011, 0b011)
end

#pacibzObject



1887
1888
1889
# File 'lib/aarch64.rb', line 1887

def pacibz
  a PACIA2.new(0b0011, 0b010)
end

#paciza(xd) ⇒ Object



1855
1856
1857
# File 'lib/aarch64.rb', line 1855

def paciza xd
  a PACIA.new(xd, xd.zr, 1)
end

#pacizb(xd) ⇒ Object



1875
1876
1877
# File 'lib/aarch64.rb', line 1875

def pacizb xd
  a PACIB.new(xd, xd.zr, 1)
end

#patch_location {|@insns.length * 4| ... } ⇒ Object

Yields the offset in the instructions

Yields:

  • (@insns.length * 4)


2848
2849
2850
# File 'lib/aarch64.rb', line 2848

def patch_location
  yield @insns.length * 4
end

#pretty(&block) ⇒ Object

Creates a DSL object so you can write prettier assembly. For example:

asm = AArch64::Assembler.new
asm.pretty do
  asm.movz x0, 42
  asm.ret
end


181
182
183
# File 'lib/aarch64.rb', line 181

def pretty &block
  DSL.new.instance_eval(&block)
end

#prfm(rt, xn) ⇒ Object



1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
# File 'lib/aarch64.rb', line 1891

def prfm rt, xn
  if rt.is_a?(Symbol)
    rt = Utils.prfop(rt)
  end

  if xn.is_a?(Array)
    xn, rm, option = *xn
    rm ||= 0
    if rm.integer?
      a PRFM_imm.new(rt, xn, rm / 8)
    else
      shift = case option.name
              when :uxtw then 0b010
              when :lsl  then 0b011
              when :sxtw then 0b110
              when :sxtx then 0b111
              else
                raise option.name
              end
      a PRFM_reg.new(rt, xn, rm, shift, (option.amount || 0) / 3)
    end
  else
    if xn.integer?
      xn = wrap_offset_with_label xn
    end

    a PRFM_lit.new(rt, xn)
  end
end

#prfum(rt, rn) ⇒ Object



1921
1922
1923
1924
1925
1926
# File 'lib/aarch64.rb', line 1921

def prfum rt, rn
  if rt.is_a?(Symbol)
    rt = Utils.prfop(rt)
  end
  a PRFUM.new(rt, rn.first, rn[1] || 0)
end

#psb(_) ⇒ Object



1928
1929
1930
# File 'lib/aarch64.rb', line 1928

def psb _
  a PSB.new
end

#pssbbObject



1932
1933
1934
# File 'lib/aarch64.rb', line 1932

def pssbb
  dsb 4
end

#put_label(label) ⇒ Object

Puts the label at the current position. Labels can only be placed once.



192
193
194
195
# File 'lib/aarch64.rb', line 192

def put_label label
  label.set_offset(@insns.length)
  self
end

#rbit(rd, rn) ⇒ Object



1936
1937
1938
# File 'lib/aarch64.rb', line 1936

def rbit rd, rn
  a RBIT_int.new(rd, rn, rd.sf)
end

#ret(reg = X30) ⇒ Object



1940
1941
1942
# File 'lib/aarch64.rb', line 1940

def ret reg = X30
  a RET.new(reg)
end

#retaaObject



1944
1945
1946
# File 'lib/aarch64.rb', line 1944

def retaa
  a RETA.new(0)
end

#retabObject



1948
1949
1950
# File 'lib/aarch64.rb', line 1948

def retab
  a RETA.new(1)
end

#rev(rd, rn) ⇒ Object Also known as: rev64



1952
1953
1954
# File 'lib/aarch64.rb', line 1952

def rev rd, rn
  a REV.new(rd, rn, rd.sf, rd.opc2)
end

#rev16(rd, rn) ⇒ Object



1956
1957
1958
# File 'lib/aarch64.rb', line 1956

def rev16 rd, rn
  a REV.new(rd, rn, rd.sf, 0b01)
end

#rev32(rd, rn) ⇒ Object



1960
1961
1962
# File 'lib/aarch64.rb', line 1960

def rev32 rd, rn
  a REV.new(rd, rn, rd.sf, 0b10)
end

#rmif(rn, shift, mask) ⇒ Object



1966
1967
1968
# File 'lib/aarch64.rb', line 1966

def rmif rn, shift, mask
  a RMIF.new(rn, shift, mask)
end

#ror(rd, rs, shift) ⇒ Object



1970
1971
1972
1973
1974
1975
1976
# File 'lib/aarch64.rb', line 1970

def ror rd, rs, shift
  if shift.integer?
    extr rd, rs, rs, shift
  else
    rorv rd, rs, shift
  end
end

#rorv(rd, rn, rm) ⇒ Object



1978
1979
1980
# File 'lib/aarch64.rb', line 1978

def rorv rd, rn, rm
  a RORV.new(rd, rn, rm, rd.sf)
end

#sbObject



1982
1983
1984
# File 'lib/aarch64.rb', line 1982

def sb
  a SB.new
end

#sbc(rd, rn, rm) ⇒ Object



1986
1987
1988
# File 'lib/aarch64.rb', line 1986

def sbc rd, rn, rm
  a SBC.new(rd, rn, rm, rd.sf)
end

#sbcs(rd, rn, rm) ⇒ Object



1990
1991
1992
# File 'lib/aarch64.rb', line 1990

def sbcs rd, rn, rm
  a SBCS.new(rd, rn, rm, rd.sf)
end

#sbfiz(rd, rn, lsb, width) ⇒ Object



1994
1995
1996
# File 'lib/aarch64.rb', line 1994

def sbfiz rd, rn, lsb, width
  sbfm rd, rn, -lsb % rd.size, width - 1
end

#sbfm(d, n, immr, imms) ⇒ Object



1998
1999
2000
# File 'lib/aarch64.rb', line 1998

def sbfm d, n, immr, imms
  a SBFM.new(d, n, immr, imms, d.sf)
end

#sbfx(rd, rn, lsb, width) ⇒ Object



2002
2003
2004
# File 'lib/aarch64.rb', line 2002

def sbfx rd, rn, lsb, width
  sbfm rd, rn, lsb, lsb + width - 1
end

#sdiv(rd, rn, rm) ⇒ Object



2006
2007
2008
# File 'lib/aarch64.rb', line 2006

def sdiv rd, rn, rm
  a SDIV.new(rd, rn, rm, rd.sf)
end

#setf16(rn) ⇒ Object



2014
2015
2016
# File 'lib/aarch64.rb', line 2014

def setf16 rn
  a SETF.new(rn, 1)
end

#setf8(rn) ⇒ Object



2010
2011
2012
# File 'lib/aarch64.rb', line 2010

def setf8 rn
  a SETF.new(rn, 0)
end

#sevObject



2018
2019
2020
# File 'lib/aarch64.rb', line 2018

def sev
  a SEV.new
end

#sevlObject



2022
2023
2024
# File 'lib/aarch64.rb', line 2022

def sevl
  a SEVL.new
end

#smaddl(xd, wn, wm, xa) ⇒ Object



2026
2027
2028
# File 'lib/aarch64.rb', line 2026

def smaddl xd, wn, wm, xa
  a SMADDL.new(xd, wn, wm, xa)
end

#smc(imm) ⇒ Object



2030
2031
2032
# File 'lib/aarch64.rb', line 2030

def smc imm
  a SMC.new(imm)
end

#smnegl(rd, rn, rm) ⇒ Object



2034
2035
2036
# File 'lib/aarch64.rb', line 2034

def smnegl rd, rn, rm
  smsubl rd, rn, rm, XZR
end

#smsubl(rd, rn, rm, ra) ⇒ Object



2038
2039
2040
# File 'lib/aarch64.rb', line 2038

def smsubl rd, rn, rm, ra
  a SMSUBL.new(rd, rn, rm, ra)
end

#smulh(rd, rn, rm) ⇒ Object



2042
2043
2044
# File 'lib/aarch64.rb', line 2042

def smulh rd, rn, rm
  a SMULH.new(rd, rn, rm)
end

#smull(rd, rn, rm) ⇒ Object



2046
2047
2048
# File 'lib/aarch64.rb', line 2046

def smull rd, rn, rm
  smaddl rd, rn, rm, XZR
end

#ssbbObject



2050
2051
2052
# File 'lib/aarch64.rb', line 2050

def ssbb
  dsb 0
end

#st2g(rt, rn, imm = nil) ⇒ Object



2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
# File 'lib/aarch64.rb', line 2054

def st2g rt, rn, imm = nil
  if imm
    if imm == :!
      # Pre index
      a ST2G.new(rt, rn.first, (rn[1] || 0) / 16, 0b11)
    else
      # Post index
      a ST2G.new(rt, rn.first, (imm || 0) / 16, 0b01)
    end
  else
    # Signed offset
    a ST2G.new(rt, rn.first, (rn[1] || 0) / 16, 0b10)
  end
end

#st64b(rt, rn) ⇒ Object



2069
2070
2071
# File 'lib/aarch64.rb', line 2069

def st64b rt, rn
  a ST64B.new(rt, rn.first)
end

#st64bv(rs, rt, rn) ⇒ Object



2073
2074
2075
# File 'lib/aarch64.rb', line 2073

def st64bv rs, rt, rn
  a ST64BV.new(rs, rt, rn.first)
end

#st64bv0(rs, rt, rn) ⇒ Object



2077
2078
2079
# File 'lib/aarch64.rb', line 2077

def st64bv0 rs, rt, rn
  a ST64BV0.new(rs, rt, rn.first)
end

#stadd(rs, rn) ⇒ Object



2081
2082
2083
# File 'lib/aarch64.rb', line 2081

def stadd rs, rn
  ldadd rs, rs.zr, rn
end

#staddb(rs, rn) ⇒ Object



2089
2090
2091
# File 'lib/aarch64.rb', line 2089

def staddb rs, rn
  ldaddb rs, rs.zr, rn
end

#staddh(rs, rn) ⇒ Object



2097
2098
2099
# File 'lib/aarch64.rb', line 2097

def staddh rs, rn
  ldaddh rs, rs.zr, rn
end

#staddl(rs, rn) ⇒ Object



2085
2086
2087
# File 'lib/aarch64.rb', line 2085

def staddl rs, rn
  ldaddl rs, rs.zr, rn
end

#staddlb(rs, rn) ⇒ Object



2093
2094
2095
# File 'lib/aarch64.rb', line 2093

def staddlb rs, rn
  ldaddlb rs, rs.zr, rn
end

#staddlh(rs, rn) ⇒ Object



2101
2102
2103
# File 'lib/aarch64.rb', line 2101

def staddlh rs, rn
  ldaddlh rs, rs.zr, rn
end

#stclr(rs, rn) ⇒ Object



2105
2106
2107
# File 'lib/aarch64.rb', line 2105

def stclr rs, rn
  ldclr rs, rs.zr, rn
end

#stclrb(rs, rn) ⇒ Object



2113
2114
2115
# File 'lib/aarch64.rb', line 2113

def stclrb rs, rn
  ldclrb rs, rs.zr, rn
end

#stclrh(rs, rn) ⇒ Object



2121
2122
2123
# File 'lib/aarch64.rb', line 2121

def stclrh rs, rn
  ldclrh rs, rs.zr, rn
end

#stclrl(rs, rn) ⇒ Object



2109
2110
2111
# File 'lib/aarch64.rb', line 2109

def stclrl rs, rn
  ldclrl rs, rs.zr, rn
end

#stclrlb(rs, rn) ⇒ Object



2117
2118
2119
# File 'lib/aarch64.rb', line 2117

def stclrlb rs, rn
  ldclrlb rs, rs.zr, rn
end

#stclrlh(rs, rn) ⇒ Object



2125
2126
2127
# File 'lib/aarch64.rb', line 2125

def stclrlh rs, rn
  ldclrlh rs, rs.zr, rn
end

#steor(rs, rn) ⇒ Object



2129
2130
2131
# File 'lib/aarch64.rb', line 2129

def steor rs, rn
  ldeor rs, rs.zr, rn
end

#steorb(rs, rn) ⇒ Object



2137
2138
2139
# File 'lib/aarch64.rb', line 2137

def steorb rs, rn
  ldeorb rs, rs.zr, rn
end

#steorh(rs, rn) ⇒ Object



2145
2146
2147
# File 'lib/aarch64.rb', line 2145

def steorh rs, rn
  ldeorh rs, rs.zr, rn
end

#steorl(rs, rn) ⇒ Object



2133
2134
2135
# File 'lib/aarch64.rb', line 2133

def steorl rs, rn
  ldeorl rs, rs.zr, rn
end

#steorlb(rs, rn) ⇒ Object



2141
2142
2143
# File 'lib/aarch64.rb', line 2141

def steorlb rs, rn
  ldeorlb rs, rs.zr, rn
end

#steorlh(rs, rn) ⇒ Object



2149
2150
2151
# File 'lib/aarch64.rb', line 2149

def steorlh rs, rn
  ldeorlh rs, rs.zr, rn
end

#stg(rt, rn, imm = nil) ⇒ Object



2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
# File 'lib/aarch64.rb', line 2153

def stg rt, rn, imm = nil
  if imm
    if imm == :!
      # Pre index
      a STG.new(rt, rn.first, (rn[1] || 0) / 16, 0b11)
    else
      # Post index
      a STG.new(rt, rn.first, (imm || 0) / 16, 0b01)
    end
  else
    # Signed offset
    a STG.new(rt, rn.first, (rn[1] || 0) / 16, 0b10)
  end
end

#stgm(rt, rn) ⇒ Object



2168
2169
2170
# File 'lib/aarch64.rb', line 2168

def stgm rt, rn
  a STGM.new(rt, rn.first)
end

#stgp(xt1, xt2, xn, imm = nil) ⇒ Object



2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
# File 'lib/aarch64.rb', line 2172

def stgp xt1, xt2, xn, imm = nil
  if imm
    if imm == :!
      # Pre index
      a STGP.new(xt1, xt2, xn.first, (xn[1] || 0) / 16, 0b011)
    else
      # Post index
      a STGP.new(xt1, xt2, xn.first, imm / 16, 0b001)
    end
  else
    # Signed offset
    a STGP.new(xt1, xt2, xn.first, (xn[1] || 0) / 16, 0b010)
  end
end

#stllr(rt, rn) ⇒ Object



2187
2188
2189
# File 'lib/aarch64.rb', line 2187

def stllr rt, rn
  a STLLR.new(rt, rn.first, rt.sizeb)
end

#stllrb(rt, rn) ⇒ Object



2191
2192
2193
# File 'lib/aarch64.rb', line 2191

def stllrb rt, rn
  a STLLRB.new(rt, rn.first)
end

#stllrh(rt, rn) ⇒ Object



2195
2196
2197
# File 'lib/aarch64.rb', line 2195

def stllrh rt, rn
  a STLLRH.new(rt, rn.first)
end

#stlr(rt, rn) ⇒ Object



2199
2200
2201
# File 'lib/aarch64.rb', line 2199

def stlr rt, rn
  a STLR.new(rt, rn.first, rt.sizeb)
end

#stlrb(rt, rn) ⇒ Object



2203
2204
2205
# File 'lib/aarch64.rb', line 2203

def stlrb rt, rn
  a STLRB.new(rt, rn.first)
end

#stlrh(rt, rn) ⇒ Object



2207
2208
2209
# File 'lib/aarch64.rb', line 2207

def stlrh rt, rn
  a STLRH.new(rt, rn.first)
end

#stlur(rt, rn) ⇒ Object



2211
2212
2213
# File 'lib/aarch64.rb', line 2211

def stlur rt, rn
  a STLUR_gen.new(rt, rn.first, rn[1] || 0, rt.sizeb)
end

#stlurb(rt, rn) ⇒ Object



2215
2216
2217
# File 'lib/aarch64.rb', line 2215

def stlurb rt, rn
  a STLUR_gen.new(rt, rn.first, rn[1] || 0, 0b00)
end

#stlurh(rt, rn) ⇒ Object



2219
2220
2221
# File 'lib/aarch64.rb', line 2219

def stlurh rt, rn
  a STLUR_gen.new(rt, rn.first, rn[1] || 0, 0b01)
end

#stlxp(rs, rt, rt2, rn) ⇒ Object



2223
2224
2225
# File 'lib/aarch64.rb', line 2223

def stlxp rs, rt, rt2, rn
  a STLXP.new(rs, rt, rt2, rn.first, rt.sz)
end

#stlxr(rs, rt, rn) ⇒ Object



2227
2228
2229
# File 'lib/aarch64.rb', line 2227

def stlxr rs, rt, rn
  a STLXR.new(rs, rt, rn.first, rt.sizeb)
end

#stlxrb(rs, rt, rn) ⇒ Object



2231
2232
2233
# File 'lib/aarch64.rb', line 2231

def stlxrb rs, rt, rn
  a STLXRB.new(rs, rt, rn.first)
end

#stlxrh(rs, rt, rn) ⇒ Object



2235
2236
2237
# File 'lib/aarch64.rb', line 2235

def stlxrh rs, rt, rn
  a STLXRH.new(rs, rt, rn.first)
end

#stnp(rt, rt2, rn) ⇒ Object



2239
2240
2241
# File 'lib/aarch64.rb', line 2239

def stnp rt, rt2, rn
  a STNP_gen.new(rt, rt2, rn.first, (rn[1] || 0) / (rt.size / 8), rt.opc3)
end

#stp(rt, rt2, rn, imm = nil) ⇒ Object



2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
# File 'lib/aarch64.rb', line 2243

def stp rt, rt2, rn, imm = nil
  div = rt.size / 8

  if imm
    if imm == :!
      # Pre index
      a STP_gen.new(rt, rt2, rn.first, (rn[1] || 0) / div, rt.opc3, 0b011)
    else
      # Post index
      a STP_gen.new(rt, rt2, rn.first, imm / div, rt.opc3, 0b001)
    end
  else
    # Signed offset
    a STP_gen.new(rt, rt2, rn.first, (rn[1] || 0) / div, rt.opc3, 0b010)
  end
end

#str(rt, rn, imm = nil) ⇒ Object



2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
# File 'lib/aarch64.rb', line 2260

def str rt, rn, imm = nil
  if imm
    if imm == :!
      # Post index
      a STR_imm_gen.new(rt, rn.first, rn[1] || 0, 0b11, rt.sizeb)
    else
      # Pre index
      a STR_imm_gen.new(rt, rn.first, imm || 0, 0b01, rt.sizeb)
    end
  else
    imm = rn[1] || 0
    if imm.integer?
      # Unsigned
      div = rt.size / 8
      a STR_imm_unsigned.new(rt, rn.first, imm / div, rt.sizeb)
    else
      rn, rm, opt = *rn
      opt ||= Extends::Extend.new(0, 0, :lsl)
      extend = case opt.name
               when :uxtw then 0b010
               when :lsl  then 0b011
               when :sxtw then 0b110
               when :sxtx then 0b111
               else
                 raise "Unknown type #{opt.name}"
               end

      amount = (opt.amount || 0) / (rt.x? ? 3 : 2)
      a STR_reg_gen.new(rt, rn, rm, extend, amount, rt.sizeb)
    end
  end
end

#strb(rt, rn, imm = nil) ⇒ Object



2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
# File 'lib/aarch64.rb', line 2293

def strb rt, rn, imm = nil
  if imm
    if imm == :!
      # Post index
      a STRB_imm.new(rt, rn.first, rn[1] || 0, 0b11)
    else
      # Pre index
      a STRB_imm.new(rt, rn.first, imm, 0b01)
    end
  else
    imm = rn[1] || 0
    if imm.integer?
      # Unsigned
      a STRB_imm_unsigned.new(rt, rn.first, imm)
    else
      amount = rn[2] ? 1 : 0

      rn, rm, opt = *rn
      opt ||= Extends::Extend.new(0, 0, :lsl)
      extend = case opt.name
               when :uxtw then 0b010
               when :lsl  then 0b011
               when :sxtw then 0b110
               when :sxtx then 0b111
               else
                 raise "Unknown type #{opt.name}"
               end

      a STRB_reg.new(rt, rn, rm, extend, amount)
    end
  end
end

#strh(rt, rn, imm = nil) ⇒ Object



2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
# File 'lib/aarch64.rb', line 2326

def strh rt, rn, imm = nil
  if imm
    if imm == :!
      # Pre index
      a STRH_imm.new(rt, rn.first, rn[1] || 0, 0b11)
    else
      # Post index
      a STRH_imm.new(rt, rn.first, imm, 0b01)
    end
  else
    imm = rn[1] || 0
    if imm.integer?
      # Unsigned
      a STRH_imm_unsigned.new(rt, rn.first, imm >> 1)
    else
      rn, rm, opt = *rn
      opt ||= Extends::Extend.new(0, 0, :lsl)
      extend = case opt.name
               when :uxtw then 0b010
               when :lsl  then 0b011
               when :sxtw then 0b110
               when :sxtx then 0b111
               else
                 raise "Unknown type #{opt.name}"
               end

      amount = (opt.amount || 0) > 0 ? 1 : 0

      a STRH_reg.new(rt, rn, rm, extend, amount)
    end
  end
end

#stset(rs, rn) ⇒ Object



2359
2360
2361
# File 'lib/aarch64.rb', line 2359

def stset rs, rn
  ldset rs, rs.zr, rn
end

#stsetb(rs, rn) ⇒ Object



2367
2368
2369
# File 'lib/aarch64.rb', line 2367

def stsetb rs, rn
  ldsetb rs, rs.zr, rn
end

#stseth(rs, rn) ⇒ Object



2375
2376
2377
# File 'lib/aarch64.rb', line 2375

def stseth rs, rn
  ldseth rs, rs.zr, rn
end

#stsetl(rs, rn) ⇒ Object



2363
2364
2365
# File 'lib/aarch64.rb', line 2363

def stsetl rs, rn
  ldsetl rs, rs.zr, rn
end

#stsetlb(rs, rn) ⇒ Object



2371
2372
2373
# File 'lib/aarch64.rb', line 2371

def stsetlb rs, rn
  ldsetlb rs, rs.zr, rn
end

#stsetlh(rs, rn) ⇒ Object



2379
2380
2381
# File 'lib/aarch64.rb', line 2379

def stsetlh rs, rn
  ldsetlh rs, rs.zr, rn
end

#stsmax(rs, rn) ⇒ Object



2383
2384
2385
# File 'lib/aarch64.rb', line 2383

def stsmax rs, rn
  ldsmax rs, rs.zr, rn
end

#stsmaxb(rs, rn) ⇒ Object



2391
2392
2393
# File 'lib/aarch64.rb', line 2391

def stsmaxb rs, rn
  ldsmaxb rs, rs.zr, rn
end

#stsmaxh(rs, rn) ⇒ Object



2399
2400
2401
# File 'lib/aarch64.rb', line 2399

def stsmaxh rs, rn
  ldsmaxh rs, rs.zr, rn
end

#stsmaxl(rs, rn) ⇒ Object



2387
2388
2389
# File 'lib/aarch64.rb', line 2387

def stsmaxl rs, rn
  ldsmaxl rs, rs.zr, rn
end

#stsmaxlb(rs, rn) ⇒ Object



2395
2396
2397
# File 'lib/aarch64.rb', line 2395

def stsmaxlb rs, rn
  ldsmaxlb rs, rs.zr, rn
end

#stsmaxlh(rs, rn) ⇒ Object



2403
2404
2405
# File 'lib/aarch64.rb', line 2403

def stsmaxlh rs, rn
  ldsmaxlh rs, rs.zr, rn
end

#stsmin(rs, rn) ⇒ Object



2407
2408
2409
# File 'lib/aarch64.rb', line 2407

def stsmin rs, rn
  ldsmin rs, rs.zr, rn
end

#stsminb(rs, rn) ⇒ Object



2415
2416
2417
# File 'lib/aarch64.rb', line 2415

def stsminb rs, rn
  ldsminb rs, rs.zr, rn
end

#stsminh(rs, rn) ⇒ Object



2423
2424
2425
# File 'lib/aarch64.rb', line 2423

def stsminh rs, rn
  ldsminh rs, rs.zr, rn
end

#stsminl(rs, rn) ⇒ Object



2411
2412
2413
# File 'lib/aarch64.rb', line 2411

def stsminl rs, rn
  ldsminl rs, rs.zr, rn
end

#stsminlb(rs, rn) ⇒ Object



2419
2420
2421
# File 'lib/aarch64.rb', line 2419

def stsminlb rs, rn
  ldsminlb rs, rs.zr, rn
end

#stsminlh(rs, rn) ⇒ Object



2427
2428
2429
# File 'lib/aarch64.rb', line 2427

def stsminlh rs, rn
  ldsminlh rs, rs.zr, rn
end

#sttr(rt, rn) ⇒ Object



2431
2432
2433
# File 'lib/aarch64.rb', line 2431

def sttr rt, rn
  a STTR.new(rt, rn.first, rn[1] || 0, rt.sizeb)
end

#sttrb(rt, rn) ⇒ Object



2435
2436
2437
# File 'lib/aarch64.rb', line 2435

def sttrb rt, rn
  a STTR.new(rt, rn.first, rn[1] || 0, 0b00)
end

#sttrh(rt, rn) ⇒ Object



2439
2440
2441
# File 'lib/aarch64.rb', line 2439

def sttrh rt, rn
  a STTR.new(rt, rn.first, rn[1] || 0, 0b01)
end

#stumax(rs, rn) ⇒ Object



2443
2444
2445
# File 'lib/aarch64.rb', line 2443

def stumax rs, rn
  ldumax rs, rs.zr, rn
end

#stumaxb(rs, rn) ⇒ Object



2451
2452
2453
# File 'lib/aarch64.rb', line 2451

def stumaxb rs, rn
  ldumaxb rs, rs.zr, rn
end

#stumaxh(rs, rn) ⇒ Object



2459
2460
2461
# File 'lib/aarch64.rb', line 2459

def stumaxh rs, rn
  ldumaxh rs, rs.zr, rn
end

#stumaxl(rs, rn) ⇒ Object



2447
2448
2449
# File 'lib/aarch64.rb', line 2447

def stumaxl rs, rn
  ldumaxl rs, rs.zr, rn
end

#stumaxlb(rs, rn) ⇒ Object



2455
2456
2457
# File 'lib/aarch64.rb', line 2455

def stumaxlb rs, rn
  ldumaxlb rs, rs.zr, rn
end

#stumaxlh(rs, rn) ⇒ Object



2463
2464
2465
# File 'lib/aarch64.rb', line 2463

def stumaxlh rs, rn
  ldumaxlh rs, rs.zr, rn
end

#stumin(rs, rn) ⇒ Object



2467
2468
2469
# File 'lib/aarch64.rb', line 2467

def stumin rs, rn
  ldumin rs, rs.zr, rn
end

#stuminb(rs, rn) ⇒ Object



2475
2476
2477
# File 'lib/aarch64.rb', line 2475

def stuminb rs, rn
  lduminb rs, rs.zr, rn
end

#stuminh(rs, rn) ⇒ Object



2483
2484
2485
# File 'lib/aarch64.rb', line 2483

def stuminh rs, rn
  lduminh rs, rs.zr, rn
end

#stuminl(rs, rn) ⇒ Object



2471
2472
2473
# File 'lib/aarch64.rb', line 2471

def stuminl rs, rn
  lduminl rs, rs.zr, rn
end

#stuminlb(rs, rn) ⇒ Object



2479
2480
2481
# File 'lib/aarch64.rb', line 2479

def stuminlb rs, rn
  lduminlb rs, rs.zr, rn
end

#stuminlh(rs, rn) ⇒ Object



2487
2488
2489
# File 'lib/aarch64.rb', line 2487

def stuminlh rs, rn
  lduminlh rs, rs.zr, rn
end

#stur(rt, rn) ⇒ Object



2491
2492
2493
# File 'lib/aarch64.rb', line 2491

def stur rt, rn
  a STUR_gen.new(rt, rn.first, rn[1] || 0, rt.sizeb)
end

#sturb(rt, rn) ⇒ Object



2495
2496
2497
# File 'lib/aarch64.rb', line 2495

def sturb rt, rn
  a STUR_gen.new(rt, rn.first, rn[1] || 0, 0b00)
end

#sturh(rt, rn) ⇒ Object



2499
2500
2501
# File 'lib/aarch64.rb', line 2499

def sturh rt, rn
  a STUR_gen.new(rt, rn.first, rn[1] || 0, 0b01)
end

#stxp(rs, rt1, rt2, rn) ⇒ Object



2503
2504
2505
# File 'lib/aarch64.rb', line 2503

def stxp rs, rt1, rt2, rn
  a STXP.new(rs, rt1, rt2, rn.first, rt1.sf)
end

#stxr(rs, rt, rn) ⇒ Object



2507
2508
2509
# File 'lib/aarch64.rb', line 2507

def stxr rs, rt, rn
  a STXR.new(rs, rt, rn.first, rt.opc2)
end

#stxrb(rs, rt, rn) ⇒ Object



2511
2512
2513
# File 'lib/aarch64.rb', line 2511

def stxrb rs, rt, rn
  a STXRB.new(rs, rt, rn.first)
end

#stxrh(rs, rt, rn) ⇒ Object



2515
2516
2517
# File 'lib/aarch64.rb', line 2515

def stxrh rs, rt, rn
  a STXRH.new(rs, rt, rn.first)
end

#stz2g(rt, rn, imm = nil) ⇒ Object



2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
# File 'lib/aarch64.rb', line 2519

def stz2g rt, rn, imm = nil
  if imm
    if imm == :!
      # Pre index
      a STZ2G.new(rt, rn.first, (rn[1] || 0) / 16, 0b11)
    else
      a STZ2G.new(rt, rn.first, imm / 16, 0b01)
    end
  else
    # Signed offset
    a STZ2G.new(rt, rn.first, (rn[1] || 0) / 16, 0b10)
  end
end

#stzg(rt, rn, imm = nil) ⇒ Object



2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
# File 'lib/aarch64.rb', line 2533

def stzg rt, rn, imm = nil
  if imm
    if imm == :!
      # Pre index
      a STZG.new(rt, rn.first, (rn[1] || 0) / 16, 0b11)
    else
      a STZG.new(rt, rn.first, imm / 16, 0b01)
    end
  else
    # Signed offset
    a STZG.new(rt, rn.first, (rn[1] || 0) / 16, 0b10)
  end
end

#stzgm(rt, rn) ⇒ Object



2547
2548
2549
# File 'lib/aarch64.rb', line 2547

def stzgm rt, rn
  a STZGM.new(rt, rn.first)
end

#sub(d, n, m, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl) ⇒ Object



2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
# File 'lib/aarch64.rb', line 2591

def sub d, n, m, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl
  if (d.sp? || n.sp?) && !m.integer?
    if n.x?
      extend ||= :uxtx
    else
      extend ||= :uxtw
    end
  end

  if option
    if option.extend?
      extend = option.name
      amount = option.amount
    else
      if m.integer?
        lsl = option.amount
      else
        shift = option.name
        amount = option.amount
      end
    end
  end

  if extend
    extend = if m.x?
               Utils.sub_decode_extend64(extend)
             else
               Utils.sub_decode_extend32(extend)
             end
    a SUB_addsub_ext.new(d, n, m, extend, amount, d.sf)
  else
    if m.integer?
      a SUB_addsub_imm.new(d, n, m, (lsl || 0) / 12, d.sf)
    else
      shift = [:lsl, :lsr, :asr].index(shift) || raise(NotImplementedError)
      a SUB_addsub_shift.new(d, n, m, shift, amount, d.sf)
    end
  end
end

#subg(xd, xn, uimm6, uimm4) ⇒ Object

Raises:

  • (NotImplementedError)


2631
2632
2633
2634
# File 'lib/aarch64.rb', line 2631

def subg xd, xn, uimm6, uimm4
  raise NotImplementedError unless xd.x?
  a SUBG.new(xd, xn, uimm6, uimm4)
end

#subp(xd, xn, xm) ⇒ Object

Raises:

  • (NotImplementedError)


2636
2637
2638
2639
# File 'lib/aarch64.rb', line 2636

def subp xd, xn, xm
  raise NotImplementedError unless xd.x?
  a SUBP.new(xd, xn, xm)
end

#subps(xd, xn, xm) ⇒ Object

Raises:

  • (NotImplementedError)


2641
2642
2643
2644
# File 'lib/aarch64.rb', line 2641

def subps xd, xn, xm
  raise NotImplementedError unless xd.x?
  a SUBPS.new(xd, xn, xm)
end

#subs(d, n, m, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl) ⇒ Object



2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
# File 'lib/aarch64.rb', line 2551

def subs d, n, m, option = nil, extend: nil, amount: 0, lsl: 0, shift: :lsl
  if n.sp? && !m.integer?
    if n.x?
      extend ||= :uxtx
    else
      extend ||= :uxtw
    end
  end

  if option
    if option.extend?
      extend = option.name
      amount = option.amount
    else
      if m.integer?
        lsl = option.amount
      else
        shift = option.name
        amount = option.amount
      end
    end
  end

  if extend
    extend = if m.x?
               Utils.sub_decode_extend64(extend)
             else
               Utils.sub_decode_extend32(extend)
             end
    a SUBS_addsub_ext.new(d, n, m, extend, amount, d.sf)
  else
    if m.integer?
      a SUBS_addsub_imm.new(d, n, m, lsl / 12, d.sf)
    else
      shift = [:lsl, :lsr, :asr].index(shift) || raise(NotImplementedError)
      a SUBS_addsub_shift.new(d, n, m, shift, amount, d.sf)
    end
  end
end

#svc(imm) ⇒ Object



2646
2647
2648
# File 'lib/aarch64.rb', line 2646

def svc imm
  a SVC.new(imm)
end

#swp(rs, rt, rn) ⇒ Object



2650
2651
2652
# File 'lib/aarch64.rb', line 2650

def swp rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 0, 0)
end

#swpa(rs, rt, rn) ⇒ Object



2662
2663
2664
# File 'lib/aarch64.rb', line 2662

def swpa rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 1, 0)
end

#swpab(rs, rt, rn) ⇒ Object



2666
2667
2668
# File 'lib/aarch64.rb', line 2666

def swpab rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 1, 0)
end

#swpah(rs, rt, rn) ⇒ Object



2682
2683
2684
# File 'lib/aarch64.rb', line 2682

def swpah rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 1, 0)
end

#swpal(rs, rt, rn) ⇒ Object



2654
2655
2656
# File 'lib/aarch64.rb', line 2654

def swpal rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 1, 1)
end

#swpalb(rs, rt, rn) ⇒ Object



2670
2671
2672
# File 'lib/aarch64.rb', line 2670

def swpalb rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 1, 1)
end

#swpalh(rs, rt, rn) ⇒ Object



2686
2687
2688
# File 'lib/aarch64.rb', line 2686

def swpalh rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 1, 1)
end

#swpb(rs, rt, rn) ⇒ Object



2674
2675
2676
# File 'lib/aarch64.rb', line 2674

def swpb rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 0, 0)
end

#swph(rs, rt, rn) ⇒ Object



2690
2691
2692
# File 'lib/aarch64.rb', line 2690

def swph rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 0, 0)
end

#swpl(rs, rt, rn) ⇒ Object



2658
2659
2660
# File 'lib/aarch64.rb', line 2658

def swpl rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 0, 1)
end

#swplb(rs, rt, rn) ⇒ Object



2678
2679
2680
# File 'lib/aarch64.rb', line 2678

def swplb rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 0, 1)
end

#swplh(rs, rt, rn) ⇒ Object



2694
2695
2696
# File 'lib/aarch64.rb', line 2694

def swplh rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 0, 1)
end

#sxtb(rd, rn) ⇒ Object



2698
2699
2700
# File 'lib/aarch64.rb', line 2698

def sxtb rd, rn
  sbfm rd, rn, 0, 7
end

#sxth(rd, rn) ⇒ Object



2702
2703
2704
# File 'lib/aarch64.rb', line 2702

def sxth rd, rn
  sbfm rd, rn, 0, 15
end

#sxtw(rd, rn) ⇒ Object



2706
2707
2708
# File 'lib/aarch64.rb', line 2706

def sxtw rd, rn
  sbfm rd, rn, 0, 31
end

#sys(op1, cn, cm, op2, xt = XZR) ⇒ Object



2710
2711
2712
# File 'lib/aarch64.rb', line 2710

def sys op1, cn, cm, op2, xt = XZR
  a SYS.new(op1, cn, cm, op2, xt)
end

#sysl(xt, op1, cn, cm, op2) ⇒ Object



2714
2715
2716
# File 'lib/aarch64.rb', line 2714

def sysl xt, op1, cn, cm, op2
  a SYSL.new(xt, op1, cn, cm, op2)
end

#tbnz(rt, imm, label) ⇒ Object



2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
# File 'lib/aarch64.rb', line 2718

def tbnz rt, imm, label
  if label.integer?
    label = wrap_offset_with_label label
  end

  sf = 0
  if imm > 31
    sf = 1
    imm -= 32
  end
  a TBNZ.new(rt, imm, label, sf)
end

#tbz(rt, imm, label) ⇒ Object



2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
# File 'lib/aarch64.rb', line 2731

def tbz rt, imm, label
  if label.integer?
    label = wrap_offset_with_label label
  end

  sf = 0
  if imm > 31
    sf = 1
    imm -= 32
  end
  a TBZ.new(rt, imm, label, sf)
end

#tlbi(tlbi_op, xt = XZR) ⇒ Object



2744
2745
2746
2747
# File 'lib/aarch64.rb', line 2744

def tlbi tlbi_op, xt = XZR
  op1, crm, op2 = Utils.tlbi_op(tlbi_op)
  sys op1, Names::C8, crm, op2, xt
end

#to_binaryObject



2856
2857
2858
# File 'lib/aarch64.rb', line 2856

def to_binary
  @insns.map.with_index { _1.encode(_2) }.pack("L<*")
end

#tsb(_) ⇒ Object



2749
2750
2751
# File 'lib/aarch64.rb', line 2749

def tsb _
  a TSB.new
end

#tst(rn, rm, option = nil, shift: :lsl, amount: 0) ⇒ Object



2753
2754
2755
2756
2757
2758
2759
2760
# File 'lib/aarch64.rb', line 2753

def tst rn, rm, option = nil, shift: :lsl, amount: 0
  if option
    shift = option.name
    amount = option.amount
  end

  ands rn.zr, rn, rm, shift: shift, amount: amount
end

#ubfiz(rd, rn, lsb, width) ⇒ Object



2766
2767
2768
# File 'lib/aarch64.rb', line 2766

def ubfiz rd, rn, lsb, width
  ubfm rd, rn, (-lsb) % rd.size, width - 1
end

#ubfm(rd, rn, immr, imms) ⇒ Object



2762
2763
2764
# File 'lib/aarch64.rb', line 2762

def ubfm rd, rn, immr, imms
  a UBFM.new(rd, rn, immr, imms, rd.sf)
end

#ubfx(rd, rn, lsb, width) ⇒ Object



2770
2771
2772
# File 'lib/aarch64.rb', line 2770

def ubfx rd, rn, lsb, width
  ubfm rd, rn, lsb, lsb + width - 1
end

#udf(imm) ⇒ Object



2774
2775
2776
# File 'lib/aarch64.rb', line 2774

def udf imm
  a UDF_perm_undef.new(imm)
end

#udiv(rd, rn, rm) ⇒ Object



2778
2779
2780
# File 'lib/aarch64.rb', line 2778

def udiv rd, rn, rm
  a UDIV.new(rd, rn, rm, rd.sf)
end

#umaddl(xd, wn, wm, xa) ⇒ Object



2782
2783
2784
# File 'lib/aarch64.rb', line 2782

def umaddl xd, wn, wm, xa
  a UMADDL.new(xd, wn, wm, xa)
end

#umnegl(xd, wn, wm) ⇒ Object



2786
2787
2788
# File 'lib/aarch64.rb', line 2786

def umnegl xd, wn, wm
  umsubl xd, wn, wm, XZR
end

#umsubl(xd, wn, wm, xa) ⇒ Object



2790
2791
2792
# File 'lib/aarch64.rb', line 2790

def umsubl xd, wn, wm, xa
  a UMSUBL.new(xd, wn, wm, xa)
end

#umulh(rd, rn, rm) ⇒ Object



2794
2795
2796
# File 'lib/aarch64.rb', line 2794

def umulh rd, rn, rm
  a UMULH.new(rd, rn, rm)
end

#umull(xd, wn, wm) ⇒ Object



2798
2799
2800
# File 'lib/aarch64.rb', line 2798

def umull xd, wn, wm
  umaddl xd, wn, wm, XZR
end

#uxtb(rd, rn) ⇒ Object



2802
2803
2804
# File 'lib/aarch64.rb', line 2802

def uxtb rd, rn
  ubfm rd, rn, 0, 7
end

#uxth(rd, rn) ⇒ Object



2806
2807
2808
# File 'lib/aarch64.rb', line 2806

def uxth rd, rn
  ubfm rd, rn, 0, 15
end

#wfeObject



2810
2811
2812
# File 'lib/aarch64.rb', line 2810

def wfe
  a WFE.new
end

#wfet(rd) ⇒ Object



2814
2815
2816
# File 'lib/aarch64.rb', line 2814

def wfet rd
  a WFET.new(rd)
end

#wfiObject



2818
2819
2820
# File 'lib/aarch64.rb', line 2818

def wfi
  a WFI.new
end

#wfit(rd) ⇒ Object



2822
2823
2824
# File 'lib/aarch64.rb', line 2822

def wfit rd
  a WFIT.new(rd)
end

#write_to(io) ⇒ Object



2852
2853
2854
# File 'lib/aarch64.rb', line 2852

def write_to io
  io.write to_binary
end

#xaflagObject



2826
2827
2828
# File 'lib/aarch64.rb', line 2826

def xaflag
  a XAFLAG.new
end

#xpacd(rd) ⇒ Object



2830
2831
2832
# File 'lib/aarch64.rb', line 2830

def xpacd rd
  a XPAC.new(rd, 1)
end

#xpaci(rd) ⇒ Object



2834
2835
2836
# File 'lib/aarch64.rb', line 2834

def xpaci rd
  a XPAC.new(rd, 0)
end

#xpaclriObject



2838
2839
2840
# File 'lib/aarch64.rb', line 2838

def xpaclri
  a XPACLRI.new
end

#yieldObject



2842
2843
2844
# File 'lib/aarch64.rb', line 2842

def yield
  a YIELD.new
end