40 2 code segment writinga write an assembly code


(40) 2. Code Segment Writing.

a) Write an assembly code segment that calls the subroutine New Function if bits 5 and 6 of PORTD equal 1.  

b) Write the same code segment in part (a) using structured assembly constructs.  

c) Write an assembly code segment to toggle bit 4 of FORMBYTE, leaving the remaining bits unchanged.

d) Write an assembly code segment to form from the value of the char variable TEMPB a new value of  TEMPB of the form 000øbbbl2 where bbbb represents the original four most significant bits of TEMPB.  

e) Assume that WREG contains a number of the form 00000b2b1b0. Using a sequence of the three  instruction- xorwf, andlw, xorwf -‚ update the lower three bits of PORTB with the b2bb0 bits in WREG,  while leaving, the upper five bits of PORTB unchanged.   

 (20) 3. LCD Control and Display.

a) What is the cursor-position code, expressed as a hex number, that you would employ in a display string to center a two-character message in the top row of your 8x2 character display?

b) Write a code segment that displays the two character message "Hi" starting at the position you identified in part (a). Assume that the character string is residing in program memory and that the PIC microcontroller is initialized for a 4-bit interface LCD. (Accurate code is not required, rather, identify the required instruction steps.

(20) 4. a) Analyze the following assembly code segment:

MOVLF 60,COUNT

REPEAT_

btg PORTA,RA4

decf COUINT, F

UNTIL _.Z.  

b) Assuring that the internal clock rate of the microcontroller is 2.5MHz. What should the Bignum value for the LoopTime subroutine be to make it count with a scale of 2,500 cyclesto generate precisely a imillisecond delay between every rollover of TMROIF?

Solution Preview :

Prepared by a verified Expert
Electrical Engineering: 40 2 code segment writinga write an assembly code
Reference No:- TGS0467524

Now Priced at $25 (50% Discount)

Recommended (92%)

Rated (4.4/5)