Professional Documents
Culture Documents
7
Write an 8086 assembly program to implement the following C language program loop:
sum = 0;
for (i = 0; i <=99; i = i + 1)
sum = sum + x[i] * y[i];
The assembly language program will compute SUM (xi * yi) where i = 100 and, xi and yi are signed 8-bit numbers
stored at offsets 4000H and 5000H respectively. Initialize DS at 2000H. Store the 16-bit result in DX. Assume no
overflow.
List File:
Symbols:
0 Warnings
0 Errors
Debug Screen shots:
Show program at default CS=0BF0H.
Fill command is used to place a value (in this case 2) in 100 memory locations starting at
DS:4000 and value (in this case 3) in 100 memory locations starting at DS:5000.
Memory dump is used to verify placing 100 memory locations at DS:4000H with 2(Xi’s) and
DS:5000H with 3(Yi’s).
Start program. Initialize CX = 100 (64H) but changed to 2 to demonstrate program functionality.
The loop will iterate only 2 times. If Xi’s and Yi’s are 2 and 3 respectively, then Xi * Yi = 6 and
summing 6 twice will result into 12. The final answer should be DX = 12 which is shown in the
last screen shot below.
CX = 0 and Loop terminates. (DX) = 000CH which is 12 in decimal. The correct answer is
stored.