📄 des.lst
字号:
01CE 0169 M movwf subkey8
0229 swap subkey8+1, subkey9+1
01CF 6A6A M movfp subkey8+1, wreg
01D0 0C70 M xorwf subkey9+1, 0
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 18
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01D1 016A M movwf subkey8+1
01D2 6A70 M movfp subkey9+1, wreg
01D3 0C6A M xorwf subkey8+1, 0
01D4 0170 M movwf subkey9+1
01D5 6A6A M movfp subkey8+1, wreg
01D6 0C70 M xorwf subkey9+1, 0
01D7 016A M movwf subkey8+1
0230 swap subkey8+2, subkey9+2
01D8 6A6B M movfp subkey8+2, wreg
01D9 0C71 M xorwf subkey9+2, 0
01DA 016B M movwf subkey8+2
01DB 6A71 M movfp subkey9+2, wreg
01DC 0C6B M xorwf subkey8+2, 0
01DD 0171 M movwf subkey9+2
01DE 6A6B M movfp subkey8+2, wreg
01DF 0C71 M xorwf subkey9+2, 0
01E0 016B M movwf subkey8+2
0231 swap subkey8+3, subkey9+3
01E1 6A6C M movfp subkey8+3, wreg
01E2 0C72 M xorwf subkey9+3, 0
01E3 016C M movwf subkey8+3
01E4 6A72 M movfp subkey9+3, wreg
01E5 0C6C M xorwf subkey8+3, 0
01E6 0172 M movwf subkey9+3
01E7 6A6C M movfp subkey8+3, wreg
01E8 0C72 M xorwf subkey9+3, 0
01E9 016C M movwf subkey8+3
0232 swap subkey8+4, subkey9+4
01EA 6A6D M movfp subkey8+4, wreg
01EB 0C73 M xorwf subkey9+4, 0
01EC 016D M movwf subkey8+4
01ED 6A73 M movfp subkey9+4, wreg
01EE 0C6D M xorwf subkey8+4, 0
01EF 0173 M movwf subkey9+4
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 19
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
01F0 6A6D M movfp subkey8+4, wreg
01F1 0C73 M xorwf subkey9+4, 0
01F2 016D M movwf subkey8+4
0233 swap subkey8+5, subkey9+5
01F3 6A6E M movfp subkey8+5, wreg
01F4 0C74 M xorwf subkey9+5, 0
01F5 016E M movwf subkey8+5
01F6 6A74 M movfp subkey9+5, wreg
01F7 0C6E M xorwf subkey8+5, 0
01F8 0174 M movwf subkey9+5
01F9 6A6E M movfp subkey8+5, wreg
01FA 0C74 M xorwf subkey9+5, 0
01FB 016E M movwf subkey8+5
0234
01FC E1FF 0235 call des ; Decrypt
0236
01FD 0237 Here
01FD 0000 0238 nop
01FE C1FD 0239 goto Here
0240
0241 ;********************************************************
0242 ;* Program DES *
0243 ;* *
0244 ;* Program to implement both the encoding and decoding *
0245 ;* portion of the data encryption standard *
0246 ;* *
0247 ;* Memory location mode contains the encoding or *
0248 ;* decoding flag. If mode=0 then encrypt *
0249 ;* If mode=1 then decrypt *
0250 ;* *
0251 ;* The text to be scrambled is to be provided in local *
0252 ;* RAM locations starting at plainText (w1, w2, w3, w4 *
0253 ;* w5, w6, w7, w8). *
0254 ;* *
0255 ;* On exit, w1 thru w8 contain the encrypted data *
0256 ;********************************************************
0257
01FF 0258 des
01FF E3FC 0259 call Initial_Permutation
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 20
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0260
0200 B010 0261 movlw 16 ; Number of iterations
0201 0121 0262 movwf iteration
0263
0264 ; Store left and right data
0265
0266 MOV32 w1, lw1 ; Store left and right bytes
0202 6A23 M MOVFP w1+B0,wreg ; get byte of w1 into w
0203 4A2F M MOVPF wreg,lw1+B0 ; move to lw1(B0)
0204 6A24 M MOVFP w1+B1,wreg ; get byte of w1 into w
0205 4A30 M MOVPF wreg,lw1+B1 ; move to lw1(B1)
0206 6A25 M MOVFP w1+B2,wreg ; get byte of w1 into w
0207 4A31 M MOVPF wreg,lw1+B2 ; move to lw1(B2)
0208 6A26 M MOVFP w1+B3,wreg ; get byte of w1 into w
0209 4A32 M MOVPF wreg,lw1+B3 ; move to lw1(B3)
0267 MOV32 w5, rw1
020A 6A27 M MOVFP w5+B0,wreg ; get byte of w5 into w
020B 4A2B M MOVPF wreg,rw1+B0 ; move to rw1(B0)
020C 6A28 M MOVFP w5+B1,wreg ; get byte of w5 into w
020D 4A2C M MOVPF wreg,rw1+B1 ; move to rw1(B1)
020E 6A29 M MOVFP w5+B2,wreg ; get byte of w5 into w
020F 4A2D M MOVPF wreg,rw1+B2 ; move to rw1(B2)
0210 6A2A M MOVFP w5+B3,wreg ; get byte of w5 into w
0211 4A2E M MOVPF wreg,rw1+B3 ; move to rw1(B3)
0268
0269 ;-- Point to subkey[i]
0270
0212 B03F 0271 movlw subkey1
0213 0109 0272 movwf fsr1
0273
0214 B00F 0274 movlw 0xf
0215 0B04 0275 andwf alusta, f
0216 8604 0276 bsf _fs2 ; fsr1 Auto-increment
0277 ; movlw subkey1
0278 ; movwf fsr1
0279
0280 ;-- Check mode flag, if decryption then point to subkey + 136 (K16)
0281
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 21
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0282 ; btfss mode, 0 ; Check mode
0283 ; goto Next_Loop
0284
0285 ; movlw 0xf
0286 ; andwf alusta, f ; fsr1 Auto-decrement
0287 ; movlw subkey16+48/8
0288 ; movwf fsr1
0289
0290 ; Actual encyphering loop
0291
0217 0292 Next_Loop
0217 6A2B 0293 movfp rw1, wreg ; Save right word i
0218 0133 0294 movwf copy_rw1
0219 6A2C 0295 movfp rw2, wreg
021A 0134 0296 movwf copy_rw2
021B 6A2D 0297 movfp rw3, wreg
021C 0135 0298 movwf copy_rw3
021D 6A2E 0299 movfp rw4, wreg
021E 0136 0300 movwf copy_rw4
0301
021F E23E 0302 call Function ; Compute Ri+1=Li+f(Ri+Ki+1)
0303
0220 6A33 0304 movfp copy_rw1, wreg ; Set Li+1=Ri
0221 012F 0305 movwf lw1
0222 6A34 0306 movfp copy_rw2, wreg
0223 0130 0307 movwf lw2
0224 6A35 0308 movfp copy_rw3, wreg
0225 0131 0309 movwf lw3
0226 6A36 0310 movfp copy_rw4, wreg
0227 0132 0311 movwf lw4
0312
0228 0000 0313 nop
0314
0229 1721 0315 decfsz iteration, f ; Repeat 16 times
022A C217 0316 goto Next_Loop
0317
022B 6A2B 0318 movfp rw1, wreg
022C 0123 0319 movwf w1
022D 6A2C 0320 movfp rw2, wreg
022E 0124 0321 movwf w2
022F 6A2D 0322 movfp rw3, wreg
0230 0125 0323 movwf w3
0231 6A2E 0324 movfp rw4, wreg
0232 0126 0325 movwf w4
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 22
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0233 6A2F 0326 movfp lw1, wreg
0234 0127 0327 movwf w5
0235 6A30 0328 movfp lw2, wreg
0236 0128 0329 movwf w6
0237 6A31 0330 movfp lw3, wreg
0238 0129 0331 movwf w7
0239 6A32 0332 movfp lw4, wreg
023A 012A 0333 movwf w8
0334
023B E4A6 0335 call Inverse_Permutation
023C 0000 0336 nop ; DEBUG
0337
023D 0002 0338 return
0339
0340 ;********************************************************
0341 ;* SUBROUTINE Function *
0342 ;* *
0343 ;* Subroutine to scramble 32 bits into another 32 *
0344 ;* bits with the aid of the key. Input words are *
0345 ;* stored in RW1 thru RW4. The output is also stored *
0346 ;* there. *
0347 ;********************************************************
0348 ;* *
0349 ;* Generate 48 bits out of the 32 using the matrix E *
0350 ;* shown below. The input is read from rw1, rw2, rw3, *
0351 ;* and rw4 and expanded into 48-bits and result stored *
0352 ;* darray. *
0353 ;* *
0354 ;* Matrix E *
0355 ;* *
0356 ;* 32 1 2 3 4 5 *
0357 ;* 4 5 6 7 8 9 *
0358 ;* 8 9 10 11 12 13 *
0359 ;* 12 13 14 15 16 17 *
0360 ;* 16 17 18 19 20 21 *
0361 ;* 20 21 22 23 24 25 *
0362 ;* 24 25 26 27 28 29 *
0363 ;* 28 29 30 31 32 1 *
0364 ;* *
0365 ;********************************************************
023E 0366 Function
023E B09F 0367 movlw darray
023F 4A20 0368 movpf wreg, blkPtr ; Prepare for indirect addressing
0240 B0CF 0369 movlw 0xcf ; Do not change fsr1 status
MPASM 01.02.04 Intermediate DES.ASM 1-30-1995 16:47:47 PAGE 23
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -