; PDP-11 CRC-16 code ; r0=byte ; r1=>data ; r2=count ; r3=crc ; r4=polynomic mov #&1021,r4 ; XMODEM polynomic .bytelp movb (r1)+,r0 ; Fetch byte from memory ; The following code updates the CRC with the byte in R0 bic #&FF00,r0 ; Ensure b8-b15 clear swab r0 xor r0,r3 ; XOR into CRC high byte mov #8,r0 ; Prepare to rotate 8 bits .rotlp clc rol r3 ; Rotate CRC bcc clear ; Carry out clear xor r4,r3 ; CRC=CRC xor &1021 .clear sub #1,r0 bne rotlp ; Loop for 8 bits sub #1,r2 ; num=num-1 bne bytelp ; Loop until num=0 mov r3,r0 ; Return CRC to BASIC in R0/R1 clr r1 rts pc ; Return with R3=updated CRC ;; #include