数组
clear1(long long int array[], size_t int size) { int i; for (i = 0; i < size; i += 1) array[i] = 0; } li x5,0 // i = 0
loop1: slli x6,x5,3 // x6 = i * 8 add x7,x10,x6 // x7 = address // of array[i] sd x0,0(x7) // array[i] = 0 addi x5,x5,1 // i = i + 1 blt x5,x11,loop1 // if (i<size) go to loop1 array[] in x10, size in x11, i in x5
stack
addi sp,sp,-40 // make room on stack for 5 regs sd x1,32(sp) // save x1 on stack sd x22,24(sp) // save x22 on stack sd x21,16(sp) // save x21 on stack sd x20,8(sp) // save x20 on stack sd x19,0(sp) // save x19 on stack
exit1: sd x19,0(sp) // restore x19 from stack sd x20,8(sp) // restore x20 from stack sd x21,16(sp) // restore x21 from stack sd x22,24(sp) // restore x22 from stack sd x1,32(sp) // restore x1 from stack addi sp,sp, 40 // restore stack pointer jalr x0,0(x1)