You are on page 1of 15

;**********************************************************************

; This file is a basic code template for assembly code generation *


; on the PIC16F84A. This file contains the basic code
; building blocks to build upon.

*
*

; Refer to the MPASM User's Guide for additional information on


; features of the assembler (Document DS33014).
;

; Refer to the respective PIC data sheet for additional

; information on the instruction set.

;**********************************************************************
;

Filename:

Date:

File Version:

7segdisplay.asm

*
*
*
*

Author: Anon

Company:

*
*

;**********************************************************************
;
;
;

*
Files required: P16F84A.INC

*
*

;**********************************************************************
;
;

*
Notes:

;**********************************************************************

list

p=16F84A

; list directive to define processor

#include <p16F84a.inc>

; processor specific variable definitions

__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC

; '__CONFIG' directive is used to embed configuration data within .asm file.


; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

;***** VARIABLE DEFINITIONS


w_temp

EQU

status_temp EQU

0x0C
0x0D

; variable used for context saving


; variable used for context saving

;**********************************************************************

RESET_VECTOR
goto

ISR

CODE

start

0x0000 ; processor reset vector

; go to beginning of program

CODE

0x0004 ; interrupt vector location

Interrupt:

movwf w_temp

; save off current W register contents

movf STATUS,w

; move status register into W register

movwf status_temp

; save off contents of STATUS register

; Place ISR Here

movf status_temp,w
movwf STATUS

; retrieve copy of STATUS register


; restore pre-isr STATUS register contents

swapf w_temp,f
swapf w_temp,w
retfie

MAIN_PROGRAM

; restore pre-isr W register contents


; return from interrupt

CODE

start:

; remaining code goes here


LIST P = 16F84A
STATUS EQU 0x03

TRISA EQU 0X85


PORTA EQU 0x05
PORTB EQU 0x06
TRISB EQU 0x86
COUNT EQU 08h

BSF

STATUS,5

MOVLW 0FFh
MOVWF TRISA
MOVLW 00h
MOVWF TRISB
BCF STATUS,5
CLRF TRISB

DISPLAY
MOVLW 003h
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

DISPLAY1
MOVLW 09FH
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY2

DISPLAY2
MOVLW 025H
MOVWF PORTB

CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY3

DISPLAY3
MOVLW 0DH
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY4

DISPLAY4
MOVLW 099H
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY5

DISPLAY5
MOVLW 049H
MOVWF PORTB
CALL DELAY

CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY6

DISPLAY6
MOVLW 041H
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

CALL DELAY
CALL DELAY
GOTO DISPLAY7

DISPLAY7
MOVLW 01FH
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY8

DISPLAY8
MOVLW 01H
MOVWF PORTB
CALL DELAY
CALL DELAY

CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY9

DISPLAY9
MOVLW 019H
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

CALL DELAY
GOTO DISPLAY10

DISPLAY10
MOVLW 010h
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY11

DISPLAY11
MOVLW 040h
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY

CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY12

DISPLAY12
MOVLW 062h
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

GOTO DISPLAY12

DISPLAY12
MOVLW 084h
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY13

DISPLAY13
MOVLW 60h
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
GOTO DISPLAY14

DISPLAY14
MOVLW b'01110000'
MOVWF PORTB
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY
CALL DELAY

DELAY
decfsz COUNT,1
GOTO DELAY

RETURN

GOTO $

END

You might also like