
Site Search
SECTION VI-9: Placing Code in Program ROM
Lets examine the action of the Program Counter PC as each instruction is fetched and executed. First, we examine once more the list file of the sample program and show how the code is placed in the ROM of the PIC chip. The opcode amd operand for each instruction are listed on the left side of the list file.
After the program is burned into ROM of a PIC family member such as PIC18F452 or PIC18F458, the opcode and operand are placed in ROM memory locations starting at 0000 as shown in the list file below:
List File Sample Program |
---|
![]() |
The list above shows that address 0000 contains 0E, which is the opcode for moving a value into WREG, and address 0001 contains the operand, in this case 25H, to be moved to WREG. The instruction "MOVLW 25H" has a machine code of "0E25", where 0E is the opcode and 25 is the operand. Similarly, the machine code "0F34" is located in memory locations 0002 and 0003 and represents the opcode and operand for the instruction "ADDLW 34H". Machine code "0F11" is located in memory location 0004 and 0005 and represents the opcode and operand for the instruction "ADDLW 11". The memory location 0006 has the opcode of 0F, which is the opcode for the instruction "MOVLW" and memory location 0007, which is the operand for the decimal 18 in the ADDLW D'18' instruction. The opcode for instruction "ADDLW 1CH" is located at address 0008 and the operand 1CH at address 0009. The memory locations 000A and 000B have the opcode and operand for the ADDLW B'00000110' instruction. The opcode for instruction "MOVWF SUM" is located at address 0000C and its address of 10H at address 0000D. The opcode for "GOTO HERE" and its target address are located in locations 0000E, F, 10 and 11. All the instructions in this program are 2 byte instructions, the GOTO instruction is a 4 byte instruction.
ROM ADDRESS | MACHINE LANGUAGE | ASSEMBLY LANGUAGE |
---|---|---|
00000 | 0E25 | MOVLW 25H |
00002 | 0F34 | ADDLW 34 |
00004 | 0F11 | ADDLW 11H |
00006 | 0F12 | ADDLW D'18' |
00008 | 0F1C | ADDLW 1CH |
0000A | 0F06 | ADDLW B '00000110' |
0000C | 6E10 | MOVWF SUM |
0000E | EF07 F000 | HERE GOTO HERE |