我必须找到这条C指令的mips代码: B [8] = A [i-j] 变量i,j位于寄存器$ s3,$ s4中,而基址 A和B中的$ s6,$ s7 当我阅读解决方案时,我不明白为什么在lw指令(代码的第三行)中必须指定偏移量。 我不是在第二行中计算了吗?
非常感谢,感谢您的英语错误。
'''Mips代码
from scipy.integrate import odeint
# define a function containing the derivatives, i.e. the ODE
def glucose(x,t,params):
X,I, G, Y = x
k, alpha, beta, gamma_X, gamma_I, gamma_G, lamda, delta = params
derivs = [k - gamma_X * X - beta * I * X + lamda * G * Y,
alpha * X - gamma_I * I,
delta * Y - gamma_X * G]
return derivs
k = 5.625 #set value
alpha = 1.111 #the rate of insulin production
delta= 1 #the rate of glucagon production
beta = 0.2 #glycogen produced based on insulin
lamda= 0.1 #glucose produced based on glycogen
gamma_X = 0.25 #glucose used
gamma_I = 1.0 #insulin turnover
gamma_G= 0.5 #glucagon turnover
params = [k, alpha, beta, gamma_X, gamma_I, delta, gamma_G, lamda]
X = 6
I = 5
G= 4 #Glucagon
Y= 5 #Glycagon
x0 = [X,I,G,Y]
maxt = 12.0
tstep = 0.05
t = np.arange(0,maxt,tstep)
glucose_out = odeint(glucose, x0, t, args=(params,))
plt.plot(t,glucose_out)
plt.legend(['blood glucose', 'insulin level'])
plt.ylabel('Blood Glucose Level mmol/L , Blood Insulin 10pmol/L')
plt.xlabel('Time/h')
plt.title('Glucose-Insulin Regulation Model')
'''
答案 0 :(得分:0)
您要在此处计算的是字节偏移量:
sub $t0,$s3,$s4
如果我们假设数组中的元素是单词(4个字节)-由于您使用的是lw
和sw
-那么您需要相应地缩放偏移量:
sll $t0, $t0, 2 # $t0 *= 4