|
50
Questions on the '508A
How much do you know about the '508A?
The best way to find out is to answer a set of questions.
Here's 50 questions on the in's and out's this micro. See how much you know.
Why learn about the '508A? . . . . . Why? Because it's much more powerful
than you think.
New versions with 64 bytes of RAM, A to D lines and 1024 bytes of
memory are available and allow you to put together very powerful
miniature projects. So it shouldn't be overlooked the next time you
are thinking of making a project for your self or even a commercial venture.
1. What does the ORG 000 statement mean?
Ans: It tells the assembler to place the next instruction at memory
address zero.
2. How can you test to see if a file is zero?
Ans: MOVF 1A,1
BTFSS 03,2
;test Z flag
3. If a file is zero, what is the value of the Z flag after the file
is tested via the instruction:
BTFSS 03,2:
Ans: The Z flag = SET = 1
4. The contents of file 1A is "moved" (MOVF 1A,0) to the W register.
After moving, what is the value in file 1A?
Ans: The same as before. The instruction means "copy."
5. Describe the following instruction:
CALL Label
Ans: The instruction tells the micro to make a CALL to a sub-routine
that has its first instruction at an address identified by the word
"Label."
6. What does the word "Label" mean?
Ans: It means a name or tag (or set of letters) to identify the address
of the first instruction of a sub-routine so the assembler can find it.
7. For a '508A, where in memory can a sub-routine be placed so the
micro can find it? Give the address range:
Ans: 000 to 0FF - only the first half of program space for a '508A.
8. For a PIC16F84, state the address range for "CALL Label."
Ans: 000 to 7FF
9. Explain the instruction: BCF 06,2
Ans: Clear bit 2 of file 6 - the input/output port (file). i.e: Zero
the bit.
10. What does WDT mean?
Ans: WatchDog Timer. A separate timer within the micro that counts
for 18mS and resets the micro (unless WDT is turned OFF).
11. How do you reset the WDT?
Ans: CLRWDT
12. How do you disable the WDT?
Ans: When burning the chip, set WDT_OFF in the config setup.
13. Explain the following:
Loop1 GOTO Loop1
Ans: This is the same as a HALT or STOP instruction. The micro will
loop around this instruction indefinitely unless the WDT (Watchdog
Timer) is SET.
14. How do you increment W?
Ans: There is no direct instruction to increment W. Put W into a temporary
file, INC the file and copy the result into W - It only takes two
instructions:
MOVWF 1A,1
INCF 1A,0
15. How do you double a value in a file? In other words how do multiply
by two?
Ans: Clear the carry flag and rotate left the file:
BCF 03,0
RLF 1A,1
This only works if the number is 7F or less. If the value in the file
is unknown, test bit 7 of the file to see if it is zero:
BTFSS 1A,7
GOTO Below
BCF 03,0
RLF 1A,1
Below (the next instruction is placed here)
16. What file is the input/output port?
Ans: file 06
17. How many port lines for a '508A?
Ans: 6 lines.
18. What is special about line 3 (GP3)?
Ans: It is input only.
19. Name the Port lines for a '508A:
Ans: GP0, GP1, GP2, GP3, GP4, GP5
20. Name the output lines for a '508A:
Ans: GP0, GP1, GP2, GP4, GP5
21. What is the name of the register that controls the bits on the
port to make them input or output?
Ans: The TRIS register.
To make Bit0 an output, the instructions are:
MOVLW 0011 1110 ;Put 3E into W
MOVWF TRIS 06
;Make GP0 output
22. Can GP0 be both input AND output?
Ans: Yes, but not at the SAME TIME. The direction of a port line (except
GP3) can be changed at any time during the running of a program. See
Changing Direction in Library of Routines.
23. What does RETLW mean?
Ans: It means RETURN from sub-routine with a value in W. The value
will be the hex value contained in the instruction:
e.g: RETLW 00
RETLW BC
RETLW FF
You cannot create a sub-rotuine that "puts a value into W." The value
in W is "locked-in" during the initial writing of the program.
24. What are these instructions doing?
MOVLW 08
XORWF 1A,0
BTFSS 03,2
Ans: The instructions test the zero flag to see if file 1A contains 08.
25. What is the value in W after the following 4 instructions:
MOVLW 08
MOVWF 1A
MOVF 1B,0
MOVF 1A,1
Ans: After the first instruction W = 08. After the 2nd instruction
W = 08. After the 3rd instruction W = unknown as the value in file
1B is unknown. After the 4th instruction W = unknown as MOVF 1A,1 moves
the value in and out of 1A but not into W.
26. What does the following instruction mean:
INCF address,W
Ans: Increment the value contained in the file at the specified address
and place the result in W.
Our programming code is easier to understand. Our instruction takes
the form:
INCF 1A,0
Where 1A is the file and 0 is the destination W.
27. How do you increment an address?
Does this statement mean:
(a) Increment from file 1A to file 1B or,
(b) Increment the contents at the specified address?
See Q26 for answer to (b).
Ans: To increment from one address to another see INCrement Address
in Library of Routines.
28. What is the value in 1A after the following 3 instructions:
MOVLW 3C
MOVWF 1A
SWAPF 1A,1
Ans: C3
29. Describe the operation of the following instruction:
BTFSS 06,1
The instruction is testing GP1 and most likely this is an input bit
and the program is testing for a HIGH.
30. What are these instructions doing:
MOVF 1A,1
BTFSS 03,2
Ans: Testing to see if file 1A is zero.
31. If a table starts at address 080h, what is its maximum length.
Ans: 080h - 1 so it does not go over the first page boundary.
32. How can you find the address of a sub-routine?
Ans: Go to the .LST file and read the address value for each label
and instruction.
33. Can a sub-routine be CALLed, that is lying across the page boundary
of a '508A?
Ans: Yes. It's only a Table that must not go over the page boundary.
34. How do you load a file from another file?
Ans: e.g: Move the contents of file 1A to 1B:
MOVF 1A,0
MOVWF 1B,1
35. How many delay loops can be created with a single file:
Ans: 256 loops
36. How do you load the TRIS register?
Ans: Each bit in the TRIS register operates on the corresponding bit
in the input/output port (file 06). For each port line required to
be made an input, make the corresponding bit in TRIS "1." When you
have worked out the value for the 6 bits, they are loaded into W and
moved from W to the TRIS register thus:
E.g: To make lines GP0 and GP3 input:
MOVLW 09
;0000 1001
TRIS 06
;GP0 and GP3 = input
37. How many uS for the following instructions. Work out the total
and look for the "catch."
CLRF 0C
MOVF 0C,0
INCF 0C,1
BTFSS 0C,6
GOTO Below
INCF 0C,1
MOVLW 04
MOVWF 0C,1
Below
Ans: 6uS. At BTFSS, file 0C will be 01 and bit 6 will be zero. The
next instruction (GOTO Below) will be executed by the micro and the
next three instructions are not counted.
38. Describe one of the uses for the AND operation?
Ans: To mask a HIGH or LOW nibble.
To remove the high nibble from a number, the file is ANDed with 0F.
See Library of Routines.
39. Describe a use for the XOR operation.
Ans: It can be used to see if two files are the SAME.
40. How do you make a port line HIGH?
Ans: Step 1: Make the corresponding bit in TRIS an output by making
it "0."
Step 2: SET the required bit in file 6 (the input/output port). i.e:
make it "1."
41. Where do you find the Carry flag?
Ans: In the STATUS file (03) bit 0.
42. Where do you find the Zero flag?
Ans: In the STATUS file (03) bit 2.
43. Write an instruction for HALT
Ans:
Stay GOTO Stay
44. How many levels of stack in the '508A?
Ans: Two.
45. What is the longest Delay routine that can be created with the
'508A?
Ans: Possibly months, using all the files in a nested routine.
46. What is the shorted delay?
Ans: 1uS Use NOP.
47. How do you DECrement W?
Ans: There is no direct instruction to DECrement W. Put W into a temporary
file, DEC the file and copy the result into W - It only takes two
instructions:
MOVWF 1A,1
DECF 1A,0
48. What does DEFAULT mean?
Ans: The setting that applies when no instructions are given.
49. What does COMPLEMENT mean?
Ans: To change the bits in a file to the opposite state. E.g: to change
"0" to "1" and "1" to "0."
50 Are the following projects suitable for a '508A?
(a) one input line, two output lines, 350 instructions in the program,
driving red and green 3mm LEDs.
(b) three input lines, four output lines, 500 lines of code in the
program, driving a mini speaker via a buffer transistor.
(c) One input line, 8 output lines, 340 lines of code in the program,
driving buffer transistors.
Ans: (a) and (b) can be performed with a '508A. (c) can be handled with a PICF84.
Produced by Colin Mitchell 1 - 1 - 2001
|