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

1. Consider the following assembly language code. The clock frequency is 4 MHz a

ID: 3839443 • Letter: 1

Question

1. Consider the following assembly language code. The clock frequency is 4 MHz and all initialization steps have been done correctly (like setting up digital I/O, the oscillator configuration, etc.) Constants Bit Pattern EQU H 20 LoopCtr EQU H 21 23 Max Count EQU Main program loop Main Loop CLRF Bit Pattern CALL Output BSF Bit Pattern, 1 CALL Output RRF Bit Pattern CALL Output BSF BitPattern, 1 CALL Output GOTO MainLoop MovF Bit Pattern, W Output MOVWF PORTB MOVLW Max Count MOVINF LoopCtr NOP Loop DECFSZ LoopCtr GOTO Loop NOP RETURN

Explanation / Answer

Answer

In MainLoop:
CLRF BitPattern will clear BitPattern so it will give 0x00
BSF BitPattern,1 ; will set bit 1 of BitPattern so it will give 0x01
RRF BitPattern will rotate right so it will give 0x00
BSF BitPattern, 1 ; will set bit 1 of BitPattern again so it will give 0x01

In Output:
MOVF BitPattern, W ;will move the content of BitPattern to W
               ;so W will have 0x01