so I'm writing a program in Unix and the thing is I can't figure out this last little bit and its a little clutch the assignment is to write a program that tests x values between -2 and 8 for the function X^3 - 14x^2 + 56x - 64. I just can't figure how get it so that it compares the values after the function is finished and then storing the higher one and holding onto it through the next loop and comparing again. Help I could just cheesedick my way through it because I know the answers to the eq but I want a solid blind way of testing.
thanks
oh heres my code so far
define (a1, 14)
define (a2, 56)
define (a3, 64)
define (x_r, -2)
.global main
main:
save %sp, -96, %sp
.global loop
loop:
clr %l0 !initialize %l0 to zero
mov %x_r, %o0 !move x into %o0
call .mul !execute x^2
mov %x_r, %o1
mov %o0, %l2 !store x^2 in %l2
mov %x_R, %O1 !move x into %o1
call .mul !execute x^3
nop
mov %o0, %l3 !store x^3 in %l3
mov %l2, %o0 !moves x^2 into %o0
call .mul
mov %a1, %o1 !moves a1 into %o1
sub %l3, %l2, %l2 !X^3 - 14x^2 stored in %l2
mov %a2, %o0
call .mul
mov %x_r, %01
add %l2, %o0, %l2 !%l2 + 56x stored in %l2
sub %l2, %a3, %l2 !%l2 - 64 stored in %l2
add %x_r, 1, %x_r !x++
cmp %l2, %l0
I would like to put something clever and about me but I fear my company will find it
Posts
b) You haven't mentioned what language you are writing in. I'm going to assume Assembly (which has nothing to do with UNIX). The point about Assembly is it is very difficult to figure out what is going on without sitting down and reading the whole of it. Which people aren't going to do.
The best thing you can do is sit down with a pen and paper and go through it's execution step-by-step. If you honestly don't "get" it, sit down with a book or go and talk to your TA/Professor during office hours.
sorry, I can't spend the time right now to read your code.
B.net: Kusanku
Protip: Assembly is hard as fuck to interpret line by line, especially if you're using subroutines so you're not rewriting the same code over and over. Document it.