EasyManuals Logo

Atmel 8051 User Manual

Atmel 8051
113 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #8 background imageLoading...
Page #8 background image
The 8051 Instruction Set
1-7 Atmel 8051 Microcontrollers Hardware Manual
4316B–8051–02/04
Note that Boolean operations can be performed on any byte in the internal Data Memory
space without going through the Accumulator. The XRL <byte>, # data instruction, for
example, offers a quick and easy way to invert port bits, as in
XRL P1, #OFFH
If the operation is in response to an interrupt, not using the Accumulator saves the time
and effort to stack it in the service routine.
The Rotate instructions (RL A, RLC A, etc.) shift the Accumulator 1 bit to the left or right.
For a left rotation, the MSB rolls into the LSB position. For a right rotation, the LSB rolls
into the MSB position.
The SWAP A instruction interchanges the high and low nibbles within the Accumulator.
this is a useful operation in BCD manipulations. For example, if the Accumulator con-
tains a binary number which is known to be less than 100, it can be quickly converted to
BCD by the following code:
MOV B, #10
DIV AB
SWAP A
ADD A,B
Dividing the number by 10 leaves the tens digit in the low nibble of the Accumulator, and
the ones digit in the B register. The SWAP and ADD instructions move the tens digit to
the high nibble of the Accumulator, and the ones digit to the low nibble.
1.5 Data Transfers
1.5.1 Internal RAM
Table 1-4 shows the menu of instructions that are available for moving data around
within the internal memory spaces, and the addressing modes that can be used with
each one. With a 12 MHz clock and X1 mode, all of these instructions execute in either
1 or 2 µs.
The MOV <dest>, <src> instruction allows data to be transferred between any two inter-
nal RAM or SFR locations without going through the Accumulator. Remember the Upper
128 bytes of data RAM can be accessed only by indirect, and SFR space only by direct
addressing.
Note that in all 8051 devices, the stack resides in on-chip RAM, and grows upwards.
The PUSH instruction first increments the Stack Pointer (SP), then copies the byte into
the stack. PUSH and POP use only direct addressing to identify the byte being saved or
restored, but the stack itself is accessed by indirect addressing using the SP register.

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Atmel 8051 and is the answer not in the manual?

Atmel 8051 Specifications

General IconGeneral
BrandAtmel
Model8051
CategoryMicrocontrollers
LanguageEnglish

Related product manuals