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

📄 tenbit.lst

📁 代码保护功能处于持续发展中。Microchip 承诺将不断改进产品的代码保护功能。任何试图破坏Microchip 代码保护功能的行为均可视 为违反了《数字器件千年版权法案(Digital Mille
💻 LST
📖 第 1 页 / 共 3 页
字号:
MPASM 03.70.01 Released                            TENBIT.ASM   3-28-2006  22:41:23         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00002 ;
                      00003 ;       Project:                Interfacing PICs 
                      00004 ;       Source File Name:       TENBIT.ASM              
                      00005 ;       Devised by:             MPB             
                      00006 ;       Date:                   27-6-05
                      00007 ;       Status:                 Working
                      00008 ;
                      00009 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00010 ;
                      00011 ;       Demonstrates 10-bit voltage measurement
                      00012 ;       using an external reference voltage of 4.096V, 
                      00013 ;       giving 4mV per bit, and an resolution of 0.1%.
                      00014 ;       The result is converted to BCD for display
                      00015 ;       as a voltage using the standard LCD routines.
                      00016 ;       
                      00017 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00018 
                      00019         PROCESSOR 16F877
                      00020 ;       Clock = XT 4MHz, standard fuse settings
2007   3731           00021         __CONFIG 0x3731
                      00022 
                      00023 ;       LABEL EQUATES   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00024 
                      00025         INCLUDE "P16F877A.INC"  
                      00001         LIST
                      00002 ; P16F877A.INC  Standard Header File, Version 1.00    Microchip Technology, Inc.
Message[301]: MESSAGE: (Processor-header file mismatch.  Verify selected processor.)
                      00398         LIST
                      00026         ; standard register labels      
                      00027 
                      00028 ;----------------------------------------------------------
                      00029 ; User register labels
                      00030 ;----------------------------------------------------------
                      00031 ; GPR 20 - 2F allocated to included LCD display routine
                      00032 
  00000030            00033 count   EQU     30      ; Counter for ADC setup delay
  00000031            00034 ADhi    EQU     31      ; Binary input high byte
  00000032            00035 ADlo    EQU     32      ; Binary input low byte
  00000033            00036 thos    EQU     33      ; Thousands digit in decimal
  00000034            00037 huns    EQU     34      ; Hundreds digit in decimal value
  00000035            00038 tens    EQU     35      ; Tens digit in decimal value
  00000036            00039 ones    EQU     36      ; Ones digit in decimal value
                      00040 
                      00041 ;----------------------------------------------------------
                      00042 ; PROGRAM BEGINS
                      00043 ;----------------------------------------------------------
                      00044 
0000                  00045         ORG     0               ; Default start address 
0000   0000           00046         NOP                     ; required for ICD mode
                      00047 
                      00048 ;----------------------------------------------------------     
                      00049 ; Port & display setup
MPASM 03.70.01 Released                            TENBIT.ASM   3-28-2006  22:41:23         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00050 
0001   1683 1303      00051         BANKSEL TRISC           ; Select bank 1
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0003   0188           00052         CLRF    TRISD           ; Display port is output
0004   3083           00053         MOVLW   B'10000011'     ; Analogue input setup code
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
0005   009F           00054         MOVWF   ADCON1          ; Right justify result, 
                      00055                                 ; Port A = analogue inputs
                      00056                                 ; with external reference
                      00057 
0006   1283 1303      00058         BANKSEL PORTC           ; Select bank 0
0008   0188           00059         CLRF    PORTD           ; Clear display outputs
0009   3041           00060         MOVLW   B'01000001'     ; Analogue input setup code
000A   009F           00061         MOVWF   ADCON0          ; f/8, RA0, done, enable  
                      00062 
000B   209E           00063         CALL    inid            ; Initialise the display
                      00064 
                      00065 ;----------------------------------------------------------
                      00066 ; MAIN LOOP
                      00067 ;----------------------------------------------------------
                      00068 
000C   2010           00069 start   CALL    getADC          ; read input
000D   2018           00070         CALL    con4            ; convert to decimal
000E   205E           00071         CALL    putLCD          ; display input
000F   280C           00072         GOTO    start           ; jump to main loop
                      00073 
                      00074 ;-----------------------------------------------------------
                      00075 ; SUBROUTINES
                      00076 ;-----------------------------------------------------------
                      00077 ; Read ADC input and store
                      00078 ;-----------------------------------------------------------
                      00079 
0010   3007           00080 getADC  MOVLW   007             ; load counter
0011   00B0           00081         MOVWF   count
Message[305]: Using default destination of 1 (file).
0012   0BB0           00082 down    DECFSZ  count           ; and delay 20us
0013   2812           00083         GOTO    down
                      00084 
0014   151F           00085         BSF     ADCON0,GO       ; start ADC..
0015   191F           00086 wait    BTFSC   ADCON0,GO       ; ..and wait for finish
0016   2815           00087         GOTO    wait
0017   0008           00088         RETURN                          
                      00089         
                      00090 ;-----------------------------------------------------------
                      00091 ; Convert 10-bit input to decimal 
                      00092 ;-----------------------------------------------------------
                      00093 
0018   081E           00094 con4    MOVF    ADRESH,W        ; get ADC result
0019   00B1           00095         MOVWF   ADhi            ; high bits
001A   1683 1303      00096         BANKSEL ADRESL          ; in bank 1
Message[302]: Register in operand not in bank 0.  Ensure that bank bits are correct.
001C   081E           00097         MOVF    ADRESL,W        ; get ADC result
001D   1283 1303      00098         BANKSEL ADRESH          ; default bank 0
MPASM 03.70.01 Released                            TENBIT.ASM   3-28-2006  22:41:23         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

001F   00B2           00099         MOVWF   ADlo            ; low byte
                      00100 
                      00101 ; Multiply by 4 for result 0 - 4096 by shifting left.........
                      00102 
0020   1003           00103         BCF     STATUS,C        ; rotate 0 into LSB and
Message[305]: Using default destination of 1 (file).
0021   0DB2           00104         RLF     ADlo            ; shift low byte left
0022   1C03           00105         BTFSS   STATUS,C        ; carry out?
0023   2825           00106         GOTO    rot1            ; no, leave carry clear
0024   1403           00107         BSF     STATUS,C        ; rotate 1 into LSB and
Message[305]: Using default destination of 1 (file).
0025   0DB1           00108 rot1    RLF     ADhi            ; shift high byte left
                      00109 
0026   1003           00110         BCF     STATUS,C        ; rotate 0 into LSB
Message[305]: Using default destination of 1 (file).
0027   0DB2           00111         RLF     ADlo            ; rotate low byte left again
0028   1C03           00112         BTFSS   STATUS,C        ; carry out?
0029   282B           00113         GOTO    rot2            ; no, leave carry clear
002A   1403           00114         BSF     STATUS,C        ; rotate 1 into LSB and
Message[305]: Using default destination of 1 (file).
002B   0DB1           00115 rot2    RLF     ADhi            ; shift high byte left
                      00116 
                      00117 
                      00118 ; Clear BCD registers........................................
                      00119 
002C   01B3           00120 clrbcd  CLRF    thos            ; zero thousands digit
002D   01B4           00121         CLRF    huns            ; zero hundreds digit
002E   01B5           00122         CLRF    tens            ; zero tens digit
002F   01B6           00123         CLRF    ones            ; zero ones digit
                      00124 
                      00125 
                      00126 ; Calclulate thousands low byte .............................
                      00127 
0030   08B1           00128 tholo   MOVF    ADhi,F          ; check high byte
0031   1903           00129         BTFSC   STATUS,Z        ; high byte zero?
0032   2847           00130         GOTO    hunlo           ; yes, next digit
                      00131 
0033   1403           00132         BSF     STATUS,C        ; set carry for subtract
0034   30E8           00133         MOVLW   0E8             ; load low byte of 1000
Message[305]: Using default destination of 1 (file).
0035   02B2           00134         SUBWF   ADlo            ; and subtract low byte
0036   1803           00135         BTFSC   STATUS,C        ; borrow from high bits?
0037   2839           00136         GOTO    thohi           ; no, do high byte
Message[305]: Using default destination of 1 (file).
0038   03B1           00137         DECF    ADhi            ; yes, subtract borrow
                      00138 
                      00139 ; Calculate thousands high byte..............................
                      00140         
0039   1403           00141 thohi   BSF     STATUS,C        ; set carry for subtract
003A   3003           00142         MOVLW   003             ; load high byte of 1000
Message[305]: Using default destination of 1 (file).
003B   02B1           00143         SUBWF   ADhi            ; subtract from high byte
003C   1803           00144         BTFSC   STATUS,C        ; result negative?
MPASM 03.70.01 Released                            TENBIT.ASM   3-28-2006  22:41:23         PAGE  4


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

003D   2845           00145         GOTO    incth           ; no, inc digit and repeat      
Message[305]: Using default destination of 1 (file).
003E   07B1           00146         ADDWF   ADhi            ; yes, restore high byte
                      00147 
                      00148 ; Restore remainder when done ...............................
                      00149 
003F   1003           00150         BCF     STATUS,C        ; clear carry for add
0040   30E8           00151         MOVLW   0E8             ; load low byte of 1000
Message[305]: Using default destination of 1 (file).
0041   07B2           00152         ADDWF   ADlo            ; add to low byte
0042   1803           00153         BTFSC   STATUS,C        ; carry out?
Message[305]: Using default destination of 1 (file).
0043   0AB1           00154         INCF    ADhi            ; yes, inc high byte
0044   2847           00155         GOTO    hunlo           ; and do next digit
                      00156 
                      00157 ; Increment thousands digit and repeat.......................
                      00158 
Message[305]: Using default destination of 1 (file).
0045   0AB3           00159 incth   INCF    thos            ; inc digit
0046   2830           00160         GOTO    tholo           ; and repeat
                      00161 
                      00162 ; Calclulate hundreds .......................................
                      00163 
0047   3064           00164 hunlo   MOVLW   064             ; load 100
0048   1403           00165         BSF     STATUS,C        ; set carry for subtract
Message[305]: Using default destination of 1 (file).
0049   02B2           00166         SUBWF   ADlo            ; and subtract low byte
004A   1803           00167         BTFSC   STATUS,C        ; result negative?
004B   2850           00168         GOTO    inch            ; no, inc hundreds & repeat
                      00169         
004C   08B1           00170         MOVF    ADhi,F          ; yes, test high byte
004D   1903           00171         BTFSC   STATUS,Z        ; zero?
004E   2852           00172         GOTO    remh            ; yes, done
Message[305]: Using default destination of 1 (file).
004F   03B1           00173         DECF    ADhi            ; no, subtract borrow
Message[305]: Using default destination of 1 (file).
0050   0AB4           00174 inch    INCF    huns            ; inc hundreds digit
0051   2847           00175         GOTO    hunlo           ; and repeat
                      00176 
Message[305]: Using default destination of 1 (file).
0052   07B2           00177 remh    ADDWF   ADlo            ; restore onto low byte
                      00178 
                      00179 
                      00180 ; Calculate tens digit......................................
                      00181 
0053   300A           00182 subt    MOVLW   D'10'           ; load 10
0054   1403           00183         BSF     STATUS,C        ; set carry for subtract
Message[305]: Using default destination of 1 (file).
0055   02B2           00184         SUBWF   ADlo            ; and subtract from result
0056   1C03           00185         BTFSS   STATUS,C        ; and check if done
0057   285A           00186         GOTO    remt            ; yes, restore remainder
Message[305]: Using default destination of 1 (file).
0058   0AB5           00187         INCF    tens            ; no, count number of loops
MPASM 03.70.01 Released                            TENBIT.ASM   3-28-2006  22:41:23         PAGE  5


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0059   2853           00188         GOTO    subt            ; and repeat
                      00189 
                      00190 
                      00191 ; Restore remainder.........................................
                      00192 
Message[305]: Using default destination of 1 (file).
005A   07B2           00193 remt    ADDWF   ADlo            ; yes, add 10 back on
005B   0832           00194         MOVF    ADlo,W          ; load remainder
005C   00B6           00195         MOVWF   ones            ; and store as ones digit
                      00196 
005D   0008           00197         RETURN                  ; done
                      00198 
                      00199 
                      00200 ;-----------------------------------------------------------
                      00201 ; Output to display
                      00202 ;-----------------------------------------------------------
                      00203 
005E   10F4           00204 putLCD  BCF     Select,RS       ; set display command mode
005F   3080           00205         MOVLW   080             ; code to home cursor
0060   208E           00206         CALL    send            ; output it to display
0061   14F4           00207         BSF     Select,RS       ; and restore data mode
                      00208 
                      00209 ; Convert digits to ASCII and display.......................
                      00210 
0062   3030           00211         MOVLW   030             ; load ASCII offset
Message[305]: Using default destination of 1 (file).
0063   07B3           00212         ADDWF   thos            ; convert thousands to ASCII
Message[305]: Using default destination of 1 (file).
0064   07B4           00213         ADDWF   huns            ; convert hundreds to ASCII

⌨️ 快捷键说明

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