Answer Sheet # 2 Microcontroller and Applications
Answer Sheet # 2 Microcontroller and Applications
Sheet # 2
Chapter # 2: PIC ARCHITECTURE & ASSEMBLY LANGUAGE ROGRAMMING
3. The largest number that can be loaded into WREG is FF in hex and decimal equivalent 255.
4. To load WREG with the value 65H, the pound sign is -------- (not necessary, optional, necessary)
in the instruction "MOVLW 6 5 H".
5. The largest number that K can take for the instruction “ADDWL K” is FF in hex.
7. If we add the SFR and general-purpose RAM sizes together we should get the total space for the -
File registers
10. The file register space in PIC18 is divided into 256-byte banks.
11. The file register space in PIC18 can be a maximum of 4096 bytes.
12. “ADDWF PORTB, W” puts the result in WREG, The flag register in the PIC is called the
STATUS Register
13. The “ADDWF fileReg, D” instruction to place the result in WREG, the D bit must be 0.
14. The “ADDWF fileReg, D” instruction to place the result in fileReg, the D bit must be 1.
15. RISC processors normally have a ------------ (large, small) number of general-purpose registers.
16. Pseudo-instructions are also called Directives.
17. The access bank has -256 bytes space.
18. The maximum number of banks that the PIC18 can have 256 and the maximum number of bytes
that the PIC18 can have for the File register 16 banks.
1
Horus University in Egypt Microcontroller and
(HUE) Faculty of Applications
Engineering Mechatronics (ECE 442)
Department
20. The size of the flag register in the PIC is 8 and 3 are unused.
21. The largest hex value that can be moved into a location in the file register FF, is the decimal
equivalent value 255.
22. Which of the following instructions produces opcode? -------- List all that do.
(a) MOVLW 25H (b) ADDLW 12 (c) ORG 2000H (d) GOTO HERE
22. The file with the “.hex “ extension is downloaded into PIC ROM.
Q:3 True or False
1. Assembler directives are not used by the CPU itself. They are simply a guide to the assembler. True
4. The larger the file register, the more difficult it is to manage. True
6. Instructions such as “ADD WREG, ROM memory” do not exist in RISC microcontrollers such as
the PIC18. True
7. While CISC instructions are of variable sizes, RISC instructions are all the same size. True
8. Harvard architecture uses the same address and data buses to fetch both code and data. False
7. All members of PIC18 family have the same size file register. False
9. The SFRs are part of the file register memory space. True
5. The general-purpose RAM is not part of the file register memory space. False
10. The more file register space that is assigned to the SFRs, the less is available for the GP RAM. True
11. The access bank is 256 bytes divided evenly between GPRs and SFRs. True
14. We can use MOVFF to copy data from any location to any location in the file register. False
16. Every source file must have ORG and END directives. True
17. The ORG and END directives appear in the ".1st" file. False
18. The linker produces the file with the extension "asm". False
19. The linker produces the file with the extension "hex". True
20. The “ADDWF fileReg, D” instruction involves a fileReg and WREG. True
Q3: Answer:
3
Horus University in Egypt Microcontroller and
(HUE) Faculty of Applications
Engineering Mechatronics (ECE 442)
Department
4. Write instructions to add the values l6H and CDH, Place the result in the WREG register.
MOVLW 0x16
ADDLW 0XCD
5. Show a simple code to load value l5H into location 7, and add it to WREG five times and
place the result in WREG as the values are added. WREG should be zero before the addition
starts.
MOVLW 0x15
MOVWF LOCATION_7
MOVLW 00
ADDWF LOCATION_7, W
ADDWF LOCATION_7, W
ADDWF LOCATION_7, W
ADDWF LOCATION_7, W
ADDWF LOCATION_7, W
6. Show a simple code to load values 30H and 97H into locations 5 and 6 respectively.
MOVLW 0X30
MOVWF LOCATION_5
MOVLW 0X97
MOVWF LOCATION_6
4
Horus University in Egypt Microcontroller and
(HUE) Faculty of Applications
Engineering Mechatronics (ECE 442)
Department
8. Compare between RISC and CISC? And each one stand for?
RISC CISC
Take shorter time to design and debug Take longer time to design and debug
5
Horus University in Egypt Microcontroller and
(HUE) Faculty of Applications
Engineering Mechatronics (ECE 442)
Department
9. Find the address of the last location of on-chip program ROM for each of the following:
(a) PIC with 48 KB
48 * 1024 = 49152 ( in decimal convert to hexadecimal ) = C000
To find the last address C000 – 0001 = BFFF
ROM address rang 0000 – BFFF.
6
Horus University in Egypt Microcontroller and
(HUE) Faculty of Applications
Engineering Mechatronics (ECE 442)
Department
10.Find the on-chip program ROM size in K for the PIC18 with the followingaddress ranges:
(a) 00000 - 4FFFF (b) 00000 - 3FFFF
(c) 00000 - 5FFFF (d) 00000 - 7FFFF
(e) 00000 - BFFFF (f) 00000 - FFFFF
(g) 00000 - l7FFFF (h) 00000 - 1FFFFF