8085. Jump Zero after CMP M statement issue

Thread Starter

lightningbolt007

Joined Jan 15, 2016
2
Hello Everyone. Please view my code on attachment first. The program is to check all the elements of two arrays are equal or not using 8085 assembly language. If equal, then it must print 01 to memory location 2570. Otherwise 00.

I have issue with this code. When I execute this code I find that i m getting 00 on 2570, never mind if all the elements on both arrays are equal or not. Which means after CMP M. JZ loop2 is not working at all. Why zero flag is not set in this code even if both element of 2 array is same ? Can anybody explain what is wrong with my code ?
 

Attachments

absf

Joined Dec 29, 2010
1,968
I simulated your program and found nothing wrong with it.

The result indicated at 2570H is = 01.

Here's the program that I entered.

Code:
    org    0
    jmp    main
    org    100h
main:    lxi    h,2500h  
    lxi    b,2550h
loop:    ldax    b    ;get [bc]
    cmp    m    ;compare with [hl]
    jz    loop2    ;if equal
    mvi    a,00    ;result=false
    sta    2570h
    hlt
loop2:    inx    h    ;increment hl pair
    inx    b    ;incr bc pair
    mov    a,l    ;done 5 locations?
    cpi    05
    jnz    loop    ;not yet finish
    mvi    a,01    ;result=true
    sta    2570h
    hlt
    org    2500h
    db    2,3,4,8,9
    org    2550h
    db    2,3,4,8,9
    org    2570h
    db    0aah
    end
Allen
 

Thread Starter

lightningbolt007

Joined Jan 15, 2016
2
I simulated your program and found nothing wrong with it.

The result indicated at 2570H is = 01.

Allen
Thanks for your reply. I found that it was the error on data sheet distributed by my college. The opcode for CMP M and CMP L was BD. Actually it is BE for CMP M. I corrected and informed to concerned Teacher. Problem solved.
 
Top