Illegal instruction in assembly language (ARMv8)

312 Views Asked by At

So I have to write a program (the image above) which finds the max of a function on the domain of -6 <= x <= 5 and if I try to run or debug (gdb) the program the terminal outputs a message saying illegal instruction, specifically "in top ()". I'm new to assembly language and admittedly am struggling with it as a whole so any help would be appreciated.

Thank you

I had to get rid of the comments so it may be a bit confusing now

.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 
0

There are 0 best solutions below