📄 des.lst
字号:
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0001 LIST C=132, p=17c42, r=dec, length=50
0002
0003 ;********************************************************
0004 ;* Project: Software implementation of DES algorithm. *
0005 ;* *
0006 ;* Copyright (c) 1993 Microchip Technology *
0007 ;* *
0008 ;* Revision history: *
0009 ;* 09/07/93 original *
0010 ;********************************************************
0011
0012 #define _NOTDEF FALSE
0013
0014 include "17c42.reg"
0014
0015 include "17c42.mac"
0015
0016
0017 ; Global variables
0018
0020 0019 blkPtr equ 0x20
0021 0020 iteration equ blkPtr+1
0022 0021 mode equ iteration+1 ; Encode/Decode flag
0022
0023 0023 w1 equ mode+1 ; plaintext/ciphertext
0024 0024 w2 equ w1+1 ; plaintext/ciphertext
0025 0025 w3 equ w2+1 ; plaintext/ciphertext
0026 0026 w4 equ w3+1 ; plaintext/ciphertext
0027 0027 w5 equ w4+1 ; plaintext/ciphertext
0028 0028 w6 equ w5+1 ; plaintext/ciphertext
0029 0029 w7 equ w6+1 ; plaintext/ciphertext
002A 0030 w8 equ w7+1 ; plaintext/ciphertext
0031
0023 0032 plainText equ w1
0033
002B 0034 rw1 equ w8+1 ; Right half
002C 0035 rw2 equ rw1+1 ; Right half
002D 0036 rw3 equ rw2+1 ; Right half
002E 0037 rw4 equ rw3+1 ; Right half
002F 0038 lw1 equ rw4+1 ; Left half
0030 0039 lw2 equ lw1+1 ; Left half
0031 0040 lw3 equ lw2+1 ; Left half
0032 0041 lw4 equ lw3+1 ; Left half
0042
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0033 0043 copy_rw1 equ lw4+1
0034 0044 copy_rw2 equ copy_rw1+1
0035 0045 copy_rw3 equ copy_rw2+1
0036 0046 copy_rw4 equ copy_rw3+1
0047
0037 0048 cipherText equ copy_rw4+1 ; 64-bit ciphertext
003F 0049 subkey1 equ cipherText+64/8 ; subkey #1
0045 0050 subkey2 equ subkey1+48/8 ; subkey #2
004B 0051 subkey3 equ subkey2+48/8 ; subkey #3
0051 0052 subkey4 equ subkey3+48/8 ; subkey #4
0057 0053 subkey5 equ subkey4+48/8 ; subkey #5
005D 0054 subkey6 equ subkey5+48/8 ; subkey #6
0063 0055 subkey7 equ subkey6+48/8 ; subkey #7
0069 0056 subkey8 equ subkey7+48/8 ; subkey #8
006F 0057 subkey9 equ subkey8+48/8 ; subkey #9
0075 0058 subkey10 equ subkey9+48/8 ; subkey #10
007B 0059 subkey11 equ subkey10+48/8 ; subkey #11
0081 0060 subkey12 equ subkey11+48/8 ; subkey #12
0087 0061 subkey13 equ subkey12+48/8 ; subkey #13
008D 0062 subkey14 equ subkey13+48/8 ; subkey #14
0093 0063 subkey15 equ subkey14+48/8 ; subkey #15
0099 0064 subkey16 equ subkey15+48/8 ; subkey #16
0065
009F 0066 darray equ subkey16+48/8 ; D array (temp locations)
009F 0067 trw1 equ darray
00A0 0068 trw2 equ darray+1
00A1 0069 trw3 equ darray+2
00A2 0070 trw4 equ darray+3
00A3 0071 trw5 equ darray+4
00A4 0072 trw6 equ darray+5
0073
0074
0075 CBLOCK darray+64/8
00A7 0076 k1, k2, k3, k4, k5, k6, k7, k8
00AF 0077 kin, temp, bit, zero, row
0078 ENDC
0079
0080
0081 ;********************************************************
0082 ; Constant definitions *
0083 ;********************************************************
0084
0080 0085 MPARITY equ 0x80
0086
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0087 ;********************************************************
0088 ; Macro definitions *
0089 ;********************************************************
0090
0091 permute macro k, test, bit
0092 btfsc k, test
0093 bsf indf0, bit
0094 endm
0095
0096 swap macro a, b
0097 movfp a, wreg
0098 xorwf b, 0
0099 movwf a
0100
0101 movfp b, wreg
0102 xorwf a, 0
0103 movwf b
0104
0105 movfp a, wreg
0106 xorwf b, 0
0107 movwf a
0108 endm
0109
0110 ;********************************************************
0111 ; DES code *
0112 ;********************************************************
0113
0114 org _ResetVector
0000 C021 0115 goto Start
0116
0117 org _Text
0021 0118 Start
0021 8406 0119 bsf _glintd ; disable all interrupts
0022 B020 0121 movlw 0x20 ; clear all memory locations [18,FF]
0023 4A01 0122 movpf wreg,fsr0
0123
0024 0124 Memory_Loop
0024 2900 0125 clrf indf0
0025 1F01 0126 incfsz fsr0
0026 C024 0127 goto Memory_Loop
0128
0129 ; Transfer the plaintext information from PM to DM. Read only 64-bit
0130 ; at a time.
0131
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0027 B023 0132 movlw plainText ; Move plain text to RAM
0028 4A01 0133 movpf wreg, fsr0
0029 B00F 0134 movlw 0xf ; Setup indirect addressing
002A 0B04 0135 andwf alusta, f ; with post increment option
002B 8404 0136 bsf _fs0
002C B008 0137 movlw high Cipher
002D 4A0E 0138 movpf wreg, tblptrh
002E B0DC 0139 movlw low Cipher
002F 4A0D 0140 movpf wreg, tblptrl ; (tblptr) = Cipher
0030 AB0A 0141 tablrd 1, 1, wreg ; (tblat) = Cipher --> junk value
0142 ; (tblptr) = Cipher++
0031 A200 0143 tlrd 1, indf0
0032 A900 0144 tablrd 0, 1, indf0
0033 A200 0145 tlrd 1, indf0
0034 A900 0146 tablrd 0, 1, indf0
0035 A200 0147 tlrd 1, indf0
0036 A900 0148 tablrd 0, 1, indf0
0037 A200 0149 tlrd 1, indf0
0038 A900 0150 tablrd 0, 1, indf0
0151
0152 ; Transfer the key from PM to DM (56 bits only).
0153
0039 B0A7 0154 movlw k1
003A 4A01 0155 movpf wreg, fsr0 ; Move key to RAM
003B B008 0156 movlw high My_Key
003C 4A0E 0157 movpf wreg, tblptrh
003D B0E0 0158 movlw low My_Key
003E 4A0D 0159 movpf wreg, tblptrl
003F AB0A 0160 tablrd 1, 1, wreg ; Junk value
0161
0040 A200 0162 tlrd 1, indf0
0041 A900 0163 tablrd 0, 1, indf0
0042 A200 0164 tlrd 1, indf0
0043 A900 0165 tablrd 0, 1, indf0
0044 A200 0166 tlrd 1, indf0
0045 A900 0167 tablrd 0, 1, indf0
0046 A200 0168 tlrd 1, indf0
0047 A900 0169 tablrd 0, 1, indf0
0170
0048 E550 0171 call Key_Generation ; Generate DES session keys
0172
0049 0000 0173 nop
0174
004A E1FF 0175 call des ; Encrypt
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0176
004B 0000 0177 nop
0178
0179 swap subkey1, subkey16
004C 6A3F M movfp subkey1, wreg
004D 0C99 M xorwf subkey16, 0
004E 013F M movwf subkey1
004F 6A99 M movfp subkey16, wreg
0050 0C3F M xorwf subkey1, 0
0051 0199 M movwf subkey16
0052 6A3F M movfp subkey1, wreg
0053 0C99 M xorwf subkey16, 0
0054 013F M movwf subkey1
0180 swap subkey1+1, subkey16+1
0055 6A40 M movfp subkey1+1, wreg
0056 0C9A M xorwf subkey16+1, 0
0057 0140 M movwf subkey1+1
0058 6A9A M movfp subkey16+1, wreg
0059 0C40 M xorwf subkey1+1, 0
005A 019A M movwf subkey16+1
005B 6A40 M movfp subkey1+1, wreg
005C 0C9A M xorwf subkey16+1, 0
005D 0140 M movwf subkey1+1
0181 swap subkey1+2, subkey16+2
005E 6A41 M movfp subkey1+2, wreg
005F 0C9B M xorwf subkey16+2, 0
0060 0141 M movwf subkey1+2
0061 6A9B M movfp subkey16+2, wreg
0062 0C41 M xorwf subkey1+2, 0
0063 019B M movwf subkey16+2
0064 6A41 M movfp subkey1+2, wreg
0065 0C9B M xorwf subkey16+2, 0
0066 0141 M movwf subkey1+2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -