Stack pointer is an 8 bit register, the direct address of SP is 81H and it is only byte addressable, which means you cant access individual bits of stack pointer. The content of the stack pointer points to the last stored location of system stack.
Usually after a system reset SP is initialized as 07H and data can be stored to stack from 08H onwards. This is usually a default case and programmer can alter values of SP to suit his needs.
Power management using a microcontroller is something you see every day in mobile phones. This is achieved by power management feature of the controller used inside that phone. As the name indicates, this register is used for efficient power management of micro controller. From the figure below you can observe that there are 2 modes for this register :- Idle mode and Power down mode.
Setting bit 0 will move the micro controller to Idle mode and Setting bit 1 will move the micro controller to Power down mode. This register reflects the status of the operation that is being carried out in the processor. PSW register is both bit and byte addressable. The individual bits are then accessed using D1, D2 … D7.
The various individual bits are explained below. At a time registers can take value from R0,R1…to R7. You may already know there are 32 such registers.
So how you access 32 registers with just 8 variables to address registers? Here comes the use of register banks. There are 4 register banks named 0,1,2 and 3. Each bank has 8 registers named from R0 to R7.
At a time only one register bank can be selected. These two bits are known as register bank select bits as they are used to select register banks. The picture will talk more about selecting register banks. This is a repeat of the last example. Write a program to get the status of the switch and send it to the LED. Notice in Examples and how the carry flag is used to get a bit of data from the port.
Reading input pins vs. In reading a port, some instructions read the status of port pins while others read the status of an internal port latch. Therefore, when reading ports there are two possibilities:. Read the status of the input pin. Read the internal latch of the output port.
We must make a distinction between these two categories of instructions since confusion between them is a major source of errors in programming, especially where external hardware is concerned.
We discuss these instructions briefly. However, readers must study and understand the material on this topic and on the internal working of ports that is given in Appendix C. Instructions for reading input ports. As stated earlier, to make any bit of any port an input port, we must write 1 logic high to that bit. After we configure the port bits as input, we can use only certain instructions in order to get the external data present at the pins into the CPU. Table shows the list of such instructions.
Reading latch for output port. Some instructions read the contents of an internal port latch instead of reading the status of an external pin.
Table provides a list of these instructions. The sequence of actions taken when such an instruction is executed is as follows. The instruction reads the internal latch of the port and brings that data into the CPU. They are addressed as 0 to in decimal or 00 to 7FH. See Figure and Example Example In order to avoid confusion regarding the addresses 00 — 7FH, the following two points must be noted. The bytes of RAM have the byte addresses of 00 — 7FH and can be accessed in byte size using various address ing modes such as direct and register-indi rect, as we have seen in this chapter and previ ous chapters.
These bytes are accessed using byte-type instruc tions. In order to access these bits of RAM locations and other bit-addressable space of individu ally, we can use only the single-bit instruc tions such as SETB. Figure Table provides a list Note: They are both bit- and byte-accessible. Notice that the single-bit instructions use only one addressing mode and that is direct addressing mode. In the first two sections of this chapter we showed various addressing modes of byte-addressable space of the , among them indirect addressing mode.
It must be noted that there is no indi rect addressing mode for single-bit instructions. Table Single-Bit Instructions.
We can access either the entire 8 bits or any single bit without altering the rest. See Figure While all of the SFR registers are byte-addressable some of them are also bit-addressable. O has the RAM address of 90H. The bit addresses for PO — P3 are shown in Table Bit memory map.
From Figures and and Table once again notice the following facts. The bit addresses 80 — 87H are assigned to the PO port.
0コメント