8085. Jump Zero after CMP M statement issue

Discussion in 'Embedded Systems and Microcontrollers' started by lightningbolt007, Jan 15, 2016.

  1. lightningbolt007

    Thread Starter New Member

    Jan 15, 2016
    2
    0
    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 ?
     
    • 1.jpg
      1.jpg
      File size:
      243.2 KB
      Views:
      7
  2. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    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 (ASM):
    1.     org    0
    2.     jmp    main
    3.     org    100h
    4. main:    lxi    h,2500h  
    5.     lxi    b,2550h
    6. loop:    ldax    b    ;get [bc]
    7.     cmp    m    ;compare with [hl]
    8.     jz    loop2    ;if equal
    9.     mvi    a,00    ;result=false
    10.     sta    2570h
    11.     hlt
    12. loop2:    inx    h    ;increment hl pair
    13.     inx    b    ;incr bc pair
    14.     mov    a,l    ;done 5 locations?
    15.     cpi    05
    16.     jnz    loop    ;not yet finish
    17.     mvi    a,01    ;result=true
    18.     sta    2570h
    19.     hlt
    20.     org    2500h
    21.     db    2,3,4,8,9
    22.     org    2550h
    23.     db    2,3,4,8,9
    24.     org    2570h
    25.     db    0aah
    26.     end
    Allen
     
    lightningbolt007 likes this.
  3. lightningbolt007

    Thread Starter New Member

    Jan 15, 2016
    2
    0
    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.
     
  4. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    And here's the simulator screen capture

    8085  sim.PNG

    Allen
     
Loading...