Odd & Even Parity generater from sequence of data

Discussion in 'Programmer's Corner' started by AMIT_GOHEL, Aug 29, 2010.

  1. AMIT_GOHEL

    Thread Starter Member

    Jul 13, 2010
    67
    7
    hello,

    i've made program to generate odd & even parity from given bunch of data(but here i've taken only for hex numbers for ex)..
    but it's not working...

    Code ( (Unknown Language)):
    1.  
    2.     ORG 00H
    3.     COUNT EQU 2                        ;totel hex size/2 (IN DESIMAL)
    4.     DB 11H
    5.     DB 00H
    6.     DB 33H
    7.     DB 22H                ;data
    8.  
    9.     MOV A,#00H                        ;acc initialization
    10.     MOV DPTR,#0000H                      ;dptr loaded with even data address
    11.     MOV R1,COUNT                    ;counter
    12.     CALL LOOP1
    13.     MOV R3,A                         ;even parity
    14.     MOV A,#00H                            ;acc initialization
    15.     MOV DPTR,#0001H                     ;dptr loaded with odd data address
    16.     MOV R1,COUNT                       ;counter
    17.     CALL LOOP1
    18.     MOV R4,A                         ;odd parity
    19.  
    20. LOOP1:
    21. LOOP: MOV A,#00H
    22.       MOVC A,@A+DPTR
    23.       ADD A,R2
    24.       MOV R2,A
    25.       INC DPTR
    26.       CLR C
    27.       DJNZ R1,LOOP
    28.       RET
    29.  
    30. END
    31.  
    i'm using keil 4 for debugging..

    when try to debug it sticks at 0000h location ...

    thanks in advance...
     
  2. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    You haven't setup any stack pointer prior to using the CALL/RET instruction and your program execution falls through to the LOOP subroutine code.

    Code ( (Unknown Language)):
    1.  
    2.     MOV DPTR,#0001H                     ;dptr loaded with odd data address
    3.     MOV R1,COUNT                       ;counter
    4.     CALL LOOP1
    5.     MOV R4,A                         ;odd parity
    6.  
    7.         ;<<<--- what instruction to execute next ????
    8.  
    9. LOOP1:
    10. LOOP: MOV A,#00H
    11.       MOVC A,@A+DPTR
    12.       ADD A,R2
    13.       MOV R2,A
    14.       INC DPTR
    15.       CLR C
    16.       DJNZ R1,LOOP
    17.       RET
     
Loading...