From what I understand Gold codes are sets of equal length pseudo-random bit patterns that have low cross-correlation between any pair of distinct codes from the set. Or more importantly a guaranteed bound on the maximum cross-correlation between any two codes.
This makes them useful for communications as different codes can share a channel. For instance the GPS system uses Gold codes for the navigation data-stream,
each satellite using a different code. And these are documented.
There are two LSFRs of ten bits each (thus each has a 1023 cycle length). The two are combined (XORed) with different relative phases to generate different
codes. The phase offset is done by picking 1 fixed tap from the first LFSR and 2 variable taps from the 2nd - changing the variable tap points has the
effect of shifting the pattern.
In PASM I've brought this down to 5 instructions, due to the handy parity function of the carry flag in the TEST instruction and MUXC. Both LFSRs are
in the same register so the shift is shared and a single TEST instruction can combine the 3 output taps in one instruction:
test val, H03A6_0000 wc ' feedback taps for G2
muxc val, H0000_8000 ' inject ready for the left shift
test val, H0000_0204 wc ' feedback taps for G1
rcl val, #1 ' inject at LSB as well as shift both LFSRs
test val, selector wc ' XOR the three output taps to put output bit in C flag
H0000_0204 long $0000_0204 ' G1 poly
H0000_8000 long $0000_8000 ' inject point for top 16 bits (RCL used for G1)
H03A6_0000 long $03A6_0000 ' G2 poly in top 16 bits
selector long $0022_0200 ' combine taps for G2 with G1's output
I found information on these sites valuable: https://archive.org/details/ADiyReceiverForGpsAndGlonassSatellites
I continue to marvel at how PASM can capture quite complex pieces of hardware in a few carefully chosed instructions, I thought this was a good example.