Write a function (subroutine) that inputs a data value in register r0 and returns value in r0. The function returns y = a + bx + cx2 where a, b, c are parameters built into the function (i.e., they are not passed to it). The subroutine also performs clipping. If the output is greater than a value d, it is constrained to d (clipped). The input in r0 is a positive binary value in the range 0 to 0xFF. Apart from r0, no other registers may be modified by this subroutine.

What will be an ideal response?


The following code provides a subroutine (we’ve built in the constants). Following that is the output of a simulation run.





Sub STMFD sp!,{r1,r2,r14} ;save working registers and link register

MUL r1,r0,r0 ;square x

MOV r2,#2 ;c = 2

MUL r1,r2,r1 ;cx2

MOV r2,#3 ;b = 3

MUL r0,r2,r0 ;bx (note r0 overwritten)

ADD r0,r0,r1 ;cx2 + bx

ADD r0,r0,#4 ;cx2 + bx + a

CMP r0,#200 ;above the limit?

MOVGT r0,#200 ;if so ? clamp

LDMFD sp!,{r1,r2,pc} ;restore registers and copy link to pc to return





Computer Science & Information Technology

You might also like to view...

Which library must be included to use the stringstream class?

A. B. C. D. it is included in namespace std

Computer Science & Information Technology

When you want the same functionality in two different places, a good technique is to copy the code from one location and paste it in the other location.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

An organization should not permit end users to install anything on their computer

Indicate whether the statement is true or false.

Computer Science & Information Technology

___________ helps with the IP address shortage problem by allowing an organization to use private IP addresses while connected to the Internet.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology