49
Young Won Lim 9/12/19 ISA Binary Encoding (5A)

ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

Young Won Lim9/12/19

ISA Binary Encoding (5A)

Page 2: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

Young Won Lim9/12/19

Copyright (c) 2014 - 2019 Young W. Lim.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

Please send corrections (or suggestions) to [email protected].

This document was produced by using LibreOffice.

Page 3: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

3 Young Won Lim9/12/19

Based on

ARM System-on-Chip Architecture, 2nd ed, Steve Furber

Page 4: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (4A)Assembler Format

4 Young Won Lim9/12/19

ARM

Rn 1st Operand Reg / Base Reg

Rd Left most Reg : Source / Destination Reg

Set Condition Codes / Signed / Restore PSR and force user bit S

Pre/Post IndexP

Up/DownU

Unsigned Byte/WordB

Write-back (auto-index)W

Link / Load/StoreL

Half-word AddressH

4-bit op codesOpcode

2nd Operand Reg / Operand Reg / Offset Reg / Source Reg Rm

Shift type Sh

CPSR/SPSRR

Page 5: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (4A)Assembler Format

5 Young Won Lim9/12/19

ARM

Rn 1st Operand Reg / Base Reg

Rd Source / Destination Reg

Set Condition Codes / Signed / Restore PSR and force user bit S

Unsigned Byte/WordB

Link / Load/StoreL

Half-word AddressH

2nd Operand Reg / Operand Reg / Offset Reg / Source Reg Rm

Selects the user view in the non-usermodesT

Page 6: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (4A)Assembler Format

6 Young Won Lim9/12/19

ARM

<cond> Conditions for conditional execution

CPSR Current Program Status Register

Saved Program Status RegisterSPSR

The most significant 32-bitsRdHi

The least significant 32-bitsRdLo

aa

aa

aa

aa

aa

Shift type and the shift amount (except RRX)<shift>

aa

aRa

Page 7: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (4A)Assembler Format

7 Young Won Lim9/12/19

ARM

<CP#> Coprocessor number

<Cop2> Coprocessor operation 2

Coprocessor RdCRd

Coprocessor RnCRn

Coprocessor RmCRm

a<CP#>

aa

a<Cop2>

a<Cop1>

aa

Coprocessor operation 1<Cop1>

aa

aa

Page 8: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

8 Young Won Lim9/12/19

All listings

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 # opcode S Rn Rd Operand 2

cond 0 0 0 0 0 0 A S Rd Rn

cond 0 0 0 1 0 B 0 0 Rn Rd 1 0 0 1 Rm

cond 0 0 0 0 1 U A S RdHi RdLo 1 0 0 1 Rm

Rs 1 0 0 1 Rm

Rn

0 0 0 0

cond Offset

cond 0 0 0 1 0 0 1 0 0 0 0 1 Rn1 1 1 1 1 1 1 1 1 1 1 1

1 0 1 L

cond 0 1 # P U B W L Rn Rd offset

cond 0 0 0 P U 1 W L Rn Rd offsetH 1 S H 1 offsetL

cond 0 0 0 P U 0 W L Rn Rd 0 0 0 0 1 S H 1 Rm

cond 0 1 1 1

cond 1 0 0 P U S W L Rn Register list

cond

cond 1 1 1 0 CP Opc CP 0 CRm

cond 1 1 1 0 CP Opc L

1 1 0 P U N W L OffsetRn CRd CP#

CRn CRd CP#

CP 1 CRmCRn Rd CP#

cond 1 1 1 1 Ignored by processor

(1)

(2)

(4)

(3)

(5)

(11)

(8)

(7)

(6)

(9)

(10)

(13)

(14)

(12)

(15)

Page 9: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

9 Young Won Lim9/12/19

All listings

Data Processing / PSR Transfer

Multiply

Single Data Swap

Multiply Long

Branch

Branch and Exchange

Single Data Transfer

Halfword Data Transfer: immediate offset

Halfword Data Transfer: register offset

Undefined

Block Data Transfer

Coprocessor Data Transfer

Coprocessor Data Operation

Coprocessor Register Transfer

Software Interrupt

(1)

(2)

(4)

(3)

(5)

(11)

(8)

(7)

(6)

(9)

(10)

(13)

(14)

(12)

(15)

Rd := Rn <op> operand2 (shifted)

Rd := Rm * Rs + Rn

Rd := [Rn]; [Rn]:= Rm

RdHi : RdLo := Rm * Rs

PC := Offset

PC := Rn; (Rn[0]=1 Thumb, else ARM)

Rd :=: [Rn, Offset] / [Rn], Offset

Rd :=: [Rn, Offset] / [Rn], Offset

Rd :=: [Rn, Rm] / [Rn], Rm

[Rn, i] :=: {Register List}

CRd :=: [Rn,Offset] / [Rn], Offset

CRd :=: CRn <CP Opc, CP> CRm

Rd :=: CRn <CP Opc, CP> CRm

Page 10: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

10 Young Won Lim9/12/19

All listings

Data Processing / PSR Transfer

Multiply

Single Data Swap

Multiply Long

Branch

Branch and Exchange

Single Data Transfer

Halfword Data Transfer: immediate offset

Halfword Data Transfer: register offset

Undefined

Block Data Transfer

Coprocessor Data Transfer

Coprocessor Data Operation

Coprocessor Register Transfer

Software Interrupt

(1)

(2)

(4)

(3)

(5)

(11)

(8)

(7)

(6)

(9)

(10)

(13)

(14)

(12)

(15)

I, Opcode, S, Rn, Rd, Operand2

A, S, Rd, Rn, Rs, Rm

B, Rn, Rd, Rm

U, A, S, RdHi, RdLo, Rn, Rm

L, Offset

Rm

P, U, B, W, L, Rn, Rd, Offset

P,U, W, L, Rn, Rd, Offset, S, H, Offset

Rd <=>

P, U, S, W, L, Rn, Register List

P, U, N, W, L, Rn , CRd, CP#, Offset

CP Opc, CRn, CRd, CP#, CP, CRm

CP Opc, L, CRn, Rd, CP# CP, CRm

Software Interrupt

Page 11: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

11 Young Won Lim9/12/19

Data Transfer Instructions

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 1 # P U B W L Rn Rd offset

cond 0 0 0 P U 1 W L Rn Rd offsetH 1 S H 1 offsetL

cond 1 0 0 P U S W L Rn Register list

Single Data Transfer

Halfword Data Transfer – Immediate Offset

cond 0 0 0 P U 0 W L Rn Rd 0 0 0 0 1 S H 1 Rm

Halfword Data Transfer – Register Offset

Block Data Transfer

Page 12: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

12 Young Won Lim9/12/19

Data Processing Instructions

cond 0 0 # opcode S Rn Rd Operand 2

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 0 0 0 A S Rd Rn

cond 0 0 0 1 0 B 0 0 Rn Rd 1 0 0 1 Rm

Data Processing PSR Transfer

Multiply

Single Data Swap

cond 0 0 0 0 1 U A S RdHi RdLo 1 0 0 1 Rm

Multiply Long

Rs 1 0 0 1 Rm

Rn

0 0 0 0

Page 13: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

13 Young Won Lim9/12/19

Branch and Branch Exchange

cond Offset

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 1 0 0 1 0

Branch

Branch and Exchange

0 0 0 1 Rn

cond 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 L 1 Rm

Branch with Link an eXchange

1 1 1 1 1 1 1 1 1 1 1 1

1 0 1 L

Page 14: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

14 Young Won Lim9/12/19

Coprocessor Instructions

cond

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 1 1 1 0 CP Opc

Coprocessor Data Transfer

Coprocessor Data Operation

CP 0 CRm

cond 1 1 1 0 CP Opc L

Coprocessor Register Transfer

1 1 0 P U N W L OffsetRn CRd CP#

CRn CRd CP#

CP 1 CRmCRn Rd CP#

Page 15: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

15 Young Won Lim9/12/19

Miscellaneous Instructions

cond

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 1 1 1 1

Undefined

Software Interrupt

Ignored by processor

0 1 1 1

Page 16: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

16 Young Won Lim9/12/19

ARM

Rn 1st Operand Reg / Base Reg

Rd Source/Destination Reg

2nd Operand Reg / Source Reg / Offset Reg / Operand RegRm

cond 0 0 # opcode S Rn Rd Operand 2

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 1 0 1 1 0 0 0 0 0 Rd 0 0 0 0 0 0 0 1 Rm

cond 0 1 # P U B W L Rn Rd offset

cond 0 0 0 P U # W L Rn Rd offsetH 1 S H 1 offsetL

cond 1 0 0 P U S W L Rn Register list

cond 0 0 0 1 0 B 0 0 Rn Rd 0 0 0 0 1 0 0 1 Rm

cond 0 0 0 1 0 R 0 0 1 1 1 1 Rd 0 0 0 0 0 0 0 0 0 0 0 0

cond 0 0 0 1 0 R 1 0 field 1 1 1 1 0 0 0 0 0 0 0 0 Rm

Page 17: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

17 Young Won Lim9/12/19

ARM

cond 0 0 # opcode S Rn Rd Operand 2

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 1 0 1 1 0 0 0 0 0 Rd 0 0 0 0 0 0 0 1 Rm

cond 0 1 # P U B W L Rn Rd offset

cond 0 0 0 P U 1 W L Rn Rd offsetH 1 S H 1 offsetL

cond 1 0 0 P U S W L Rn Register list

cond 0 0 0 1 0 R 0 0 1 1 1 1 Rd 0 0 0 0 0 0 0 0 0 0 0 0

cond 0 0 0 1 0 R 1 0 field 1 1 1 1 0 0 0 0 0 0 0 0 Rm

Data Processing PSR Transfer

????

Single Data Transfer

Halfword Data Transfer – Immediate Offset

cond 0 0 0 P U 0 W L Rn Rd 0 0 0 0 1 S H 1 Rm

Halfword Data Transfer – Register Offset

Block Data Transfer

Page 18: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

18 Young Won Lim9/12/19

Condition Code

cond

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 19: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

19 Young Won Lim9/12/19

ARM Condition Codes

0 0 0 0 EQ EQual / EQuals zero Z←1

31 30 29 28

0 0 0 1 NE Not Equal Z←0

0 0 1 0

NV

Carry Set / unsigned High or Same C←1

0 0 1 1

CS/HS

Carry Clear / unsigned Lower C←0

0 1 0 0

CC/LO

MInus / negative N←1

0 1 0 1

MI

PLus / positive or zero N←0

0 1 1 0

PL

oVerflow Set V←1

0 1 1 1

VS

oVerflow Clear V←0

1 0 0 0

VC

unsigned HIgher C←1, Z←0

1 0 0 1

HI

unsigned Lower or Same C←0, Z←1

1 0 1 0

LS

signed Greater than or Equal N == V

1 0 1 1

GE

signed Less Than N != V

1 1 0 0

LT

signed Greater Than Z←0, N==V

1 1 0 1

GT

signed Less than or Equal Z←1, N!=V

1 1 1 0

LE

ALways any

1 1 1 1

AL

NeVer (do not use?) none

Page 20: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

20 Young Won Lim9/12/19

Branch and Branch with Link (B, BL)

cond 1 0 1 L 24-bit signed word offset

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Branch and Branch with Link

Page 21: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

21 Young Won Lim9/12/19

Branch, Branch with Link and eXchange (BX, BLX)

cond 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 L 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 1 1 1 1 0 1 H 24-bit signed word offset

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Branch with Link an eXchange

Branch with Link an eXchange

Page 22: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

22 Young Won Lim9/12/19

SWI (Software Interrupt)

cond 1 1 1 1 24-bit (interpreted) immediate

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

SWI

Page 23: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

23 Young Won Lim9/12/19

Data Processing Instructions

cond 0 0 # opcode S Rn Rd Operand 2

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Rs 0 Sh 1

11 10 9 8 7 6 5 4

cond 0 0 1 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

#rot 8-bit immediate

11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

#shift Sh 0 Rm

11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

Rm

3 2 1 0

Data Processing

Data Processing

Data Processing with a shifted operand

Data Processing with a shifted operand

Page 24: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

24 Young Won Lim9/12/19

Data Processing Instructions – shift

Rs 0 Sh 1

11 10 9 8 7 6 5 4

cond 0 0 0 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

#shift Sh 0 Rm

11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

Rm

3 2 1 0

Shift RmADD r3, r2, r1, LSL #3 ; r3 := r2 + r1*2^3ADD r5, r5, r3, LSL r2 ; r5 := r5 + r3*2^r2MOV r0, r0, LSR #2 ; r0 := r0 / 2^2

cond 0 0 1 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

#rot 8-bit immediate

11 10 9 8 7 6 5 4 3 2 1 0

Rotate 8-bit immediate0xA_05 // rotate 0x05 right by 20 (=2 * 0xA)0xB_14 // rotate 0x14 right by 22 (=2 * 0xB)0xC_50 // rotate 0x50 right by 24 (=2 * 0xC)

Data Processing with a shifted operand

Data Processing with a shifted operand

Data Processing with a shifted operand

Page 25: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

25 Young Won Lim9/12/19

Data Processing Instructions – shift

Rs 0 Sh 1

11 10 9 8 7 6 5 4

cond 0 0 0 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

#shift Sh 0 Rm

11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 opcode S Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

Rm

3 2 1 0

Shift Rm<Sh> {cond}{S} Rd, Rm, Rs

<Sh> {cond}{S} Rd, Rm, #n

RRX {cond}{S} Rd, Rm

00 Logical Left

01 Logical Right

10 Arithmetic Right

11 Rotate Right

Sh Shift Type

Data Processing with a shifted operand

Data Processing with a shifted operand

Page 26: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

26 Young Won Lim9/12/19

Data Processing Instructions

cond 0 0 # 0000 S

31 30 29 28 27 26 25 24 23 22 21 20

AND Rd := Rn AND Op2Logical bit-wise AND

cond 0 0 # 0001 S EOR Rd := Rn EOR Op2Logical bit-wise XOR

cond 0 0 # 0010 S SUB Rd := Rn – Op2Subtract

cond 0 0 # 0011 S RSB Rd := Op2 – RnReverse Subtract

cond 0 0 # 0100 S ADD Rd := Rn + Op2Add

cond 0 0 # 0101 S ADC Rd := Rn + Op2 + C Add with carry

cond 0 0 # 0110 S SBC Rd := Rn – Op2 + C – 1Subtract with carry

cond 0 0 # 0111 S RSC Rd := Op2 – Rn + C – 1Reverse subtract with carry

cond 0 0 # 1000 S TST Rn AND Op2Test

cond 0 0 # 1001 S TEQ Rn EOR Op2Test equivalence

cond 0 0 # 1010 S CMP Rn – Op2Compare

cond 0 0 # 1011 S CMN Rn + Op2Compare negated

cond 0 0 # 1100 S ORR Rd := Rn OR Op2Logical bit-wise OR

cond 0 0 # 1101 S MOV Rd := Op2Move

cond 0 0 # 1110 S BIC Rd := Rn AND NOT Op2Bit clear

cond 0 0 # 1111 S MVN Rd := NOT Op2Nive begated

cond 0 0 0 opcode S

31 30 29 28 27 26 25 24 23 22 21 20

Page 27: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

27 Young Won Lim9/12/19

Multiply Instructions

N 0 0 0 0 mul S Rd/RdHi Rn/RdLo Rs 1 0 0 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Multiply

Page 28: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

28 Young Won Lim9/12/19

Multiply Instructions

N 0 0 0 0 mul S Rd/RdHi Rn/RdLo Rs 1 0 0 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 0 0 MUL Multiply (32-bit result) Rd := (Rm * Rs)[31:0]

0 0 1 MLA Multiply-accumulate (32-bit result) Rd := (Rm * Rs)[31:0]

1 0 0 UMULL Unsigned multiply long RdHi.RdLo := Rm * Rs

1 0 1 UMLAL Unsigned multiply-accumulate long RdHi.RdLo += Rm * Rs

1 1 0 SMULL Signed multiply long RdHi.RdLo := Rm * Rs

1 1 1 SMLAL Signed multiply-accumulate long RdHi.RdLo += Rm * Rs

Multiply

Page 29: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

29 Young Won Lim9/12/19

CLZ (Count leading zeros)

cond 0 0 0 1 0 1 1 0 0 0 0 0 Rd 0 0 0 0 0 0 0 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

CLZ

Page 30: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

30 Young Won Lim9/12/19

Data Transfer Instructions

cond 0 1 # P U B W L Rn Rd offset

cond 1 0 0 P U S W L Rn Register list

Page 31: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

31 Young Won Lim9/12/19

Single word and unsigned byte data transfer instructions

cond 0 1 # P U B W L Rn Rd offset

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 1 0 P U B W L Rn Rd offset

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 1 1 P U B W L Rn Rd

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

R Sh 0 R

Page 32: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

32 Young Won Lim9/12/19

Half-word and signed byte data transfer instructions

N 0 0 0 P U # W L Rn Rd offsetH 1 S H 1 offsetL

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

N 0 0 0 P U 1 W L Rn Rd Imm[7:4] 1 S H 1 Imm[3:0]

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 0 0 0N 0 0 0 P U 0 W L Rn Rd 1 S H 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 33: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

33 Young Won Lim9/12/19

Multiple register transfer instruction

cond 1 0 0 P U S W L Rn Register list

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

U=1 : IncrementP=1 : before

U : Up/DownP : Pre/Post

U=0 : DecrementP=0 : after

W : Write-back (auto index)

W=1 : auto indexW=0 : no auto index

IB PU=11IA PU=01DB PU=10DA PU=00

DA PU=00IA PU=01DB PU=10IB PU=11

L=1 : LDML=0 : STM

Name Stack Block L P UPre-Increment Load LDMED LDMIB 1 1 1Post-Increment Load LDMFD LDMIA 1 0 1Pre-Decrement Load LDMEA LDMDB 1 1 0Post-Decrement Load LDMFA LDMDA 1 0 0Pre-Increment Store STMFA STMIB 0 1 1Post-Increment Store STMEA STMIA 0 0 1Pre-Decrement Store STMFD STMDB 0 1 0Post-Decrement Store STMED STMDA 0 0 0

Page 34: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

34 Young Won Lim9/12/19

Multiple register transfer instruction

cond 1 0 0 P U S W L Rn Register list

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

STMIA R8! {R0,R1,R4}

STMIB R8! {R0,R1,R4}

STMDA R8! {R0,R1,R4}

STMDB R8! {R0,R1,R4}

STMEA R8! {R0,R1,R4}

STMFA R8! {R0,R1,R4}

STMED R8! {R0,R1,R4}

STMFD R8! {R0,R1,R4}LDMIA R8! {R0,R1,R4}

LDMIB R8! {R0,R1,R4}

LDMDA R8! {R0,R1,R4}

LDMDB R8! {R0,R1,R4}

LDMFD R8! {R0,R1,R4}

LDMED R8! {R0,R1,R4}

LDMFA R8! {R0,R1,R4}

LDMEA R8! {R0,R1,R4}

IB PU=11IA PU=01DB PU=10DA PU=00

Page 35: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

35 Young Won Lim9/12/19

Swap memory and register instruction (SWP)

cond 0 0 0 1 0 B 0 0 Rn Rd 0 0 0 0 1 0 0 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 36: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

36 Young Won Lim9/12/19

Status register to general register transfer instructions

cond 0 0 0 1 0 R 0 0 1 1 1 1 Rd 0 0 0 0 0 0 0 0 0 0 0 0

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 37: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

37 Young Won Lim9/12/19

General register to status register transfer instructions

cond 0 0 # 1 0 R 1 0 field 1 1 1 1 operand

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 1 1 0 R 1 0 field 1 1 1 1

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

cond 0 0 0 1 0 R 1 0 field 1 1 1 1

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12

#rot 8-bit immediate

11 10 9 8 7 6 5 4 3 2 1 0

0 0 0 0 0 0 0 0 Rm

11 10 9 8 7 6 5 4 3 2 1 0

Page 38: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

38 Young Won Lim9/12/19

Coprocessor data operations

cond 1 1 1 0 Cop1 CRn CRd CP# Cop2 0 CRm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 39: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

39 Young Won Lim9/12/19

Coprocessor data transfers

N 1 1 0 P U N W L Rn CRd CP# 8-bit offset

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 40: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

40 Young Won Lim9/12/19

Coprocessor register transfer

N 1 1 1 0 Cop1 L CRn Rd CP# Cop2 1 CRm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 41: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

41 Young Won Lim9/12/19

Breakpoint instruction (BKPT)

1 1 1 0 0 0 0 1 0 0 1 0 x x x x x x x x x x x x 0 1 1 1 x x x x

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 42: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

42 Young Won Lim9/12/19

Unused arithmetic instructions

cond 0 0 0 0 0 1 Op Rn Rd Rs 1 0 0 1 R

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 43: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

43 Young Won Lim9/12/19

Unused control instructions

cond 0 0 0 1 0 op1 0 Rn Rd Rs R R R R R R R R

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 1 0 op1 0 Rn Rd Rs 0 op2 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

cond 0 0 0 1 0 op1 0 Rn Rd #rot 8-bit immediate

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 44: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

44 Young Won Lim9/12/19

Unused load/store instructions

cond 0 0 0 P U B W L Rn Rd Rs 1 op1 1 Rm

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 45: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

45 Young Won Lim9/12/19

Unused coprocessor instructions

cond 1 1 0 0 op 0 X Rn CRd CP# offset

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 46: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

46 Young Won Lim9/12/19

Undefined instruction space

cond 0 1 1 X X X X X X X X X X X X X X X X X X X X 1 X X X X

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 47: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

47 Young Won Lim9/12/19

Multiple register transfer instruction

N Z C V R R R R R R R R R R R R R R R R R R R R R R R R R R R R

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 48: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

48 Young Won Lim9/12/19

ARM Exception Handling

N Z C V R R R R R R R R R R R R R R R R R R R R R R R R R R R R

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Page 49: ISA Binary Encoding (5A) · ISA (5A) Binary Encoding 10 Young Won Lim 9/12/19 All listings Data Processing / PSR Transfer Multiply Single Data Swap Multiply Long Branch Branch and

ISA (5A)Binary Encoding

49 Young Won Lim9/12/19

References

[1] ftp://ftp.geoinfo.tuwien.ac.at/navratil/HaskellTutorial.pdf[2] https://www.umiacs.umd.edu/~hal/docs/daume02yaht.pdf