因此,我必须编写一个程序(上图),该程序在-6 <= x <= 5的域中找到函数的最大值,如果我尝试运行或调试(gdb)终端输出一条消息,指出非法指令,特别是在“ top()”中。我是汇编语言的新手,但我还是为整个语言而苦苦挣扎,因此希望能提供帮助。
谢谢
我必须摆脱评论,所以现在可能有点混乱
.global main
mov x19, -6 // integer that gets inerated from -6 to 5 (x)
//the following integers are used as the constants for each term in the function
y = -5x^3 - 31x^2 + 4x + 31
mov x24, -5
mov x25, -31
mov x26, 4
mov x27, 0
b main
main:
cmp x19,5
b.le loop
loop:
mul x20, x19, x19
mul x20, x20, x19
mul x20, x20, x24
mul x21, x19, x19
mul x21, x21, x25
mul x22, x19, x26
add x23, x20, x21
add x23, x23, x22
add x23, x23, 31
cmp x23, x27
b.gt top
add x19, x19, 1
b main
top:
mov x27, x23