microcontroller MC9S12C32 The array sample contains 7 8-bit signed numbers as sh
ID: 3592788 • Letter: M
Question
microcontroller MC9S12C32
The array sample contains 7 8-bit signed numbers as shown below. Write a program which computes the sum of negative numbers, the sum of positive numbers, and the sum of the absolute values of all the numbers, and stores them in psum, nsum, and tsum, respectively. Note that each sum is represented in a word (16 bits). You must use a loop which is iterated 7 times. Outside the loop, there should be only the initialization. Your program should work for any 7 numbers stored in samples. RAMStart-$0800 and ROMStart-$4000. Add a comment on cach instruction samples DC.B $27,$95,$75,SE2,SCB,$41,$44 nsum DC.W 0 psum tsumDC. 0 DC.W 0Explanation / Answer
ASSUME CS : CODE, DS : DATA CODE SEGMENT MOV AX, DATA MOV DS, AX MOV DX, COUNT - 1 BACK : MOV CX, DX MOV SI,OFFSET LIST AGAIN : MOV AX, [SI] CMP AX, [SI + 2] JC GO XCHG AX, [SI + 2] XCHG AX, [SI] GO:INC SI INC SI LOOP AGAIN DEC DX JNZ BACK HLT CODE ENDS DATA SEGMENT LIST DW 05H, 04H, 01H, 03H, 02H COUNT EQU 05H DATA ENDS END
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.