Write a program to implement the arithmetic function F 45X2

Write a program to implement the arithmetic function F = 4.5X^2 + 3Y - 1.5Z. The numbers X, Y, and Z are 8-bit integers stored in registers D0, D1 and D2, respectively. The calculated value of F should be stored in memory starting at $2000. Test your program by initializing D0, D1, and D2 with different values and verify the results. [For e.g. D0, D1, D2 = 1, 2, 3, 4, 5] Write a program to compute the dot product of two vectors A and B. C = A.B = A_xB_x + A_yB_y + A_zB_z The components of vector A (A_x, A_y and A_z) are stored in memory at address VEC_A, and those of vector B at address VEC_B. All components are 8-bit signed numbers. The result of the dot product (scalar) should be stored in memory starting at address RESULT. Use the most suitable addressing modes. [Hint: for signed numbers instructions MULS must be used; refer to lecture notes] VEC_A DC.B 2, 4, 6 VEC_B DC.B 1, 3, 5 RESULT DS.W 0 Write a program using EASy68K to multiply the contents of D0.W by 13 without using the MUL instruction. Write a program using EASy68K to divide the contents of D0.W by 9 without using the DIV instruction.

Solution

12.

for x=2000 : 2002
X=input(\'Enter X value : \');
Y=input(\'Enter Y value : \');
Z=input(\'Enter Z value : \');
D0=X;
D1=Y;
D2=Z;
F=4.5*power(X,2)-3*Y-1.5*Z
end

result

Enter X value : 1
Enter Y value : 2
Enter Z value : 3

F =

    -6

Enter X value : 4
Enter Y value : 5
Enter Z value : 6

F =

    48

Enter X value : 7
Enter Y value : 8
Enter Z value : 9

F =

   183

 Write a program to implement the arithmetic function F = 4.5X^2 + 3Y - 1.5Z. The numbers X, Y, and Z are 8-bit integers stored in registers D0, D1 and D2, resp

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site