Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly language (SPARC) program to compute: y = (x-4)(x-14) During ea

ID: 3667160 • Letter: W

Question

Write an assembly language (SPARC) program to compute: y = (x-4)(x-14)

During each iteration, print out a message stating the current value of x and the corresponding value of y. Make sure to define the values of the constants 4 and 14 as constants a1 and a2.

Try to eliminate as many nop instructions as possible and also try to minimize the length of your code. You may run the program using gdb to verify correctness. Make sure to pay close attention to the requirements above.

Output Format:

For input of x = 0, output y = 56

For input of x = 1, output y = 39

For input of x = 10, output y = -24

Requirements:

1. Follow the requirements as described above.

2. Make sure to comment your code.

Explanation / Answer

/*
This program will compute y = (x-4)(x-14)
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,4)

define(a2,14)

define(y_r,l0)
define(y_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 //storing result
  
//printing
set mystring,%o0
move %x_r,%o1
move %y_r,%o2
call printf
nop

add %x_r,1,%x_r // x++

cmp %x_r,10
ble loop
nop

ret
restore

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote