English
Language : 

EF6805U3 Datasheet, PDF (19/31 Pages) STMicroelectronics – 8-BIT MICROCOMPUTER UNIT
SOFTWARE
BIT MANIPULATION
The EF6805U3 MCU has the ability to set or clear
any single random access memory or input/output
bit (except the data direction register, see Caution
below), with a single instruction (BSET, BCLR). Any
bit in page zero including ROM, except the DDRs,
can be tested, using the BRSET and BRCLR ins-
tructions, and the program branches as a result of
its state. The carry bit equals the value of the bit ref-
erenced by BRSET or BRCLR. A rotate instruction
may then be used to accumulate serial input data in
a RAM location or register. The capability to work
with any bit in RAM, ROM, or I/O allows the user to
have individual flags in RAM or to handle I/O bits as
control lines.
The coding example in figure 21 illustrates the use-
fulness of the bit manipulation and test instructions.
Figure 21 : Bit Manipulation Example.
EF6805U3
Assume that the MCU is to communicate with an ex-
ternal serial device.
The external device has a data ready signal, a data
output line, and a clock line to clock data one bit at
a time. LSB first, out of the device. The MCU waits
until the data is ready, clocks the external device,
picks up the data in the carry flag (C bit), clears the
clock line, and finally accumulates the data bit in a
RAM location.
Caution
The corresponding DDRs for ports A, B, and C
are write-only registers (registers at $004, $005,
and $006). A read operation on these registers
is undefined. Since BSET and BCLR are read-
modify-write functions, they cannot be used to
set or clear a DDR bit (all ”unaffected” bits would
be set). It is recommended that all DDR bits in a
port be written using a single-store instruction.
ADDRESSING MODES
The EF6805P2 MCU has 10 addressing modes
which are explained briefly in the following para-
graphs. For additional details and graphical illustra-
tions, refer to the 6805 Family User’s Manual.
The term ”effective address” (EA) is used in descri-
bing the address modes. EA is defined as the ad-
dress from which the argument for an instruction is
fetched or stored.
IMMEDIATE - In the immediate addressing mode,
the operand is contained in the byte immediately fol-
lowing the opcode. The immediate addressing
mode is used to access constants which do not
change during program execution (e.g;, a constant
used to initialize a loop counter).
DIRECT - In the direct addressing mode, the effec-
tive address of the argument is contained in a single
byte following the opcode byte. Direct addresing al-
lows the user to directly address the lowest 256
bytes in memory with a single 2-byte instruction.
This includes the on-chip RAM and I/O registers and
128 bytes of ROM. Direct addressing is an effective
use of both memory and time.
EXTENDED - In the extended addressing mode, the
effective address of the argument is contained in the
two bytes following the opcode. Instructions using
extended addressing are capable of referencing ar-
guments anywhere in memory with a single 3-byte
instruction. When using the Motorola assembler, the
programmer need not specify whether an instruction
uses direct or extended addressing. The assembler
automatically selects the shortest for of the instruc-
tion.
RELATIVE - The relative addressing mode is only
used in branch instructions. In relative addressing,
the contents of the 8-bit signed byte following the op-
code (the offset) is added to the PC if and only if the
19/31