0
start :
    mov ax, @data
    mov ds, ax 
    MOV BL, 00H 
        MOV DL, 00H
    LEA SI, ARX
    LEA DI, ARY
    PRINTF MSG1
X:  
    MOV CL,05
    mov ah, 01h
    int 21h
    MOV BL,AL
    INC BL
    DEC CL
    JZ Y
    JNZ X

Y:  
    MOV CL,05
    mov ah, 01h
    int 21h
    MOV DL,AL
    INC DL
    DEC CL
    JZ A
    JNZ Y

A:  MOV ARX,BL
    MOV ARY,DL
    JMP Z       

Z:  PRINTF MSG3
    MOV CL,05H
    MOV AL,[SI]
    ADD AL,[DI]
    ADD AL,48H
    mov dl,al
    mov ah,02h
    int 21h
    DEC CL
    INC SI
    INC DI
    JZ EXIT
    JNZ Z   
EXIT:   mov ah, 4ch
    int 21h
    end start

I Can't end the loop and there are other problems too can someone please help me in rectifying these errors. Not too complicated answer still in college so please help. I used counter (05) to stop loop but no matter what is not stopping.

Question: Write an assembly level program for 8086 microprocessor to read two separate arrays of 10 bytes each and display a sum array, which gives the sum of corresponding elements. Example given below:

Enter the array 1:

01

02

03

04

Enter the array 2:

01

02

03

04

The sum array is:

02

04

06

08

1 Answer 1

1

You're relying on the flags being set properly after decrementing your loop counter, but you execute some instructions that will change the flags between the decrement and when you check the flags.

Specifically, the dec cl instruction should be right before the jnz at the end of the third loop:

    INC SI
    INC DI
    DEC CL
    JNZ Z

You can remove some of the other conditional checks, as a JZ to skip a JNZ can be eliminated. And you could use some better names for your labels.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.