IT3030E CA Chap3 ISA Exercises
IT3030E CA Chap3 ISA Exercises
X and Y
Data segment address: 0x10010000
.text
la a0, A
la a1, B
li t0, 100
sw t0, 0(a0) #initialize A[0]=100
sub t3, t3, t4 #i-j, now i and j are both 0
slli t4, t3, 2 #offset of A[i-j]
add a0, a0, t4 #a0 hold addr A[i-j]
lw a0, 0(a0) #load A[i-j]
sw a0, 32(a1) #store to B[8]
❑ Usage:
l Step 1. Load the service number in register a7.
l Step 2. Load argument values, if any, in a0, a1, a2, a3, fa0, ... as
specified.
l Step 3. Issue the ECALL instruction.
l Step 4. Retrieve return values, if any, from result registers as
specified
❑ Example:
li a7, 1
li a0, 0x307
ecall
❑ Result:
❑ Example:
.data
message: .asciz "Khoa \nKy thuat May tinh"
.text
li a7, 4
la a0, message
ecall
❑ Result
❑ Return
l a0 = integer value read
❑ Example:
li a7, 5
ecall