ld hl,($c1be) ; Get high two bytes ld a,l ; xor low byte with high byte of doubled number add hl,hl xor h ld b,a ; -> b ld hl,($c1bd) ; Then read again one byte lower, and repeat ld a,l add hl,hl xor h ld c,a ; -> c ld hl,($c1bc) ; copy last value read to high 2 bytes ld ($c1be),hl ld ($c1bc),bc ; and save new value to low 2 bytes ret