Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:multiasm:paarm:chapter_5_6 [2025/12/03 21:26] – [Arithmetical instructions] eriks.klavinsen:multiasm:paarm:chapter_5_6 [2025/12/03 21:41] (current) – [Data copy/move instructions] eriks.klavins
Line 161: Line 161:
 The register ''<fc #008000>X0</fc>'' holds a memory address. The data/value is loaded into the ''<fc #008000>W2</fc>'' register, and then the value is added to the ''<fc #008000>W1</fc>'' register value, after which the new value ''[<fc #008000>X0</fc>]+<fc #008000>W1</fc>'' is stored back into memory at the exact location pointed by ''[<fc #008000>X0</fc>]''. Basically, the ''<fc #008000>W2</fc>'' register now holds the ''[<fc #008000>X0</fc>]''- pointed data that was present before the ''<fc #008000>W1</fc>'' value was added. Similar instructions are available to perform atomic logic operations on the memory data. The register ''<fc #008000>X0</fc>'' holds a memory address. The data/value is loaded into the ''<fc #008000>W2</fc>'' register, and then the value is added to the ''<fc #008000>W1</fc>'' register value, after which the new value ''[<fc #008000>X0</fc>]+<fc #008000>W1</fc>'' is stored back into memory at the exact location pointed by ''[<fc #008000>X0</fc>]''. Basically, the ''<fc #008000>W2</fc>'' register now holds the ''[<fc #008000>X0</fc>]''- pointed data that was present before the ''<fc #008000>W1</fc>'' value was added. Similar instructions are available to perform atomic logic operations on the memory data.
  
-To copy content from one register to another, the ''<fc #800000>MOV</fc>'' instruction is used. The ''<fc #800000>FMOV</fc>'' instruction can also copy floating-point values. These instructions allow typecasting a floating-point value to an integer and vice versa.\\ +To copy content from one register to another, the ''<fc #800000>MOV</fc>'' instruction is used. The ''<fc #800000>FMOV</fc>'' instruction can also copy floating-point values. These instructions allow typecasting a floating-point value to an integer and vice versa. Here are some independent instruction examples\\ 
-''MOV X1, X0      @ X1 = X0 (64 bit register copy)''\\ +''<fc #800000>MOV</fc> <fc #008000>X1</fc><fc #008000>X0</fc> <fc #6495ed>@ X1 = X0 (64 bit register copy)</fc>''\\ 
-''MOV W1, W0      @ W1 = W0 (32 bit register copy)''\\ +''<fc #800000>MOV</fc> <fc #008000>W1</fc><fc #008000>W0</fc> <fc #6495ed>@ W1 = W0 (32 bit register copy)</fc>''\\ 
-''FMOV S1, S0     @ float → float (32-bit floating-point copy between vector registers)''\\ +''<fc #800000>FMOV</fc> <fc #008000>S1</fc><fc #008000>S0</fc> <fc #6495ed>@ float → float (32-bit floating-point copy between vector registers)</fc>''\\ 
-''FMOV X0, D1     @ FP64 → int64 (copy from vector register to general-purpose register)''\\ +''<fc #800000>FMOV</fc> <fc #008000>X0</fc><fc #008000>D1</fc> <fc #6495ed> @ FP64 → int64 (copy from vector register to general-purpose register)</fc>''\\ 
-''FMOV D2, X3     @ int64 → FP64 (copy from general-purpose register to vector register)''\\ +''<fc #800000>FMOV</fc> <fc #008000>D2</fc><fc #008000>X3</fc> <fc #6495ed>@ int64 → FP64 (copy from general-purpose register to vector register)</fc>''\\ 
-''MOV V1.16b, V0.16b @ vector register copy one byte''\\ +''<fc #800000>MOV</fc> <fc #008000>V1</fc>.<fc #808000>16b</fc><fc #008000>V0</fc>.<fc #808000>16b</fc> <fc #6495ed>@ vector register copy one byte</fc>''\\ 
-The MOV instructions can also be used to write a value into the register immediately:\\ +The ''<fc #800000>MOV</fc>'' instructions can also be used to write a value into the register immediately. In the following example, all instructions are executed one by one:\\ 
-''MOV X0, #123 @ assign value 291 to the register''\\ +''<fc #800000>MOV</fc> <fc #008000>X0</fc><fc #ffa500>#123</fc> <fc #6495ed>@ assign value 291 to the register</fc>''\\ 
-''MOVZ X0, #0x1234, LSL #48 @ int64''\\ +''<fc #800000>MOVZ</fc> <fc #008000>X0</fc><fc #ffa500>#0x1234</fc><fc #800080>LSL</fc> <fc #ffa500>#48</fc><fc #6495ed> X0 = 0x1234 0000 0000 0000. The X0 value gets overvritten</fc>''\\ 
-''MOVK X0, #0xABCD, LSL #0 @ int64''\\+''<fc #800000>MOVK</fc> <fc #008000>X0</fc><fc #ffa500>#0xABCD</fc><fc #800080>LSL</fc> <fc #ffa500>#0</fc> <fc #6495ed>X0 = 0x1234 0000 0000 ABCD, if before instruction execution the register value was 0x1234 0000 0000 0000</fc>''
  
  
 +===== Data copy/move instructions =====
  
 +These instructions do not work with values that require arithmetic operations. Still, they are mainly used to manipulate individual bits in registers, widely used to test or verify values, and to perform other functions. Basic logic instructions for AARCH64 are:\\
 +''<fc #800000>AND</fc> <fc #008000>X0</fc>, <fc #008000>X1</fc>, <fc #008000>X2</fc> <fc #6495ed>@ logical AND between X1 and X2, result is stored in X0</fc>''\\
 +''<fc #800000>ORR</fc> <fc #008000>X6</fc>, <fc #008000>X7</fc>, <fc #008000>X8</fc> <fc #6495ed>@ logical OR between X7 and X8, result is stored in X6</fc>''\\
 +''<fc #800000>EOR</fc> <fc #008000>X12</fc>, <fc #008000>X13</fc>, <fc #008000>X14</fc> <fc #6495ed>@ logical XOR between X13 and X14, result is stored in X12</fc>''\\
 +''<fc #800000>NEG</fc> <fc #008000>X24</fc>, <fc #008000>X25</fc> <fc #6495ed>@ logical NOT, X24 is set to inverted X25</fc>''
 +
 +Remember that most instructions, which operate with registers, can update the status register by adding the postfix S at the end of the instruction. Logical instructions are fundamental for low-level programming. These instructions allow taking control over bits and are widely used in system code, device drivers, and embedded systems. Some instructions can perform combined bitwise operations, like ''<fc #800000>ORN</fc>'', which performs an OR operation with the inverted second operand. 
en/multiasm/paarm/chapter_5_6.1764797173.txt.gz · Last modified: 2025/12/03 21:26 by eriks.klavins
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0