0

所以我必须编写一个程序(上图),它在 -6 <= x <= 5 的域中找到函数的最大值,如果我尝试运行或调试(gdb)程序,终端会输出一条消息说非法指令,特别是“in 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 
4

0 回答 0