-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.asm
More file actions
24 lines (23 loc) · 872 Bytes
/
Copy pathsample.asm
File metadata and controls
24 lines (23 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -------------------------
# Code segment (.text)
# -------------------------
.text
main:
add x1, x2, x3 # simple R-format
addi x4, x1, 10 # I-format immediate
sw x4, 0(x5) # S-format store word
lw x6, 0(x5) # I-format load
beq x6, x4, label1 # SB-format branch (forward)
andi x7, x6, 255 # I-format, mask
jal x0, end # UJ-format jump to 'end' (used as termination jump)
label1:
or x8, x7, x1 # R-format
jalr x0, 0(x1) # I-format, return-like (jalr x0, x1, 0)
end:
sd x0, 8(x0) # S-format store double (tests SD encoding)
# -------------------------
# Data segment (.data)
# -------------------------
.data
msg: .asciz "Hi\n" # 4 bytes -> 'H' 'i' '\n' '\0'
val: .dword 0x1122334455667788 # 8-byte value (little-endian)