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

Write the Intel x86 code fragment to implement a simple polynomial function. Ass

ID: 3852973 • Letter: W

Question

Write the Intel x86 code fragment to implement a simple polynomial function. Assume all variables are defined as words in the data segment, and are *NOT* initialized. Don't worry about overflow. A_var, B_var, C_var, and D_var are constants defined in the data segment, and are equal to the digits in your UT Rocket ID# positions 2, 3, 4, and 5 (least significant digit is position 0). So if your rocket# is R09876S43, A_var = 5, B_var = 6, C_var = 7, and D_var = 8. Note that the function's output f(x) is to be written to a variable f_out (also defined as a word in the data segment). The polynomial to be implemented is as follows: f(x) = (A_var * x^n + B_var * x^m)/D_var - C_var* x a. If n = the least-significant digit of your UT Rocket ID#, and m = the tens digit (next to the least significant digit) of your UT Rocket ID#, write the code fragment to implement the function and copy the result to f_out. b. Implement the function in ARM assembly language. Assume all registers and constants are defined as 32-bit (doubleword) values).

Explanation / Answer

A). CODE FRAGMENT WITH THE VARIABLES DECLARED AS WORD AND THE OUTPUT IS COPIED TO F_OUT.

.DATA

.CODE

MAIN PROC

A_VAR WORD 5

B_VAR WORD 6

C_VAR WORD 7

D_VAR WORD 8

F_OUT WORD 0

MOV EAX, A_VAR

MOV EBX, B_VAR

MOV ECX, C_VAR

MOV EDX, D_VAR

SHR $1, EAX

JC ADDONE

ADDONE:MOV AX,0

MUL EAX,1

SHL $10,EBX

MUL EBX,TMP

ADD EAX, EBX

MUL ECX,AX

SUB EAX,ECX

DIV EAX,EDX

MOV F_OUT, EAX

MAIN ENDP

END MAIN

B). ARM CODE FRAGMENT WITH VARIABLES DECLARED AS DOUBLE.

.DATA

.CODE

MAIN PROC

A_VAR DWORD 5

B_VAR DWORD 6

C_VAR DWORD 7

D_VAR DWORD 8

MOV EAX, A_VAR

MOV EBX, B_VAR

MOV ECX, C_VAR

MOV EDX, D_VAR

SHR $1, EAX

JC ADDONE

ADDONE:MOV AX,0

MUL EAX,1

SHL $10,EBX

MUL EBX,TMP

ADD EAX, EBX

MUL ECX,AX

SUB EAX,ECX

DIV EAX,EDX

MAIN ENDP

END MAIN

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote