Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
access bank. We will discuss that issue in Section 6.5 when we discuss bank
switching.
The entire data RAM file register can be accessed using either direct or
register indirect addressing modes. The register indirect addressing mode will be
discussed in the next section. In direct addressing mode, the operand data is in a
RAM memory location whose address is known, and this address is given as a part
of the instruction. Contrast this with immediate addressing mode in which the
operand data itself is provided with the instruction. While the letter "L" in the
instruction means literal (immediate), the letter "F" in the instruction signifies the
address of the file register location. See the example below, and note the letter F
in the instructions.
MOVLW Ox56
MOVWF Ox40
MOVFF Ox40,0x50
;WREG = 56H (immediate addressing mode)
;copy WREG into fileReg RAM location 40H
;copy data from loc 40H to SOH.
The last two instructions use direct addressing mode. If we dissect the
opcode we see that the addresses are embedded in the instruction, as shown in
Figure 6-1 a.
SECTION 6.2: REGISTER INDIRECT ADDRESSING MODE
We can use register direct or register indirect addressing modes to access
data stored in the general purpose RAM section of the file register. In the last section we showed how to use direct addressing mode, which is also called register
direct. The register indirect addressing mode is a very important addressing mode
in the PIC 18. This topic will be discussed thoroughly in this section.
Register indirect addressing mode
MOVWF Ox40
MOVWF Ox41
MOVWF Ox42
MOVWF Ox43
MOVWF Ox44
(b)
MOVLW SSH
LFSR O,Ox40
MOVWF INDFO
INCF FSROL,F
MOVWF INDFO
INCF FSROL,F
MOVWF INDFO
INCF FSROL,F
MOVWF INDFO
INCF FSROL,F
MOVWF INDFO
(c)
COUNT EQU OxlO
MOVLW oxs
MOVWF COUNT
LFSR O,Ox40
MOVLW Ox55
Bl MOVWF INDFO
INCF FSROL,F
DECF COUNT,F
BNZ Bl
;load WREG with value SSH
;copy WREG to RAM location 40H
;copy WREG to RAM location 41H
;copy WREG to RAM location 42H
;copy WREG to RAM location 43H
;copy WREG to RAM location 44H
;load with value SSH
;load the pointer. FSRO = 40H
;copy w to RAM loc FSRO points
;increment pointer. Now FSRO =
;copy W to RAM loc FSRO points
;increment pointer. Now FSRO =
;copy W to RAM loc FSRO points
;increment pointer. Now FSRO =
;copy W to RAM loc FSRO points
;increment pointer. Now FSRO =
;copy W to RAM loc FSRO points
;location lOH for counter
;WREG = 5
;load the counter, Count = 5
to
41H
to
42H
to
43H
to
44H
to
;load pointer. FSRO = 40H, RAM address
;WREG = 55h value to be copied
;copy WREG to RAM loc SFRO points to
;increment FSRO pointer
;decrement the counter
;loop until counter = zero