Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Provide a partial analysis of the program below by including the following two i

ID: 3790667 • Letter: P

Question

Provide a partial analysis of the program below by including the following two items:

1. A flowchart of the code, starting with address TOP, that executes while the button remains pushed.

2. A complete timing analysis of the code referenced in item 1, including a statement of the number of

instruction cycles and the time in seconds needed for this code to execute once. Compare this theoretical

time with the observed time needed for the LED to toggle from off to on or from on to off with the button

pushed.

Table I

Light flasher program

;light flasher DMK 12/21/2013

list P=PIC16F84

;equates

count0 equ H’0C’

count1 equ H’0D’

porta equ H’05’

portb equ H’06’

status equ H’03’

trisa equ H’05’

trisb equ H’06’

org H’0’

;beginning of program

goto start

start clrf porta

clrf portb

bsf status,5

movlw 0

movwf trisa ;all Port A bits outputs

movlw 2

movwf trisb ;Port B bit 1 an input

bcf status,5

;beginning of first loop

top movlw H’0E’

movwf count0

inner1 movlw H’0C3’

movwf count1

loop1 decfsz count1,1

goto loop1

decfsz count0,1

goto inner1

movlw H’1’

xorwf porta,1 ;toggle the LED

btfss portb,1 ;test the pushbutton

goto top ;jump to first loop if button pressed

;beginning of second loop

movlw H’0E’ ;continue with second loop if button released

movwf count0

inner2 movlw H’0C3’

movwf count1

loop2 decfsz count1,1

goto loop2

decfsz count0,1

Explanation / Answer

count0 equ H’0C’

count1 equ H’0D’

porta equ H’05’

portb equ H’06’

status equ H’03’

trisa equ H’05’

trisb equ H’06’

org H’0’

;beginning of program

goto start

start clrf porta

clrf portb

bsf status,5

movlw 0

movwf trisa ;all Port A bits outputs

movlw 2

movwf trisb ;Port B bit 1 an input

bcf status,5

;beginning of first loop

top movlw H’0E’

movwf count0

inner1 movlw H’0C3’

movwf count1

loop1 decfsz count1,1

goto loop1

decfsz count0,1

goto inner1

movlw H’1’

xorwf porta,1 ;toggle the LED

btfss portb,1 ;test the pushbutton

goto top ;jump to first loop if button pressed

;beginning of second loop

movlw H’0E’ ;continue with second loop if button released

movwf count0

inner2 movlw H’0C3’

movwf count1

loop2 decfsz count1,1

goto loop2

decfsz count0,1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote