Code for Checksum

I am working on this PLM51 code written for 80552 written many years ago.I am basically trying to re-write the whole code in embedded c using Keil.The statement given below is part of PLM51 code that deals with checksum error detection method.

DECLARE MEM$PTR WORD IDATA; /* Variables used for EPROM test */
DECLARE MEM$VAL BASED MEM$PTR BYTE CONSTANT;
DECLARE CONTROL1 WORD AT (7FFEH) CONSTANT (0FFFFH); /* checksum Eprom */
DECLARE CHECK WORD IDATA;

DO MEM$PTR=0H TO 7FFDH; CHECK=CHECK+MEM$VAL; END; CHECK=CHECK+0FFH+0FFH;/* sum last 2 bytes */ IF CHECK<>CONTROL1 THEN DO; INITIAL$ERROR=90; END;

Can someone PLEASEEEE interpret the statements above to convert to C..Else can anyone suggest a method to program checksum error detection method in embedded C.

Kat

Parents
  • Declare an unsigned char pointer for code memory.

    Iterate between address 0 and 0x7ffd (inclusive) and add to a 16-bit variable.
    Add 0xff two times more, and then compare with the value stored at 0x7ffe,0x7fff.

    The question here is if PLM51 is using the same byte order for 16-bit values as Keil C51, to make sure that the comparison with the stored checksum will match.

Reply
  • Declare an unsigned char pointer for code memory.

    Iterate between address 0 and 0x7ffd (inclusive) and add to a 16-bit variable.
    Add 0xff two times more, and then compare with the value stored at 0x7ffe,0x7fff.

    The question here is if PLM51 is using the same byte order for 16-bit values as Keil C51, to make sure that the comparison with the stored checksum will match.

Children
More questions in this forum