Question: Can some on please explain the assembly language below to me in a simple way? Including a flowchart of what is happening? Directive sets processor
Can some on please explain the assembly language below to me in a simple way?
Including a flowchart of what is happening?
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
; Register Label Equates ************************************
PORTB EQU 0x06 ;Port B
TRISB EQU 0x86 ;Data direction register B
STATUS EQU 0x03 ;Status register
Z EQU 0x02 ;Status register Z bit
RP0 EQU 0x05 ;Bank select bit
PCL EQU 0x02 ;Program counter register
;user equates here
strlen EQU 0x0A ;string length, 10 characters in total
asclen EQU 0x07 ;ASCII character bit length (7)
sub45 EQU 2D ;The decimal number 45, required to be subtracted from the ASCII character
; Variable definitions***************************************
charpos EQU 0x18
dly0 EQU 0x19
dly1 EQU 0x20
dly2 EQU 0x21
dly3 EQU 0x22
holding EQU 0x23
;Place user variables here
; 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 the begining
retlw 0
; Student number ASCII table ..............................
snum addwf PCL,F
dt "123456789",0 ;Student number
; 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
; Excess 3 code table for LED display on Port B ..
binary addwf PCL,F
retlw b'00000011' ;Set display to 0
retlw b'00000011' ;Set display to 0
retlw b'00001001' ;Set display to 6
retlw b'00000100' ;Set display to 1
retlw b'00000011' ;Set display to 0
retlw b'00001010' ;Set display to 7
retlw b'00001001' ;Set display to 6
retlw b'00000101' ;Set display to 2
retlw b'00001011' ;Set display to 8
retlw b'00000100' ;Set display to 1
; Main program **********************************************
main
call initalise ;need to call initailise
andlw 0 ;clear w
goto loop
loop
movf charpos,w ;get char position
bcf STATUS,C ;make sure clear before 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 character in ASCII code string
goto loop
flash
movlw 0xf ;flash on
movwf PORTB ;
call delay1 ;flash off
clrf PORTB ;
call delay1 ;
goto flash ;goes back to flash on. endless loop
END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
