Rupert Swarbrick | a2789b0 | 2020-07-24 18:25:28 +0100 | [diff] [blame] | 1 | /* Copyright lowRISC contributors. */ |
| 2 | /* Licensed under the Apache License, Version 2.0, see LICENSE for details. */ |
| 3 | /* SPDX-License-Identifier: Apache-2.0 */ |
| 4 | /* |
| 5 | An example of the pseudo-operations supported by the OTBN ISA |
| 6 | */ |
Rupert Swarbrick | 9b1392e | 2021-10-26 17:39:34 +0100 | [diff] [blame] | 7 | .section .text.start |
Rupert Swarbrick | a2789b0 | 2020-07-24 18:25:28 +0100 | [diff] [blame] | 8 | |
| 9 | nop_example: |
| 10 | /* NOP is a no-op, and expands to addi x0, x0, 0 */ |
| 11 | nop |
| 12 | |
| 13 | ret_example: |
| 14 | /* RET is a return and expands to jalr x0, x1, 0 */ |
| 15 | ret |
| 16 | |
| 17 | li_example: |
| 18 | /* LI is a bit more complicated. With a small immediate, it turns |
| 19 | into just addi */ |
| 20 | li x2, 1230 |
| 21 | li x2, -123 |
Rupert Swarbrick | c35c520 | 2020-10-06 08:41:08 +0100 | [diff] [blame] | 22 | li x2, 2272 |
Rupert Swarbrick | a2789b0 | 2020-07-24 18:25:28 +0100 | [diff] [blame] | 23 | |
| 24 | /* With a big immediate which happens to have nothing set in the |
| 25 | lower 20 bits, it turns into just a LUI */ |
| 26 | li x2, 1048576 |
| 27 | li x2, -0x800000 |
| 28 | |
| 29 | /* With a big immediate in general, we need 2 instructions. |
| 30 | Firstly, a LUI to set up the upper bits, then an ADDI to sort out |
| 31 | the lower ones. */ |
| 32 | li x2, 0x10000042 |
| 33 | |
| 34 | li x2, 123456789 |
| 35 | li x2, 0x7fffffff |