user43680
user43680

Reputation: 33

Computing the checksum of an array of bytes in 68HC11 assembly language

The checksum is computed as the sum without carry of each byte of the array and is put in the register B. The size of the array is in register A and the array is in memory starting at the address in register X.

So far I got this program:

      ORG  $C000

      LDAA #N
      LDAB #$00
LOOP  DECA

      ADDB 0,X
      INX
      CMPA #0
      BNE  LOOP
END

I think that would do the job but I'm new with assembly and the 68HC11. Can you tell if you see something wrong? Thanks in advance.

Upvotes: 1

Views: 806

Answers (1)

Laurent H.
Laurent H.

Reputation: 6526

Here is the code to handle zero-length array (will return B=0):

      LDAB #$00
      LDAA #N
      BEQ END
LOOP  ADDB 0,X
      INX
      DECA
      BNE  LOOP
END

Upvotes: 1

Related Questions