Skip to content

How to enable Floating Point Support in aarch64 (ARM64)

Guille Polito edited this page Sep 30, 2020 · 1 revision

To use Floating Point instructions in aarch64 simulation, Unicorn needs to enable floating point support. In aarch64 this is done by changing some flags in the CPACR_EL1 register.

This can be done with the following code:

unicorn := Unicorn arm64.
wordSize := 8.

"Read the value of CPACR_EL1"
registerBytes := ByteArray new: wordSize.
unicorn register: UcARM64Registers cpacr_el1 value readInto: registerBytes.
cpacr_el1 := registerBytes integerAt: 1 size: wordSize signed: false.

"Set the bits"
cpacr_el1 := cpacr_el1 bitOr: 2r11 << 20.

"Write back the value in the register"
registerBytes := ByteArray new: wordSize.
registerBytes integerAt: 1 put: cpacr_el1 size: wordSize signed: false.
unicorn register: UcARM64Registers cpacr_el1 value write: registerBytes.

After executing that, the unicorn simulator instance will be able to execute floating point instructions.

Clone this wiki locally