mirror of
https://github.com/plctlab/riscv-operating-system-mooc.git
synced 2025-11-16 12:34:47 +00:00
24 lines
768 B
ArmAsm
24 lines
768 B
ArmAsm
# Shift Right Arithmetic Immediate
|
|
# Format:
|
|
# SLLI RD, RS1, IMM
|
|
# Description:
|
|
# The immediate value determines the number of bits to shift. The contents of
|
|
# RS1 is shifted right that many bits and the result is placed in RD. The shift
|
|
# is “arithmetic”, i.e., the sign bit is repeatedly shifted in on the
|
|
# most-significant end.
|
|
# Comment:
|
|
# In C, for signed integer, >> is shift right with arithmetic.
|
|
|
|
.text # Define beginning of text section
|
|
.global _start # Define entry _start
|
|
|
|
_start: # Label, not really required
|
|
# li x6, 0x80 # x6 = 0b1000-0000
|
|
li x6, 0x80000000 # x6 = 0b1000-0000-0000-0000-0000-0000-0000-0000
|
|
srai x5, x6, 4 # x5 = x6 >> 3
|
|
|
|
stop:
|
|
j stop # Infinite loop to stop execution
|
|
|
|
.end # End of file
|