Download M16C Assembler Manual

Transcript
CPU Programming Model
2
2.5 Addressing Modes
Column
Relationship between Number of Bits and Address
To get an address from a number of bits, it is necessary to convert the number of bits into a
"number of bytes and number of bits" first. For this conversion, the number of bits is divided by 8,
because one byte is eight bits. This is shown in Figure 2.5.31. The conversion is accomplished by
shifting the bit train right by three bits, so that 1234H bits are changed to "246H bytes + 4 bits" as
shown below.
Figures 2.5.32 through 2.5.34 show examples of main addressing calculations.
1
2
3
4
0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 [1234H]
Bits
Shifted right by
three bits
0
2
4
6
4
0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 [ 246H + 4 bits ]
↑
Bit
position
Bytes
Figure 2.5.31 Conversion from a number of bits to address
(1) Address register indirect
Example: BCLR [A0]
2
3
4
1
5
A0 1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 1 [A0 = 91A5H]
↑
Bit
position
Address
Address: 1234H
Bit position: Bit 5 is cleared.
Figure 2.5.32 Calculation of bit position in address register indirect addressing
(2) Address register relative
Example: BCLR 5[A0]
A0 is a number of bits; dsp is an address. Therefore, the bit train is
shifted right by three bits to obtain a number of bytes or an address.
A0
2
3
4
1
5
1 0 0 1 0 0 0 1 1 0 1 0 0 1 0 1 [ A0 = 91A5H ]
+
0
5
dsp8 0 0 0 0 0 1 0 1 [dsp = 05H]
=
2
3
9
1
5
A0 1 0 0 1 0 0 0 1 1 1 0 0 1 1 0 1 [ A0 = 91CDH]
↑
Address
Bit
position
Address: 1239H
Bit position: Bit 5 is cleared.
Figure 2.5.33 Calculation of bit position in address register relative addressing
44