The AArch64 processor (aka arm64), part 2: Extended register operations
source link: https://devblogs.microsoft.com/oldnewthing/20220727-00/?p=106907
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The AArch64 processor (aka arm64), part 2: Extended register operations
Raymond Chen
July 27th, 20223
There are a number of places where the instruction set permits the value in a register to be transformed before it is used. The set of valid transforms vary from instruction to instruction, but they share a common syntax.
Operand | Meaning | |||
---|---|---|---|---|
Shifted | Rn/zr, LSL #n |
Logical shift left. | ||
Rn/zr, LSR #n |
Logical (unsigned) shift right. | |||
Rn/zr, ASR #n |
Arithmetic (signed) shift right. | |||
Extended | Wn/sp, UXTB #n |
Unsigned | extend low byte | shifted left. |
Wn/sp, UXTH #n |
Unsigned | extend low halfword | shifted left. | |
Wn/sp, UXTW #n |
Unsigned | extend low word | shifted left. | |
Xn/sp, UXTX #n |
Unsigned | extend low doubleword | shifted left. | |
Wn/sp, SXTB #n |
Signed | extend low byte | shifted left. | |
Wn/sp, SXTH #n |
Signed | extend low halfword | shifted left. | |
Wn/sp, SXTW #n |
Signed | extend low word | shifted left. | |
Xn/sp, SXTX #n |
Signed | extend low doubleword | shifted left. |
The LSL
, LSR
, and ASR
transformations are formally known as shifted registers. They take a value in a register and shift it.
The extend+shift transformations are formally known as extended registers. They extract a subset of the source register, extend it either as a signed or unsigned value to the full operand size, and then shift the extended result.
Shifting the zero register isn’t particular useful since you still get zero, but the instruction encoding lets you do it. Similarly, there is no practical difference between UXTX
and SXTX
(unsigned and signed extension of the low doubleword of a 64-bit register) since the low doubleword of a 64-bit register is the whole register.
For extended registers, the assembler lets you omit the shift amount, in which case it defaults to zero. The shift amount is not optional for the shifted registers.
Before you get all excited about the possibilities, know that not all instructions support all of these transformations, and for the ones that they do, the shift amounts are limited. We’ll look at the restrictions as they arise. For now, I just wanted to introduce the concepts.
As a convenience, if you are using an instruction that accepts only extended registers, but you want to use a LSL
, you can write LSL #n
, and the assembler will autoconvert it to UXTW #n
or UXTX #n
, depending on the operand size.
Next time, we’ll start putting these transforms to use when we look at addressing modes.
Recommend
-
7
Valgrind is a great tool not only for finding errors related to memory management in a program, but also for memory consumption analysis, performance profiling, issues related to multithreading, and
-
1
The AArch64 processor (aka arm64), part 5: Multiplication and division
-
4
The AArch64 processor (aka arm64), part 12: Memory access and alignment
-
2
The AArch64 processor (aka arm64), part 18: Return address protection
-
2
The AArch64 processor (aka arm64), part 19: Miscellaneous instructions
-
7
The AArch64 processor (aka arm64), part 21: Classic function prologues and epilogues
-
4
The AArch64 processor (aka arm64), part 20: The classic calling convention
-
4
The AArch64 processor (aka arm64), part 22: Other kinds of classic prologues and epilogues
-
7
Running arm64.aarch64 FreeBSD on QEMU/UTM.app on Apple Silicon Around a year ago I got an M1 MacBook Air for work. At this point, a lot of people that I know use these Apple Silicon mach...
-
3
Mar 10, 2023 - 8 minute read - Comments - ARM...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK