]> gitweb.factorcode.org Git - factor.git/commitdiff
arm64: ADR ADRP fix encoding
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 14 Mar 2021 02:38:44 +0000 (20:38 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 17 Jun 2022 22:17:37 +0000 (17:17 -0500)
basis/cpu/arm/assembler/assembler.factor
basis/cpu/arm/assembler/opcodes/opcodes-tests.factor

index fe9214f89e84968b85005634f2229c40fab8845d..86664ebb1cc513aabd418285c5f4f4809813804f 100644 (file)
@@ -22,10 +22,10 @@ TUPLE: arm64-assembler ip labels out ;
 : >out ( instruction -- ) arm64-assembler get out>> push ;
 
 : ADR ( imm21 Rd -- )
-    [ [ 2 bits ] [ 19 bits ] bi ] dip ADR-encode >out ;
+    [ [ 2 bits ] [ -2 shift 19 bits ] bi ] dip ADR-encode >out ;
 
 : ADRP ( imm21 Rd -- )
-    [ [ 2 bits ] [ 19 bits ] bi ] dip ADRP-encode >out ;
+    [ [ 2 bits ] [ -2 shift 19 bits ] bi ] dip ADRP-encode >out ;
 
 : BL ( offset -- ) ip - 4 / BL-encode >out ;
 : BR ( register -- ) BR-encode >out ;
index 905867ea9c351b66a9d2b3f87eff538c0528c063..77c9d0255f6d14bb836c8b24a61d978a90da94d4 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2020 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: cpu.arm.assembler.opcodes math math.bitwise tools.test ;
+USING: cpu.arm.assembler cpu.arm.assembler.opcodes math
+math.bitwise tools.test ;
 IN: cpu.arm.assembler.opcodes.tests
 
 { 0b00011010000000110000000001000001 } [ X3 X2 X1 ADC32-encode ] unit-test
@@ -16,3 +17,10 @@ IN: cpu.arm.assembler.opcodes.tests
 
 ! stp x29, x30, [sp,#-16]!
 { 0xa9bf7bfd } [ -16 8 / 7 bits X30 SP X29 STPpre64-encode ] unit-test
+
+
+{ B{ 0 0 0 0x10 } } [ [ 0 X0 ADR ] assemble-arm ] unit-test
+{ B{ 0 0 0 0x30 } } [ [ 1 X0 ADR ] assemble-arm ] unit-test
+
+{ B{ 0 0 0 0x90 } } [ [ 0 X0 ADRP ] assemble-arm ] unit-test
+{ B{ 0 0 0 0xb0 } } [ [ 1 X0 ADRP ] assemble-arm ] unit-test