?? dessamp.lst
字號:
MPASM 01.50 Released DESSAMP.ASM 5-5-1997 16:06:32 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;-----------------------------------------------------------------------------
00002 ; DES sample code
00003 ; Copyright 1994, 1996, 1997 Eric L. Smith
00004 ;
00005 ; $Header$
00006 ;-----------------------------------------------------------------------------
00007
00000001 00008 do_serial equ 1
00000000 00009 do_parallel equ 0
00000001 00010 echo_input equ 1
00000000 00011 do_parity equ 0
00012
00000001 00013 single_des equ 1
00000000 00014 triple_des equ 0
00015
00016 processor 16f84
00017 include "p16f84.inc"
00001 LIST
00002 ; P16F84.INC Standard Header File, Version 2.00 Microchip Technology, Inc.
00136 LIST
2007 3FF2 00018 __CONFIG _CP_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC
00019 radix dec
00020 errorlevel -224
00021 errorlevel -305
00022
00023
00024 ;-----------------------------------------------------------------------------
00025 ; memory map
00026 ;-----------------------------------------------------------------------------
00027
0000000C 00028 rambase equ 0x0c
00000000 00029 rombase equ 0x000
00030
00031 ;sboxbase equ 0x300
00032
00033
00034 ;-----------------------------------------------------------------------------
00035 ; port bits
00036 ;-----------------------------------------------------------------------------
00037
00038 if do_parallel
00039 #define strobe PORTA,4
00040 #define select PORTA,3
00041 #define error PORTA,2
00042 #define paper PORTA,1
00043 #define ack PORTA,0
00044 endif ; do_parallel
00045
00046 if do_serial
00047 #define rxd PORTA,1
00048 #define txd PORTA,2
00049 endif ; do_serial
00050
MPASM 01.50 Released DESSAMP.ASM 5-5-1997 16:06:32 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00051
00052 ;-----------------------------------------------------------------------------
00053 ; RAM definitions
00054 ;-----------------------------------------------------------------------------
00055
00056 cblock rambase
00057
0000000C 00058 cmd
0000000D 00059 parity
0000000E 00060 result
0000000F 00061 temp
00062 endc
00063
00064
00065 if do_serial&&echo_input
00066 cblock
00000010 00067 temp2
00068 endc
00069 endif
00070
00071
00072 ;-----------------------------------------------------------------------------
00073 ; error codes
00074 ;-----------------------------------------------------------------------------
00075
00000000 00076 noerr equ 0
00000001 00077 parerr equ 1
00000002 00078 cmderr equ 2
00000003 00079 argerr equ 3
00000004 00080 keyerr equ 4
00081
00082
00083 ;-----------------------------------------------------------------------------
00084 ; vectors
00085 ;-----------------------------------------------------------------------------
00086
0000 00087 org rombase
00088
0000 2811 00089 goto reset
0001 0000 00090 nop
0002 0000 00091 nop
0003 0000 00092 nop
0004 2811 00093 goto reset
00094
00095
00096 ;-----------------------------------------------------------------------------
00097 ; tables - must be in page 0
00098 ;-----------------------------------------------------------------------------
00099
00100 ; command dispatch table
00101
0005 018A 00102 docmd: clrf PCLATH
0006 0E0C 00103 swapf cmd,w ; look at bits 4-6 for command
MPASM 01.50 Released DESSAMP.ASM 5-5-1997 16:06:32 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0007 3907 00104 andlw 7
0008 0782 00105 addwf PCL
00106
0009 289E 00107 goto version
000A 28A2 00108 goto echo
000B 28C3 00109 goto setkeyee
000C 28BA 00110 goto clrkeyee
00111
00112 if single_des
000D 28A3 00113 goto des
000E 28AA 00114 goto desinv
00115 else
00116 goto echo
00117 goto echo
00118 endif
00119
00120 if triple_des
00121 goto triple
00122 goto tripleinv
00123 else
000F 28A2 00124 goto echo
0010 28A2 00125 goto echo
00126 endif
00127
00128
00129 ;-----------------------------------------------------------------------------
00130 ; initialization code
00131 ;-----------------------------------------------------------------------------
00132
0011 00133 reset:
00134 if do_parallel
00135 movlw 0xff ; all port pins are inputs (or inactive
00136 tris PORTA ; open-drain outputs)
00137 tris PORTB
00138 clrf PORTA
00139 clrf PORTB
00140 endif
00141
00142 if do_serial
0011 3002 00143 movlw 0x02 ; only rxd is an input
0012 0065 00144 tris PORTA
0013 3000 00145 movlw 0x00 ; all portb pins are outputs
0014 0066 00146 tris PORTB
0015 0185 00147 clrf PORTA
0016 0186 00148 clrf PORTB
00149 endif
00150
0017 1683 00151 bsf STATUS,RP0
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
0018 0188 00152 clrf EECON1
0019 1283 00153 bcf STATUS,RP0
00154
00155
MPASM 01.50 Released DESSAMP.ASM 5-5-1997 16:06:32 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00156 ;-----------------------------------------------------------------------------
00157 ; main loop
00158 ;-----------------------------------------------------------------------------
00159
001A 018E 00160 main: clrf result
001B 2028 00161 call getcmd
00162
00163 if do_parity
00164 btfss STATUS,Z
00165 goto main9
00166 endif ; do_parity
00167
001C 0E0C 00168 swapf cmd,W ; set up key pointer
001D 0089 00169 movwf EEADR
001E 0C89 00170 rrf EEADR
001F 3038 00171 movlw 0x38
0020 0589 00172 andwf EEADR
00173
0021 2005 00174 call docmd
00175
0022 00176 main9:
00177 ; replace the cmd with the result
0022 080E 00178 movf result,W
0023 008C 00179 movwf cmd
00180 ; compute parity
0024 2094 00181 call parchk
0025 008D 00182 movwf parity
00183
0026 203C 00184 call sendresult
0027 281A 00185 goto main
00186
00187
00188 ;-----------------------------------------------------------------------------
00189 ; communication with PC
00190 ;-----------------------------------------------------------------------------
00191
00192 if do_parallel
00193
00194 getcmd:
00195 movlw cmd ; get ten bytes from host
00196 movwf FSR
00197 movlw 10
00198 movwf temp
00199
00200 getc1: btfsc select ; if select goes active, abort
00201 goto getcmd
00202 btfsc strobe ; wait for strobe to go true (low)
00203 goto getc1
00204
00205 movf PORTB,w ; grab and stash the data
00206 movwf INDF
00207
00208 getc2: btfsc select ; if select goes active, abort
MPASM 01.50 Released DESSAMP.ASM 5-5-1997 16:06:32 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00209 goto getcmd
00210 btfss strobe ; wait for strobe to go false (high)
00211 goto getc2
00212
00213 movlw 0xfe ; generate an ack pulse
00214 tris PORTA
00215
00216 movlw 8 ; delay 8*4*400nS (10 MHz)
00217 ackp: addlw 0xff
00218 btfss STATUS,Z
00219 goto ackp
00220
00221 movlw 0xff
00222 tris PORTA
00223
00224 incf FSR ; advance to next byte
00225 decfsz temp
00226 goto getc1
00227
00228 ; test parity, return zero flag clear if error
00229 call parchk
00230 xorwf parity,w
00231 btfsc STATUS,Z
00232 return
00233
00234 movlw parerr
00235 movwf result
00236 bcf STATUS,Z
00237 return
00238
00239 sendresult:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -