Chapter 3 - Review Questions:
-
Please focus on the following commands for the quiz:
- Arithmetic commands (ADDLW, ADDWF, ADDWFC, SUBLW, SUBWF, SUBWB, INC, DEC, MULLW, NEGF, COMPF)
- Logical commands, ANDLW, XOR, IOR, AND)
- MOVE & Copy (MOVLW, MOVFF, MOVWF, CLR, SETF)
- Branches (BC, BNC, BZ, BNZ, BOV, BRA, GOTO)
- Bit manipulations (BCF, BSF, BTG, RLCF, RRCF)
- Make sure you know about flags.
- Make sure you can do the homework assignment
- Physically, exactly, where is the BSR register? What is it called?
- Can the program counter be set to 0xF00543? How so?
- How can we obtain the value of the program counter and save it in the RAM locations, say within the range of REG10-REG20?
- If a program starts with ORG 0x0 and it has 10 one-word long instructions, what will be the location of the PC AFTER the last line is executed?
- While executing a program, is it possible that the value of a PC is decremented?
- What are two examples of unconditional branches? NEW
- What is bit masking? ANSWER: Using a mask, multiple bits in a bye (etc.) can be set either on, off or inverted from on to off (or vice versa) in a single bitwise operation.
- A single one-word instruction in PIC 18F takes how many clock cycles to be executed?
- Assuming a PIC operates at 1MHz. How long (in terms of time) does it take to execute MOVFF? .
- Assuming a PIC operates at 1MHz. How long (in terms of time) does it take to copy the content of registers 1-9 to registers 100-109. Explain. Is there a way to perform this operation faster?
Review Questions about Instructions: Note: If you are not sure please EXECUTE the commands in your simulator and check the results!
- What command will you use to take the 2's complement of 0x04? What will be the result? Where will the result be lcated at? NEW
- Is it possible to add a literal and the content of a register using a simple command?
- What will SUBLW 0x131 result?
- Does this work: GOTO MY_OFFICE?
- Does this work: BRA MY_TREE?
- Assume REG10 contains 0x40. Using a single instruction change the content of REG10 to 0x04. NEW
- What will SUBWF 3,1,1 result?
- Assume we run the following instruction: ORG 0x20;
NOP; NOP; NOP; MOVWF 0x20. Will it work? If so, what will be the adress of the next PC after MOV command is executed? NEW
- Assume the Status register and WREG both contain 0xFF; REG05 and REG04 contain 0x04. Assume you execute RRCF 0x04,0,0. What will be the value of STAT reg? What will be the value of WREG? What will be the value of REG05?
What will be the value of REG04?
NEW
- Assuming REG10 is holding 0xA. What will INC 0xA,1,1 result?
- What will MULLW 0x2,0x4 result?
Explain.
- What will MULLW 0xA result? Explain.
- If WREG=0x2, and then we execute MULLW 0xA, what will be the content of PRODH?
- What does DAW do?
- If we XOR 0xXY value with 0x0F what will happen to 0xXY?
- Assume 0xXY is a two digit HEX value. If we IOR 0xXY value with 0x0F what will be the result?
- How can we Mask bits 6 and 7 to 1's in 10010101 (note: LSB is zero and MSB is 7)?
- How can you perform "Querying the status of a bit", for exmaple bit 3 in 10010101 (starting with bit 0)? ANSWER: AND 10011101 with 0x08 - Read this for more info: https://en.wikipedia.org/wiki/Mask_(computing)#Masking_bits_to_1 )
- Write a set of instrcutions to divde any 8-bit value X=2^n (say X=64) by 4, add 4 to the results, and then multiply it by 4 (e.g., if the input is X=64 then you should get 80). Is there an easier way to do this?