MPASM 02.15 Released EXPT4.ASM 3-13-2002 12:04:23 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;Expt4.asm 00002 ;Project: Counting on 7-segment display 00003 ;List P = 16F84 00004 ;#include 00005 ;__CONFIG 1Bh    ;_CP_OFF & _PWRTE_ON & _WDT_OFF & _RC_OSC 00006 00007 0000 00008 ORG 0 ;This is the start of memory for the program. 0000 1683 00009 SETUP BSF 03,5 ;Go to Bank 1 0001 0186 00010 CLRF 06 ;Make all port B output 0002 3001 00011 MOVLW 01 ;Load W with 0000 0001 0003 0085 00012 MOVWF 05 ;Make RA0 input 0004 1283 00013 BCF 03,5 ;Go to Bank 0 - the program memory area. 0005 019F 00014 CLRF 1F ;Clear the button-press file 0006 2816 00015 GOTO MAIN 00016 0007 0782 00017 TABLE ADDWF 02H,1 ;Add W to the Program Counter to create a jump. 0008 343F 00018 RETLW 3FH ;0    format= gfedcba 0009 3406 00019 RETLW 06H ;1    If any table value has a leading letter, it must be 000A 345B 00020 RETLW 5BH ;2 preceded with a "0." E.g: 0A3h, 0FFh, 0CCh 000B 344F 00021 RETLW 4FH ;3 000C 3466 00022 RETLW 66H ;4 000D 346D 00023 RETLW 6DH ;5 000E 347D 00024 RETLW 7DH ;6 000F 3407 00025 RETLW 07H ;7 0010 347F 00026 RETLW 7FH ;8 0011 346F 00027 RETLW 6FH ;9  00028 00029 0012 0000 00030 DELAY NOP ;Create 1mS debounce delay 0013 0B9A 00031 DECFSZ 1A,1 0014 2812 00032 GOTO DELAY 0015 0008 00033 RETURN 00034 0016 30FF 00035 MAIN MOVLW 0FFH ;File 1E holds the count-value 0017 009E 00036 MOVWF 1E ;Next increment will make file=0 0018 1C05 00037 MAIN1 BTFSS 05,0 ;Test the input line on port A 0019 2827 00038 GOTO MAIN2 ;Button not pressed 001A 2012 00039 CALL DELAY ;Debounce the button 001B 181F 00040 BTFSC 1F,0 ;Button pressed first time? 001C 2818 00041 GOTO MAIN1 ;Button already pressed 001D 0A9E 00042 INCF 1E,1 ;First time button pressed. Increment count. 001E 300A 00043 MOVLW 0A ;Has count reached ten? 001F 061E 00044 XORWF 1E,0 ;Compare file 1E with ten 0020 1903 00045 BTFSC 03,2 ;Check the zero flag in Status file 0021 2816 00046 GOTO MAIN ;Count has reached ten 0022 081E 00047 MOVF 1E,0 ;Copy count into W 0023 2007 00048 CALL TABLE ;W will return with display-value 0024 0086 00049 MOVWF 06 ;Output display value 0025 141F 00050 BSF 1F,0 ;Set button-press flag 0026 2818 00051 GOTO MAIN1 ;Loop Main1 0027 2012 00052 MAIN2 CALL DELAY ;Button not pressed. Call Delay 0028 101F 00053 BCF 1F,0 ;Clear button-press flag MPASM 02.15 Released EXPT4.ASM 3-13-2002 12:04:23 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0029 2818 00054 GOTO MAIN1 ;Loop Main1 00055 00056 END ;Tells assembler end of program MPASM 02.15 Released EXPT4.ASM 3-13-2002 12:04:23 PAGE 3 SYMBOL TABLE LABEL VALUE DELAY 00000012 MAIN 00000016 MAIN1 00000018 MAIN2 00000027 SETUP 00000000 TABLE 00000007 __16F84 00000001 MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXX------ ---------------- All other memory blocks unused. Program Memory Words Used: 42 Program Memory Words Free: 982 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 0 reported, 0 suppressed