User:Cuddlyable3/Sandbox2

=Testing LFSRs= A taps configuration can be tested to find whether it gives the maximal sequence from an LFSR of a given number of bits n. The code below tests LFSRs up to 32 bits. Enter the assembly code to a PC using the tool DEBUG.EXE provided with MS-DOS and Windows operating systems. On the command line enter only the characters shown below in bold and not the explanations in italics.

C:\>debug -a 100 assemble code ░░░░:0100 mov ax,400 Put the polynomial that describes the LFSR in registers BX:AX ░░░░:0103 mov bx,2 ░░░░:0106 mov cx,ax   DX:CX is the Galois shift register ░░░░:0108 mov dx,bx ░░░░:010A mov di,1    SI:DI counts shifts ░░░░:010D mov si,0 ░░░░:0110 add di,1 ░░░░:0113 jnc 116 ░░░░:0115 inc si ░░░░:0116 shr dx,1     Shift ░░░░:0118 rcr cx,1 ░░░░:011A jnc 120,1 ░░░░:011C xor dx,bx    If carry then XOR taps ░░░░:011E xor cx,ax ░░░░:0120 cmp cx,1     Has LFSR recycled yet to ....001 ? ░░░░:0123 jne 110 ░░░░:0125 add dx,0 ░░░░:0128 jnz 110 ░░░░:012A ^C ''ctrl-c completes the assembly. At this breakpoint SI:DI will show the LFSR cycle length.'' -g =100 12A Run the code until the breakpoint. The above example tests the 18-bit LFSR polynomial $$x^{ 17 }+x^{ 14 }+1$$ and exits with SI:DI = 3FFFF (the maximal count 262 143). Test another polynomial simply by changing the first two lines as in the following example: 32-bit LFSR polynomial $$x^{ 32 }+x^{ 31 }+x^{ 30 }+x^{ 10 }+1$$  32 31 30 29 28......17|16.....12 11 10 9.......1 Taps  1  1  1  0  0       0| 0      0  0  1  0       0  binary E000|                      200  hexadecimal  -a 100 assemble code ░░░░:0100 mov ax,200 Put the polynomial that describes the LFSR in registers BX:AX ░░░░:0103 mov bx,E000 ░░░░:0106 ^C ctrl-c completes the changes to the previous assembly -g =100 12A Run the code until the breakpoint. The code exits with SI:DI = FFFFFFFF (the maximal count $$2^{ 32 } - 1$$) after about 60 seconds on a typical PC.