I am trying to write the following code for the sparc machine.
y=(x-7)(x-11) for the range 0<=x<=10
and I want to print out the following code like this for input of x=0 output y=77
and so on up to ten.
I managed to make the loop. But my problem is getting the output printed out.
/*
This program will compute y=(x-7)(x-11)
for the range 0<=x<=10
*/
/*
these are the variables
*/
.section ".data"
mystring:.asciz "for input of x=%d and output y=%d"
define(a1,7)
define(a2,11)
define(x_r,l0)
define(x_r,l1)
.section ".text"
main:
save %sp,-96,%sp
clr %x_r
loop:
sub %x_r,a1,%o0 !(x-a1)
sub %x_r,a2,%o1 !(x-a2)
call .mul
nop
mov %o0,%y_r
add %x_r,1,%x_r
cmp %x_r,10
ble loop
nop
ret
restore
I know I have to print something like this on my code but Im not sure where.
set mystring,%o0
move %x_r,%o1
move %y_r,%o2
call printf
nop
THe output I get now is
for input of x=0 output y=77 for input of x=1 output y=60 for input of x=2 output y=45 for input of x=3 output y=32 for input of x=4 output y=21 for input of x=5 output y=12 for input of x=6 output y=5 for input of x=7 output y=0 for input of x=8 output y=-3 for input of x=9 output y=-4 for input of x=10 output y=-3
I would like it like this
for input of x=0 output y=77
for input x=1 output y=60
......
......
for input x=10 y=-3