Sum of Array – Assembly Program


Write and run a program using 8086 assembly language that finds the total of marks of 5 students stored in five consecutive memory locations. [Dec 2012, Set-2]

DATA SEGMENT
    ARRAY DW 5h, 2h, 4h, 1h, 6h
    TOTAL DW ? 
DATA ENDS

CODE SEGMENT
START:

    ASSUME CS:CODE, DS:DATA 
    MOV AX, DATA
    MOV DS, AX 
    
    MOV AX, 0000h
    
    MOV SI, 0000h
    MOV CX, 5H
       
    NEXT: ADD AX, ARRAY[SI]
    ADD SI,2   
    LOOP NEXT
     
    MOV TOTAL, AX  
        
    MOV AX, 4C00H
    INT 21H    
CODE ENDS

END START