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
# File 'lib/aarch64.rb', line 290

def adrp xd, label
  a ADRP.new(xd, label)
end

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



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

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



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

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



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

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



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

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

#at(at_op, t) ⇒ Object



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

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



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

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



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

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



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

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

#autdzb(d) ⇒ Object



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

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

#autia(d, n) ⇒ Object



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

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

#autia1716Object



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

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

#autiaspObject



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

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

#autiazObject



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

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

#autib(d, n) ⇒ Object



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

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

#autib1716Object



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

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

#autibspObject



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

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

#autibzObject



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

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

#autiza(d) ⇒ Object



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

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

#autizb(d) ⇒ Object



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

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

#axflagObject



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

def axflag
  a AXFLAG.new
end

#b(label, cond: nil) ⇒ Object



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

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



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

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



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

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

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



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

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

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



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

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

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



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

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



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

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



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

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



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

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

  a BL.new(label)
end

#blr(n) ⇒ Object



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

def blr n
  a BLR.new(n)
end

#blraa(rn, rm) ⇒ Object



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

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

#blraaz(rn) ⇒ Object



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

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

#blrab(rn, rm) ⇒ Object



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

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

#blrabz(rn) ⇒ Object



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

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

#br(rn) ⇒ Object



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

def br rn
  a BR.new(rn)
end

#braa(rn, rm) ⇒ Object



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

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

#braaz(rn) ⇒ Object



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

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

#brab(rn, rm) ⇒ Object



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

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

#brabz(rn) ⇒ Object



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

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

#brk(imm) ⇒ Object



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

def brk imm
  a BRK.new(imm)
end

#bti(target) ⇒ Object



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

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

#cas(s, t, n_list) ⇒ Object



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

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



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

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



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

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

#casal(s, t, n_list) ⇒ Object



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

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



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

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

#casalh(rs, rt, rn_list) ⇒ Object



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

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

#casb(rs, rt, rn_list) ⇒ Object



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

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

#cash(rs, rt, rn_list) ⇒ Object



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

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

#casl(s, t, n_list) ⇒ Object



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

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



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

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

#caslh(rs, rt, rn_list) ⇒ Object



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

def cfinv
  a CFINV.new
end

#cfp_rcfx(rt) ⇒ Object



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

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

#cinc(rd, rn, cond) ⇒ Object



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

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

#cinv(rd, rn, cond) ⇒ Object



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

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

#clrex(imm = 15) ⇒ Object



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

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

#cls(rd, rn) ⇒ Object



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

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

#clz(rd, rn) ⇒ Object



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

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



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

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



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

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



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

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

#cneg(rd, rn, cond) ⇒ Object



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

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

#cpp(_, xn) ⇒ Object



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

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

#crc32b(rd, rn, rm) ⇒ Object



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

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

#crc32cb(rd, rn, rm) ⇒ Object



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

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

#crc32ch(rd, rn, rm) ⇒ Object



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

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

#crc32cw(rd, rn, rm) ⇒ Object



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

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

#crc32cx(rd, rn, rm) ⇒ Object



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

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

#crc32h(rd, rn, rm) ⇒ Object



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

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

#crc32w(rd, rn, rm) ⇒ Object



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

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

#crc32x(rd, rn, rm) ⇒ Object



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

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

#csdbObject



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

def csdb
  a CSDB.new
end

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



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

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

#cset(rd, cond) ⇒ Object



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

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

#csetm(rd, cond) ⇒ Object



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

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



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

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

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



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

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

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



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

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

#dc(dc_op, xt) ⇒ Object



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

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



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

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

#dcps2(imm = 0) ⇒ Object



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

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

#dcps3(imm = 0) ⇒ Object



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

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

#dghObject



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

def dgh
  a DGH.new
end

#dmb(option) ⇒ Object



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

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

#drpsObject



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

def drps
  a DRPS.new
end

#dsb(option) ⇒ Object



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

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

#dvp(_, xt) ⇒ Object



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

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

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



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

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



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

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



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

def eret
  a ERET.new
end

#eretaaObject



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

def eretaa
  a ERETA.new(0)
end

#eretabObject



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

def eretab
  a ERETA.new(1)
end

#esbObject



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

def esb
  a ESB.new
end

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



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

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

#gmi(rd, rn, rm) ⇒ Object



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

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

#hint(imm) ⇒ Object



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

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

#hlt(imm) ⇒ Object



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

def hlt imm
  a HLT.new(imm)
end

#hvc(imm) ⇒ Object



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

def hvc imm
  a HVC.new(imm)
end

#ic(op, xt = SP) ⇒ Object



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

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



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

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

#isb(option = 0b1111) ⇒ Object



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

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

#ld64b(rt, rn) ⇒ Object



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

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

#ldadd(rs, rt, rn) ⇒ Object



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

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

#ldadda(rs, rt, rn) ⇒ Object



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

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

#ldaddab(rs, rt, rn) ⇒ Object



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

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

#ldaddah(rs, rt, rn) ⇒ Object



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

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

#ldaddal(rs, rt, rn) ⇒ Object



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

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

#ldaddalb(rs, rt, rn) ⇒ Object



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

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

#ldaddalh(rs, rt, rn) ⇒ Object



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

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

#ldaddb(rs, rt, rn) ⇒ Object



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

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

#ldaddh(rs, rt, rn) ⇒ Object



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

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

#ldaddl(rs, rt, rn) ⇒ Object



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

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

#ldaddlb(rs, rt, rn) ⇒ Object



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

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

#ldaddlh(rs, rt, rn) ⇒ Object



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

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

#ldapr(rt, rn) ⇒ Object



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

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

#ldaprb(rt, rn) ⇒ Object



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

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

#ldaprh(rt, rn) ⇒ Object



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

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

#ldapur(rt, rn) ⇒ Object



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

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

#ldapurb(rt, rn) ⇒ Object



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

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

#ldapurh(rt, rn) ⇒ Object



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

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

#ldapursb(rt, rn) ⇒ Object



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

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

#ldapursh(rt, rn) ⇒ Object



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

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

#ldapursw(rt, rn) ⇒ Object



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

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

#ldar(rt, rn) ⇒ Object



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

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

#ldarb(rt, rn) ⇒ Object



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

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

#ldarh(rt, rn) ⇒ Object



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

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

#ldaxp(rt1, rt2, xn) ⇒ Object



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

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

#ldaxr(rt1, xn) ⇒ Object



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

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

#ldaxrb(rt1, xn) ⇒ Object



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

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

#ldaxrh(rt1, xn) ⇒ Object



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

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

#ldclr(rs, rt, rn) ⇒ Object



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

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

#ldclra(rs, rt, rn) ⇒ Object



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

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

#ldclrab(rs, rt, rn) ⇒ Object



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

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

#ldclrah(rs, rt, rn) ⇒ Object



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

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

#ldclral(rs, rt, rn) ⇒ Object



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

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

#ldclralb(rs, rt, rn) ⇒ Object



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

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

#ldclralh(rs, rt, rn) ⇒ Object



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

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

#ldclrb(rs, rt, rn) ⇒ Object



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

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

#ldclrh(rs, rt, rn) ⇒ Object



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

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

#ldclrl(rs, rt, rn) ⇒ Object



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

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

#ldclrlb(rs, rt, rn) ⇒ Object



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

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

#ldclrlh(rs, rt, rn) ⇒ Object



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

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

#ldeor(rs, rt, rn) ⇒ Object



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

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

#ldeora(rs, rt, rn) ⇒ Object



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

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

#ldeorab(rs, rt, rn) ⇒ Object



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

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

#ldeorah(rs, rt, rn) ⇒ Object



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

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

#ldeoral(rs, rt, rn) ⇒ Object



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

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

#ldeoralb(rs, rt, rn) ⇒ Object



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

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

#ldeoralh(rs, rt, rn) ⇒ Object



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

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

#ldeorb(rs, rt, rn) ⇒ Object



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

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

#ldeorh(rs, rt, rn) ⇒ Object



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

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

#ldeorl(rs, rt, rn) ⇒ Object



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

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

#ldeorlb(rs, rt, rn) ⇒ Object



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

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

#ldeorlh(rs, rt, rn) ⇒ Object



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

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

#ldg(xt, xn) ⇒ Object



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

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

#ldgm(xt, xn) ⇒ Object



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

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

#ldlar(rt, rn) ⇒ Object



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

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

#ldlarb(rt, rn) ⇒ Object



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

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

#ldlarh(rt, rn) ⇒ Object



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

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

#ldnp(rt1, rt2, rn) ⇒ Object



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

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



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

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



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

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



1113
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
# File 'lib/aarch64.rb', line 1113

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



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

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



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

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



1181
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
# File 'lib/aarch64.rb', line 1181

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



1218
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
# File 'lib/aarch64.rb', line 1218

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



1255
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
# File 'lib/aarch64.rb', line 1255

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



1288
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
# File 'lib/aarch64.rb', line 1288

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



1320
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
# File 'lib/aarch64.rb', line 1320

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



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

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

#ldseta(rs, rt, rn) ⇒ Object



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

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

#ldsetab(rs, rt, rn) ⇒ Object



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

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

#ldsetah(rs, rt, rn) ⇒ Object



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

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

#ldsetal(rs, rt, rn) ⇒ Object



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

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

#ldsetalb(rs, rt, rn) ⇒ Object



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

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

#ldsetalh(rs, rt, rn) ⇒ Object



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

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

#ldsetb(rs, rt, rn) ⇒ Object



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

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

#ldseth(rs, rt, rn) ⇒ Object



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

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

#ldsetl(rs, rt, rn) ⇒ Object



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

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

#ldsetlb(rs, rt, rn) ⇒ Object



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

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

#ldsetlh(rs, rt, rn) ⇒ Object



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

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

#ldsmax(rs, rt, rn) ⇒ Object



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

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

#ldsmaxa(rs, rt, rn) ⇒ Object



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

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

#ldsmaxab(rs, rt, rn) ⇒ Object



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

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

#ldsmaxah(rs, rt, rn) ⇒ Object



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

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

#ldsmaxal(rs, rt, rn) ⇒ Object



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

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

#ldsmaxalb(rs, rt, rn) ⇒ Object



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

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

#ldsmaxalh(rs, rt, rn) ⇒ Object



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

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

#ldsmaxb(rs, rt, rn) ⇒ Object



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

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

#ldsmaxh(rs, rt, rn) ⇒ Object



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

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

#ldsmaxl(rs, rt, rn) ⇒ Object



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

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

#ldsmaxlb(rs, rt, rn) ⇒ Object



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

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

#ldsmaxlh(rs, rt, rn) ⇒ Object



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

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

#ldsmin(rs, rt, rn) ⇒ Object



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

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

#ldsmina(rs, rt, rn) ⇒ Object



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

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

#ldsminab(rs, rt, rn) ⇒ Object



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

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

#ldsminah(rs, rt, rn) ⇒ Object



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

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

#ldsminal(rs, rt, rn) ⇒ Object



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

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

#ldsminalb(rs, rt, rn) ⇒ Object



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

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

#ldsminalh(rs, rt, rn) ⇒ Object



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

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

#ldsminb(rs, rt, rn) ⇒ Object



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

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

#ldsminh(rs, rt, rn) ⇒ Object



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

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

#ldsminl(rs, rt, rn) ⇒ Object



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

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

#ldsminlb(rs, rt, rn) ⇒ Object



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

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

#ldsminlh(rs, rt, rn) ⇒ Object



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

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

#ldtr(rt, rn) ⇒ Object



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

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

#ldtrb(rt, rn) ⇒ Object



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

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

#ldtrh(rt, rn) ⇒ Object



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

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

#ldtrsb(rt, rn) ⇒ Object



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

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

#ldtrsh(rt, rn) ⇒ Object



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

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

#ldtrsw(rt, rn) ⇒ Object



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

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

#ldumax(rs, rt, rn) ⇒ Object



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

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

#ldumaxa(rs, rt, rn) ⇒ Object



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

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

#ldumaxab(rs, rt, rn) ⇒ Object



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

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

#ldumaxah(rs, rt, rn) ⇒ Object



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

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

#ldumaxal(rs, rt, rn) ⇒ Object



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

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

#ldumaxalb(rs, rt, rn) ⇒ Object



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

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

#ldumaxalh(rs, rt, rn) ⇒ Object



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

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

#ldumaxb(rs, rt, rn) ⇒ Object



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

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

#ldumaxh(rs, rt, rn) ⇒ Object



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

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

#ldumaxl(rs, rt, rn) ⇒ Object



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

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

#ldumaxlb(rs, rt, rn) ⇒ Object



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

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

#ldumaxlh(rs, rt, rn) ⇒ Object



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

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

#ldumin(rs, rt, rn) ⇒ Object



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

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

#ldumina(rs, rt, rn) ⇒ Object



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

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

#lduminab(rs, rt, rn) ⇒ Object



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

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

#lduminah(rs, rt, rn) ⇒ Object



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

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

#lduminal(rs, rt, rn) ⇒ Object



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

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

#lduminalb(rs, rt, rn) ⇒ Object



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

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

#lduminalh(rs, rt, rn) ⇒ Object



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

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

#lduminb(rs, rt, rn) ⇒ Object



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

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

#lduminh(rs, rt, rn) ⇒ Object



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

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

#lduminl(rs, rt, rn) ⇒ Object



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

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

#lduminlb(rs, rt, rn) ⇒ Object



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

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

#lduminlh(rs, rt, rn) ⇒ Object



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

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

#ldur(rt, rn) ⇒ Object



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

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

#ldurb(rt, rn) ⇒ Object



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

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

#ldurh(rt, rn) ⇒ Object



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

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

#ldursb(rt, rn) ⇒ Object



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

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

#ldursh(rt, rn) ⇒ Object



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

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

#ldursw(rt, rn) ⇒ Object



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

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

#ldxp(rt, rt2, rn) ⇒ Object



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

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

#ldxr(rt, rn) ⇒ Object



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

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

#ldxrb(rt, rn) ⇒ Object



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

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

#ldxrh(rt, rn) ⇒ Object



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

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

#lsl(rd, rn, rm) ⇒ Object



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

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



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

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

#lsr(rd, rn, rm) ⇒ Object



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

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



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

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

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



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

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



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

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

#mov(rd, rm) ⇒ Object



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

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



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

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



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

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



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

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



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

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



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

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



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

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

#mul(rd, rn, rm) ⇒ Object



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

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

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



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

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



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

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



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

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



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

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

#ngcs(rd, rm) ⇒ Object



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

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

#nopObject



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

def nop
  a NOP.new
end

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



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

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



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

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



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

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

#pacdb(xd, xn) ⇒ Object



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

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

#pacdza(xd) ⇒ Object



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

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

#pacdzb(xd) ⇒ Object



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

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

#pacga(xd, xn, xm) ⇒ Object



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

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

#pacia(xd, xn) ⇒ Object



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

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

#pacia1716Object



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

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

#paciaspObject



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

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

#paciazObject



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

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

#pacib(xd, xn) ⇒ Object



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

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

#pacib1716Object



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

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

#pacibspObject



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

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

#pacibzObject



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

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

#paciza(xd) ⇒ Object



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

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

#pacizb(xd) ⇒ Object



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

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)


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

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



1890
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
# File 'lib/aarch64.rb', line 1890

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



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

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



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

def psb _
  a PSB.new
end

#pssbbObject



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

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



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

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

#ret(reg = X30) ⇒ Object



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

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

#retaaObject



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

def retaa
  a RETA.new(0)
end

#retabObject



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

def retab
  a RETA.new(1)
end

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



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

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

#rev16(rd, rn) ⇒ Object



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

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

#rev32(rd, rn) ⇒ Object



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

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

#rmif(rn, shift, mask) ⇒ Object



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

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

#ror(rd, rs, shift) ⇒ Object



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

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



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

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

#sbObject



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

def sb
  a SB.new
end

#sbc(rd, rn, rm) ⇒ Object



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

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

#sbcs(rd, rn, rm) ⇒ Object



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

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

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



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

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

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



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

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

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



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

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

#sdiv(rd, rn, rm) ⇒ Object



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

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

#setf16(rn) ⇒ Object



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

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

#setf8(rn) ⇒ Object



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

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

#sevObject



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

def sev
  a SEV.new
end

#sevlObject



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

def sevl
  a SEVL.new
end

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



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

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

#smc(imm) ⇒ Object



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

def smc imm
  a SMC.new(imm)
end

#smnegl(rd, rn, rm) ⇒ Object



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

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

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



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

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

#smulh(rd, rn, rm) ⇒ Object



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

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

#smull(rd, rn, rm) ⇒ Object



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

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

#ssbbObject



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

def ssbb
  dsb 0
end

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



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

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



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

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

#st64bv(rs, rt, rn) ⇒ Object



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

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

#st64bv0(rs, rt, rn) ⇒ Object



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

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

#stadd(rs, rn) ⇒ Object



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

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

#staddb(rs, rn) ⇒ Object



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

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

#staddh(rs, rn) ⇒ Object



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

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

#staddl(rs, rn) ⇒ Object



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

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

#staddlb(rs, rn) ⇒ Object



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

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

#staddlh(rs, rn) ⇒ Object



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

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

#stclr(rs, rn) ⇒ Object



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

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

#stclrb(rs, rn) ⇒ Object



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

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

#stclrh(rs, rn) ⇒ Object



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

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

#stclrl(rs, rn) ⇒ Object



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

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

#stclrlb(rs, rn) ⇒ Object



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

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

#stclrlh(rs, rn) ⇒ Object



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

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

#steor(rs, rn) ⇒ Object



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

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

#steorb(rs, rn) ⇒ Object



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

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

#steorh(rs, rn) ⇒ Object



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

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

#steorl(rs, rn) ⇒ Object



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

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

#steorlb(rs, rn) ⇒ Object



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

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

#steorlh(rs, rn) ⇒ Object



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

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

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



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

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



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

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

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



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

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



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

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

#stllrb(rt, rn) ⇒ Object



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

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

#stllrh(rt, rn) ⇒ Object



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

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

#stlr(rt, rn) ⇒ Object



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

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

#stlrb(rt, rn) ⇒ Object



2202
2203
2204
# File 'lib/aarch64.rb', line 2202

def stlrb rt, rn
  a STLRB.new(rt, rn.first)
end

#stlrh(rt, rn) ⇒ Object



2206
2207
2208
# File 'lib/aarch64.rb', line 2206

def stlrh rt, rn
  a STLRH.new(rt, rn.first)
end

#stlur(rt, rn) ⇒ Object



2210
2211
2212
# File 'lib/aarch64.rb', line 2210

def stlur rt, rn
  a STLUR_gen.new(rt, rn.first, rn[1] || 0, rt.sizeb)
end

#stlurb(rt, rn) ⇒ Object



2214
2215
2216
# File 'lib/aarch64.rb', line 2214

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

#stlurh(rt, rn) ⇒ Object



2218
2219
2220
# File 'lib/aarch64.rb', line 2218

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

#stlxp(rs, rt, rt2, rn) ⇒ Object



2222
2223
2224
# File 'lib/aarch64.rb', line 2222

def stlxp rs, rt, rt2, rn
  a STLXP.new(rs, rt, rt2, rn.first, rt.sz)
end

#stlxr(rs, rt, rn) ⇒ Object



2226
2227
2228
# File 'lib/aarch64.rb', line 2226

def stlxr rs, rt, rn
  a STLXR.new(rs, rt, rn.first, rt.sizeb)
end

#stlxrb(rs, rt, rn) ⇒ Object



2230
2231
2232
# File 'lib/aarch64.rb', line 2230

def stlxrb rs, rt, rn
  a STLXRB.new(rs, rt, rn.first)
end

#stlxrh(rs, rt, rn) ⇒ Object



2234
2235
2236
# File 'lib/aarch64.rb', line 2234

def stlxrh rs, rt, rn
  a STLXRH.new(rs, rt, rn.first)
end

#stnp(rt, rt2, rn) ⇒ Object



2238
2239
2240
# File 'lib/aarch64.rb', line 2238

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



2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
# File 'lib/aarch64.rb', line 2242

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



2259
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
# File 'lib/aarch64.rb', line 2259

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



2292
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
# File 'lib/aarch64.rb', line 2292

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



2325
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
# File 'lib/aarch64.rb', line 2325

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



2358
2359
2360
# File 'lib/aarch64.rb', line 2358

def stset rs, rn
  ldset rs, rs.zr, rn
end

#stsetb(rs, rn) ⇒ Object



2366
2367
2368
# File 'lib/aarch64.rb', line 2366

def stsetb rs, rn
  ldsetb rs, rs.zr, rn
end

#stseth(rs, rn) ⇒ Object



2374
2375
2376
# File 'lib/aarch64.rb', line 2374

def stseth rs, rn
  ldseth rs, rs.zr, rn
end

#stsetl(rs, rn) ⇒ Object



2362
2363
2364
# File 'lib/aarch64.rb', line 2362

def stsetl rs, rn
  ldsetl rs, rs.zr, rn
end

#stsetlb(rs, rn) ⇒ Object



2370
2371
2372
# File 'lib/aarch64.rb', line 2370

def stsetlb rs, rn
  ldsetlb rs, rs.zr, rn
end

#stsetlh(rs, rn) ⇒ Object



2378
2379
2380
# File 'lib/aarch64.rb', line 2378

def stsetlh rs, rn
  ldsetlh rs, rs.zr, rn
end

#stsmax(rs, rn) ⇒ Object



2382
2383
2384
# File 'lib/aarch64.rb', line 2382

def stsmax rs, rn
  ldsmax rs, rs.zr, rn
end

#stsmaxb(rs, rn) ⇒ Object



2390
2391
2392
# File 'lib/aarch64.rb', line 2390

def stsmaxb rs, rn
  ldsmaxb rs, rs.zr, rn
end

#stsmaxh(rs, rn) ⇒ Object



2398
2399
2400
# File 'lib/aarch64.rb', line 2398

def stsmaxh rs, rn
  ldsmaxh rs, rs.zr, rn
end

#stsmaxl(rs, rn) ⇒ Object



2386
2387
2388
# File 'lib/aarch64.rb', line 2386

def stsmaxl rs, rn
  ldsmaxl rs, rs.zr, rn
end

#stsmaxlb(rs, rn) ⇒ Object



2394
2395
2396
# File 'lib/aarch64.rb', line 2394

def stsmaxlb rs, rn
  ldsmaxlb rs, rs.zr, rn
end

#stsmaxlh(rs, rn) ⇒ Object



2402
2403
2404
# File 'lib/aarch64.rb', line 2402

def stsmaxlh rs, rn
  ldsmaxlh rs, rs.zr, rn
end

#stsmin(rs, rn) ⇒ Object



2406
2407
2408
# File 'lib/aarch64.rb', line 2406

def stsmin rs, rn
  ldsmin rs, rs.zr, rn
end

#stsminb(rs, rn) ⇒ Object



2414
2415
2416
# File 'lib/aarch64.rb', line 2414

def stsminb rs, rn
  ldsminb rs, rs.zr, rn
end

#stsminh(rs, rn) ⇒ Object



2422
2423
2424
# File 'lib/aarch64.rb', line 2422

def stsminh rs, rn
  ldsminh rs, rs.zr, rn
end

#stsminl(rs, rn) ⇒ Object



2410
2411
2412
# File 'lib/aarch64.rb', line 2410

def stsminl rs, rn
  ldsminl rs, rs.zr, rn
end

#stsminlb(rs, rn) ⇒ Object



2418
2419
2420
# File 'lib/aarch64.rb', line 2418

def stsminlb rs, rn
  ldsminlb rs, rs.zr, rn
end

#stsminlh(rs, rn) ⇒ Object



2426
2427
2428
# File 'lib/aarch64.rb', line 2426

def stsminlh rs, rn
  ldsminlh rs, rs.zr, rn
end

#sttr(rt, rn) ⇒ Object



2430
2431
2432
# File 'lib/aarch64.rb', line 2430

def sttr rt, rn
  a STTR.new(rt, rn.first, rn[1] || 0, rt.sizeb)
end

#sttrb(rt, rn) ⇒ Object



2434
2435
2436
# File 'lib/aarch64.rb', line 2434

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

#sttrh(rt, rn) ⇒ Object



2438
2439
2440
# File 'lib/aarch64.rb', line 2438

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

#stumax(rs, rn) ⇒ Object



2442
2443
2444
# File 'lib/aarch64.rb', line 2442

def stumax rs, rn
  ldumax rs, rs.zr, rn
end

#stumaxb(rs, rn) ⇒ Object



2450
2451
2452
# File 'lib/aarch64.rb', line 2450

def stumaxb rs, rn
  ldumaxb rs, rs.zr, rn
end

#stumaxh(rs, rn) ⇒ Object



2458
2459
2460
# File 'lib/aarch64.rb', line 2458

def stumaxh rs, rn
  ldumaxh rs, rs.zr, rn
end

#stumaxl(rs, rn) ⇒ Object



2446
2447
2448
# File 'lib/aarch64.rb', line 2446

def stumaxl rs, rn
  ldumaxl rs, rs.zr, rn
end

#stumaxlb(rs, rn) ⇒ Object



2454
2455
2456
# File 'lib/aarch64.rb', line 2454

def stumaxlb rs, rn
  ldumaxlb rs, rs.zr, rn
end

#stumaxlh(rs, rn) ⇒ Object



2462
2463
2464
# File 'lib/aarch64.rb', line 2462

def stumaxlh rs, rn
  ldumaxlh rs, rs.zr, rn
end

#stumin(rs, rn) ⇒ Object



2466
2467
2468
# File 'lib/aarch64.rb', line 2466

def stumin rs, rn
  ldumin rs, rs.zr, rn
end

#stuminb(rs, rn) ⇒ Object



2474
2475
2476
# File 'lib/aarch64.rb', line 2474

def stuminb rs, rn
  lduminb rs, rs.zr, rn
end

#stuminh(rs, rn) ⇒ Object



2482
2483
2484
# File 'lib/aarch64.rb', line 2482

def stuminh rs, rn
  lduminh rs, rs.zr, rn
end

#stuminl(rs, rn) ⇒ Object



2470
2471
2472
# File 'lib/aarch64.rb', line 2470

def stuminl rs, rn
  lduminl rs, rs.zr, rn
end

#stuminlb(rs, rn) ⇒ Object



2478
2479
2480
# File 'lib/aarch64.rb', line 2478

def stuminlb rs, rn
  lduminlb rs, rs.zr, rn
end

#stuminlh(rs, rn) ⇒ Object



2486
2487
2488
# File 'lib/aarch64.rb', line 2486

def stuminlh rs, rn
  lduminlh rs, rs.zr, rn
end

#stur(rt, rn) ⇒ Object



2490
2491
2492
# File 'lib/aarch64.rb', line 2490

def stur rt, rn
  a STUR_gen.new(rt, rn.first, rn[1] || 0, rt.sizeb)
end

#sturb(rt, rn) ⇒ Object



2494
2495
2496
# File 'lib/aarch64.rb', line 2494

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

#sturh(rt, rn) ⇒ Object



2498
2499
2500
# File 'lib/aarch64.rb', line 2498

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

#stxp(rs, rt1, rt2, rn) ⇒ Object



2502
2503
2504
# File 'lib/aarch64.rb', line 2502

def stxp rs, rt1, rt2, rn
  a STXP.new(rs, rt1, rt2, rn.first, rt1.sf)
end

#stxr(rs, rt, rn) ⇒ Object



2506
2507
2508
# File 'lib/aarch64.rb', line 2506

def stxr rs, rt, rn
  a STXR.new(rs, rt, rn.first, rt.opc2)
end

#stxrb(rs, rt, rn) ⇒ Object



2510
2511
2512
# File 'lib/aarch64.rb', line 2510

def stxrb rs, rt, rn
  a STXRB.new(rs, rt, rn.first)
end

#stxrh(rs, rt, rn) ⇒ Object



2514
2515
2516
# File 'lib/aarch64.rb', line 2514

def stxrh rs, rt, rn
  a STXRH.new(rs, rt, rn.first)
end

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



2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
# File 'lib/aarch64.rb', line 2518

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



2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
# File 'lib/aarch64.rb', line 2532

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



2546
2547
2548
# File 'lib/aarch64.rb', line 2546

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



2590
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
# File 'lib/aarch64.rb', line 2590

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)


2630
2631
2632
2633
# File 'lib/aarch64.rb', line 2630

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)


2635
2636
2637
2638
# File 'lib/aarch64.rb', line 2635

def subp xd, xn, xm
  raise NotImplementedError unless xd.x?
  a SUBP.new(xd, xn, xm)
end

#subps(xd, xn, xm) ⇒ Object

Raises:

  • (NotImplementedError)


2640
2641
2642
2643
# File 'lib/aarch64.rb', line 2640

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



2550
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
# File 'lib/aarch64.rb', line 2550

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



2645
2646
2647
# File 'lib/aarch64.rb', line 2645

def svc imm
  a SVC.new(imm)
end

#swp(rs, rt, rn) ⇒ Object



2649
2650
2651
# File 'lib/aarch64.rb', line 2649

def swp rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 0, 0)
end

#swpa(rs, rt, rn) ⇒ Object



2661
2662
2663
# File 'lib/aarch64.rb', line 2661

def swpa rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 1, 0)
end

#swpab(rs, rt, rn) ⇒ Object



2665
2666
2667
# File 'lib/aarch64.rb', line 2665

def swpab rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 1, 0)
end

#swpah(rs, rt, rn) ⇒ Object



2681
2682
2683
# File 'lib/aarch64.rb', line 2681

def swpah rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 1, 0)
end

#swpal(rs, rt, rn) ⇒ Object



2653
2654
2655
# File 'lib/aarch64.rb', line 2653

def swpal rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 1, 1)
end

#swpalb(rs, rt, rn) ⇒ Object



2669
2670
2671
# File 'lib/aarch64.rb', line 2669

def swpalb rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 1, 1)
end

#swpalh(rs, rt, rn) ⇒ Object



2685
2686
2687
# File 'lib/aarch64.rb', line 2685

def swpalh rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 1, 1)
end

#swpb(rs, rt, rn) ⇒ Object



2673
2674
2675
# File 'lib/aarch64.rb', line 2673

def swpb rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 0, 0)
end

#swph(rs, rt, rn) ⇒ Object



2689
2690
2691
# File 'lib/aarch64.rb', line 2689

def swph rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 0, 0)
end

#swpl(rs, rt, rn) ⇒ Object



2657
2658
2659
# File 'lib/aarch64.rb', line 2657

def swpl rs, rt, rn
  a SWP.new(rs, rt, rn.first, rs.opc2, 0, 1)
end

#swplb(rs, rt, rn) ⇒ Object



2677
2678
2679
# File 'lib/aarch64.rb', line 2677

def swplb rs, rt, rn
  a SWPB.new(rs, rt, rn.first, 0, 1)
end

#swplh(rs, rt, rn) ⇒ Object



2693
2694
2695
# File 'lib/aarch64.rb', line 2693

def swplh rs, rt, rn
  a SWPH.new(rs, rt, rn.first, 0, 1)
end

#sxtb(rd, rn) ⇒ Object



2697
2698
2699
# File 'lib/aarch64.rb', line 2697

def sxtb rd, rn
  sbfm rd, rn, 0, 7
end

#sxth(rd, rn) ⇒ Object



2701
2702
2703
# File 'lib/aarch64.rb', line 2701

def sxth rd, rn
  sbfm rd, rn, 0, 15
end

#sxtw(rd, rn) ⇒ Object



2705
2706
2707
# File 'lib/aarch64.rb', line 2705

def sxtw rd, rn
  sbfm rd, rn, 0, 31
end

#sys(op1, cn, cm, op2, xt = XZR) ⇒ Object



2709
2710
2711
# File 'lib/aarch64.rb', line 2709

def sys op1, cn, cm, op2, xt = XZR
  a SYS.new(op1, cn, cm, op2, xt)
end

#sysl(xt, op1, cn, cm, op2) ⇒ Object



2713
2714
2715
# File 'lib/aarch64.rb', line 2713

def sysl xt, op1, cn, cm, op2
  a SYSL.new(xt, op1, cn, cm, op2)
end

#tbnz(rt, imm, label) ⇒ Object



2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
# File 'lib/aarch64.rb', line 2717

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



2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
# File 'lib/aarch64.rb', line 2730

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



2743
2744
2745
2746
# File 'lib/aarch64.rb', line 2743

def tlbi tlbi_op, xt = XZR
  op1, crm, op2 = Utils.tlbi_op(tlbi_op)
  sys op1, Names::C8, crm, op2, xt
end

#to_binaryObject



2855
2856
2857
# File 'lib/aarch64.rb', line 2855

def to_binary
  @insns.map.with_index { _1.encode(_2) }.pack("L<*")
end

#tsb(_) ⇒ Object



2748
2749
2750
# File 'lib/aarch64.rb', line 2748

def tsb _
  a TSB.new
end

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



2752
2753
2754
2755
2756
2757
2758
2759
# File 'lib/aarch64.rb', line 2752

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



2765
2766
2767
# File 'lib/aarch64.rb', line 2765

def ubfiz rd, rn, lsb, width
  ubfm rd, rn, (-lsb) % rd.size, width - 1
end

#ubfm(rd, rn, immr, imms) ⇒ Object



2761
2762
2763
# File 'lib/aarch64.rb', line 2761

def ubfm rd, rn, immr, imms
  a UBFM.new(rd, rn, immr, imms, rd.sf)
end

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



2769
2770
2771
# File 'lib/aarch64.rb', line 2769

def ubfx rd, rn, lsb, width
  ubfm rd, rn, lsb, lsb + width - 1
end

#udf(imm) ⇒ Object



2773
2774
2775
# File 'lib/aarch64.rb', line 2773

def udf imm
  a UDF_perm_undef.new(imm)
end

#udiv(rd, rn, rm) ⇒ Object



2777
2778
2779
# File 'lib/aarch64.rb', line 2777

def udiv rd, rn, rm
  a UDIV.new(rd, rn, rm, rd.sf)
end

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



2781
2782
2783
# File 'lib/aarch64.rb', line 2781

def umaddl xd, wn, wm, xa
  a UMADDL.new(xd, wn, wm, xa)
end

#umnegl(xd, wn, wm) ⇒ Object



2785
2786
2787
# File 'lib/aarch64.rb', line 2785

def umnegl xd, wn, wm
  umsubl xd, wn, wm, XZR
end

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



2789
2790
2791
# File 'lib/aarch64.rb', line 2789

def umsubl xd, wn, wm, xa
  a UMSUBL.new(xd, wn, wm, xa)
end

#umulh(rd, rn, rm) ⇒ Object



2793
2794
2795
# File 'lib/aarch64.rb', line 2793

def umulh rd, rn, rm
  a UMULH.new(rd, rn, rm)
end

#umull(xd, wn, wm) ⇒ Object



2797
2798
2799
# File 'lib/aarch64.rb', line 2797

def umull xd, wn, wm
  umaddl xd, wn, wm, XZR
end

#uxtb(rd, rn) ⇒ Object



2801
2802
2803
# File 'lib/aarch64.rb', line 2801

def uxtb rd, rn
  ubfm rd, rn, 0, 7
end

#uxth(rd, rn) ⇒ Object



2805
2806
2807
# File 'lib/aarch64.rb', line 2805

def uxth rd, rn
  ubfm rd, rn, 0, 15
end

#wfeObject



2809
2810
2811
# File 'lib/aarch64.rb', line 2809

def wfe
  a WFE.new
end

#wfet(rd) ⇒ Object



2813
2814
2815
# File 'lib/aarch64.rb', line 2813

def wfet rd
  a WFET.new(rd)
end

#wfiObject



2817
2818
2819
# File 'lib/aarch64.rb', line 2817

def wfi
  a WFI.new
end

#wfit(rd) ⇒ Object



2821
2822
2823
# File 'lib/aarch64.rb', line 2821

def wfit rd
  a WFIT.new(rd)
end

#write_to(io) ⇒ Object



2851
2852
2853
# File 'lib/aarch64.rb', line 2851

def write_to io
  io.write to_binary
end

#xaflagObject



2825
2826
2827
# File 'lib/aarch64.rb', line 2825

def xaflag
  a XAFLAG.new
end

#xpacd(rd) ⇒ Object



2829
2830
2831
# File 'lib/aarch64.rb', line 2829

def xpacd rd
  a XPAC.new(rd, 1)
end

#xpaci(rd) ⇒ Object



2833
2834
2835
# File 'lib/aarch64.rb', line 2833

def xpaci rd
  a XPAC.new(rd, 0)
end

#xpaclriObject



2837
2838
2839
# File 'lib/aarch64.rb', line 2837

def xpaclri
  a XPACLRI.new
end

#yieldObject



2841
2842
2843
# File 'lib/aarch64.rb', line 2841

def yield
  a YIELD.new
end