Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатика
ИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханика
ОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторика
СоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансы
ХимияЧерчениеЭкологияЭкономикаЭлектроника

Special Function Registers

Читайте также:
  1. Changing Party Functions
  2. Definition of the phoneme and its functions.
  3. Ex 516. A. Read and translate the sentences. Define the function of Infinitives.
  4. Ex. 539. A. Read and translate the sentences. State the functions of Gerunds.
  5. Ex. 6. Use the required form of the infinitive in its function of part of a compound verbal predicate.
  6. Ex. 8. Translate. Mind the functions of the Infinitive and the Infinitive Constructions.
  7. Exercise 15. State the function of the infinitive and Infinitive Constructions. Translate into Russian.

SFRs are generally accessed using direct addressing. Some SFRs are both bit-and byte-addressable.

The 8051 internal registers are configured as part of the on-chip RAM. Hence each of these registers also has a memory address. There are 21 special function registers (SFRs) at the top of the internal RAM, from addresses 80H to FFH (see Figure 1.6b).

Most SFRs are accessed using direct addressing. Some SFRs are both bit-addressable and byte-addressable. For example, the instructions

SETB 0D3H SETB 0D4H

set bit 3 and 4 in the Program Status Word (PSW.3 and PSW.4), leaving the other bits unchanged. This will select Bank 3 for registers RO to R7 at address locations 18H to 1FH. Since the SETB instruction operates on bits (not bytes), only the addressed bit is affected.

Carry Flag (CY)

The carry flag (CY) has a dual purpose. It is used in the traditional way for arithmetic operations - it is set if there is a carry out of bit 7 during an addition operation or set if there is a borrow into bit 7 during a subtraction operation. For example, if accumulator A=F1H, then the instruction

ADD A,#15

leaves a value of 00H in the accumulator and sets the carry flag in PSW (PSW.7).

The carry flag is extensively used as a 1-bit register in Boolean operations on bit-valued data.

Auxiliary Carry Flag (AC)

When adding binary coded decimal (BCD) values, the auxiliary carry flag (AC) is set if a carry was generated out of bit 3 into bit 4 or if the result in the lower nibble is in the range OAH to OFH. For example, the following instruction sequence will result in the auxiliary carry flag being set.

MOV RO, #2 MOV A,#8 ADD A,R0

User Flag 0 (FO)

This is a general purpose flag bit available for user applications.

Register Bank Select Bits (RS1 and RSO)

The register bank select bits, RSO and RS1, determine the active register bank. They are cleared after reset (so Bank 0 is selected by default) and are changed by the application program as required.

For example, the following instruction sequence enables register Bank 3 then moves the contents of register RO (byte address 18H, see Figure 1.6a) to the accumulator:

SETB RSI alternatively use instruction

;SETB 0D4H SETB RSO /alternatively use instruction

;SETB 0D3H MOV A,R0

Overflow Flag (OV)

The overflow flag (OV) is set after an addition or subtraction operation if there is an arithmetic overflow (the result is out of range for the data size). When signed numbers are added or subtracted, a program can test this bit to determine if the result is in the proper range. For 8-bit signed numbers, the result should be in the range of +127 to -128).


Дата добавления: 2015-07-10; просмотров: 145 | Нарушение авторских прав


Читайте в этой же книге: LAST WEEK/MONTH/… à THE WEEK/MONTH/… BEFORE | YES/NO - Questions à IF/WHETHER | C8051F020 System Overview |
<== предыдущая страница | следующая страница ==>
General Purpose RAM| Serial Communication Registers

mybiblioteka.su - 2015-2024 год. (0.006 сек.)