encryptrand.asm

来自「Cypress公司开发的2.4G无线键盘鼠标及其Bridge源代码」· 汇编 代码 · 共 70 行

ASM
70
字号
; *********************************************************************
; Copyright 2005, 2006 Cypress Semiconductor Corporation.
;
; This software is owned by Cypress Semiconductor Corporation (Cypress)
; and is protected by United States copyright laws and international
; treaty provisions.  Therefore, you must treat this software like any
; other copyrighted material (e.g., book, or musical recording), with
; the exception that one copy may be made for personal use or
; evaluation.  Reproduction, modification, translation, compilation, or
; representation of this software in any other form (e.g., paper,
; magnetic, optical, silicon, etc.) is prohibited without the express
; written permission of Cypress.
;
; Disclaimer: Cypress makes no warranty of any kind, express or
; implied, with regard to this material, including, but not limited to,
; the implied warranties of merchantability and fitness for a particular
; purpose. Cypress reserves the right to make changes without further
; notice to the materials described herein. Cypress does not assume any
; liability arising out of the application or use of any product or
; circuit described herein. Cypress' products described herein are not
; authorized for use as components in life-support devices.
;
; This software is protected by and subject to worldwide patent
; coverage, including U.S. and foreign patents. Use may be limited by
; and subject to the Cypress Software License Agreement.
;
; *********************************************************************
;
; encryptRand.asm: Random data generator used by encrypt.
;

include "aes128.inc"
    IF ENCRYPT_AES 

;----------------------------------------------------------------------------
;
; Code.
;
;----------------------------------------------------------------------------


                AREA       UserModules (ROM, REL)

;----------------------------------------------------------------------------
;
; random() - Store "random" byte in specified RAM address
;
;  To properly generate a PN byte, this should shift 8 times, but since
;  it's XORing with someplace in RAM, we figure it's OK.
;----------------------------------------------------------------------------
POLY:   EQU 0x1021     ; CRC-CCITT polynomial: x16 + x12 + x5 + 1
_random::
    rlc [_lfsr16+0]     ; [ 7: 0]
    rlc [_lfsr16+1]     ; [15: 8]
    jnc S1
    xor [_lfsr16+0], <POLY  ; [ 7: 0]
    xor [_lfsr16+1], >POLY  ; [15: 8]
S1:
    mov a,[_lfsr16+0]
    mov x, a
    xor a,[x+0]     ; xor w/someplace in RAM
    jz  _random     ; ZERO is reserved for end-of-data mark
    ret

    ELSE
    ENDIF   



⌨️ 快捷键说明

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