⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lfsr.asm

📁 胎压检测发送端汇编源码-tpms-transmitters
💻 ASM
字号:
* LFSR.asm

* This file contains the soft implementation of the linear feedback shift register.

                                                ;First, break the seed into eight
                                                ; registers, 1 bit each.

LFSR:           LDX     #$08                            ;Bit counter
GetSeedBit:     ROL     SEED                            ;Bump a data bit into carry
                ROR     D_REG-1,X                       ;Snatch the carry bit in a register
                DBNZX   GetSeedBit                      ;Get the next bit

                                                ;Next, perform the flip-flop action
                                                ; with the exclusive OR where needed.
                LDX     #Q_REG
                MOV     D_REG+7,X+                      ;Q1 = D8
                MOV     D_REG,X+                        ;Q2 = D1
                LDA     D_REG+1
                EOR     D_REG+7
                STA     ,X                              ;Q3 = D2 ^ D8
                INCX
                MOV     D_REG+2,X+                      ;Q4 = D3
                LDA     D_REG+3
                EOR     D_REG+7
                STA     ,X                              ;Q5 = D4 ^ D8
                INCX
                LDA     D_REG+4
                EOR     D_REG+7
                STA     ,X                              ;Q6 = D5 ^ D8
                INCX
                LDA     D_REG+5
                EOR     D_REG+7
                STA     ,X                              ;Q7 = D6 ^ D8
                INCX
                LDA     D_REG+6
                EOR     D_REG+7
                STA     ,X                              ;Q8 = D7 ^ D8

                                                ;Finally, move the new data into the
                                                ; SEED register.

PlaceSeedBit:   LDX     #$08                            ;Bit counter
                ROL     Q_REG-1,X                       ;Bump the data bit into carry
                ROL     SEED                            ;Rotate the data bits into the Seed
                DBNZX   PlaceSeedBit                    ;Place the next bit

                LDX     #$16
Clr_NextReg:    CLR     D_REG-1,X
                DBNZX   Clr_NextReg

                RTS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -