Question

1. Write code to turn on bit 4 of PORTC, where bit 4 is configured as...

1. Write code to turn on bit 4 of PORTC, where bit 4 is configured as output bit.

2. What does this code in assembly do? You can write your answer in a high-level language like C.

MOVF Q,W

SUBWF P,F

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Ans.

1)

C code:

#include<p18f452.h>
int main()
{
TRISC.F3 = 0; //Configure 4th bit of PORTC as Output.
PORTC.F3 = 1; //Turn on 4th bit of PORTC.
return (0);
}

2)

MOVF Q,W :

It is used to move contents of Q register , if W=0,contents of Q register is moved to Working register WREG. If W=1,the contents of register Q is copied to itself this is used to check if a register has value zero as when the value is copied to itself the zero flag is affected ie, if the content is zero after this instructon z flag goes high.

SUBWF P,F :

Substracts W register from P register and if F is 0 result is stored in WREG (Working register) else if F is 1, result is stored back to the file register P.

Add a comment
Know the answer?
Add Answer to:
1. Write code to turn on bit 4 of PORTC, where bit 4 is configured as...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT