mirror of
https://github.com/plctlab/riscv-operating-system-mooc.git
synced 2025-11-16 12:34:47 +00:00
24 lines
718 B
ArmAsm
24 lines
718 B
ArmAsm
# Add Upper Immediate to PC
|
|
# Format:
|
|
# AUIPC RD, IMM
|
|
# Description:
|
|
# AUIPC is used to build pc-relative addresses and uses the U-type format.
|
|
# AUIPC forms a 32-bit offset from the 20-bit U-immediate, filling in the
|
|
# lowest 12 bits with zeros, adds this offset to the address of the AUIPC
|
|
# instruction, then places the result in register RD.
|
|
# Note:
|
|
# The current PC can be obtained by setting the U-immediate to 0.
|
|
|
|
.text # Define beginning of text section
|
|
.global _start # Define entry _start
|
|
|
|
_start: # Label, not really required
|
|
auipc x6, 0 # x6 = PC
|
|
auipc x5, 0x12345 # x5 = PC + (0x12345 << 12)
|
|
|
|
|
|
stop:
|
|
j stop # Infinite loop to stop execution
|
|
|
|
.end # End of file
|