;**************************************************
; Filename: Ass2_2017_Elbobbo.asm (your file name)
; Date:
; Author: Elbobbo
;**************************************************
; Program description:
; Assembly code to output a 10 digit ASCII coded
; student number one character at a time, as Excess-3 code, to 4 LEDs.
; ...
;************************************************************
;
; Directive sets processor type .............................
list p=16F84A
#include "P16F84A.INC"
; Set configuration fuses ...................................
__CONFIG _CP_OFF & _WDT_OFF &_PWRTE_ON & _RC_OSC
; Code protection off, watchdog timer off, power up timer on, RC Clock
errorlevel -302 ;No warnings about register not in Bank 0
; Variable definitions***************************************
charpos equ 0x18 ; keep position
dly0 equ 0x19 ;
dly1 equ 0x20
dly2 equ 0x21 ;
dly3 equ 0x22
holding equ 0x23 ; used for subtract
; Set program origin*****************************************
ORG 0x00
goto main
; Subroutines **************************************
; Initialise Port B .................................
initalise:
bcf STATUS,RP0 ;Bank select 0
clrf PORTB ;Clear Port B data latches
bsf STATUS,RP0 ;Bank select 1
movlw 0x00 ;
movwf TRISB ;Set port B lines to output
bcf STATUS,RP0 ;Bank select 0
clrf charpos ;start at begining
retlw 0
; Student number ASCII table ..............................
snum: addwf PCL, f
dt "0061076281",0 ;Student number "null terminated
; Delay timer ......................................
delay4: movlw 4
movwf dly0 ; about 4 seconds
delaya: call delay1
decfsz dly0
goto delaya
retlw 0
delay1: movlw 1 ; about a second
movwf dly1
clrf dly3
clrf dly2
delayb: nop
decfsz dly3
goto delayb
decfsz dly2
goto delayb
decfsz dly1
goto delayb
retlw 0
;Place delay subroutine code here
; Main program **********************************************
main:
call initalise ; need to call initailise
andlw 0 ; clear w
loop:
movf charpos,w ; get char position
bcf STATUS,C ; make sure clear befor add..
call snum ; fetch Character
andlw 0xff ; control zero test
btfsc STATUS,Z ; all done?
goto flash
movwf holding ; save character
movlw 0x2d ; adjust for ascii and Xs3
subwf holding,w ;
movwf PORTB ; display
call delay4 ; view time
clrf PORTB ;
call delay1 ; off
incf charpos ; next char
goto loop
flash:
movlw 0xf ; flash on
movwf PORTB ;
call delay1 ; flash off
clrf PORTB ;
call delay1
goto flash ; forever..
END