Skip to content

Commit

Permalink
core: arm64: add add_imm and sub_imm assembly macros
Browse files Browse the repository at this point in the history
Adds the add_imm and sub_imm assembly macros capable of adding or
subtracting a 24-bit immediate value to or from a general purpose
register.

Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
jenswi-linaro authored and jforissier committed Aug 30, 2023
1 parent 1188e42 commit 733655e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/arch/arm/include/arm64_macros.S
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@
movk \_reg, :abs_g0_nc:\_val
.endm

.macro add_imm _reg, _val
.if ((\_val) > 0xfff)
add \_reg, \_reg, ((\_val) >> 12), LSL #12
.endif
.if (((\_val) & 0xfff) > 0)
add \_reg, \_reg, ((\_val) & 0xfff)
.endif
.endm

.macro sub_imm _reg, _val
.if ((\_val) > 0xfff)
sub \_reg, \_reg, ((\_val) >> 12), LSL #12
.endif
.if (((\_val) & 0xfff) > 0)
sub \_reg, \_reg, ((\_val) & 0xfff)
.endif
.endm

/*
* Load address of <sym> into <reg>, <sym> being in the range
* +/- 4GB of the PC (note that 'adr reg, sym' is limited to +/- 1MB).
Expand Down

0 comments on commit 733655e

Please sign in to comment.