Embedded System
Embedded System
Example:
MOV A, #25h ; Load A with 25h (37 in decimal)
MOV R0, #13h ; Load R0 with 13h (19 in decimal)
ADD A, R0 ; A = A + R0 = 25h + 13h = 38h (56 in decimal)
If the result is greater than 255 (FFh), the carry flag (CY) will be set, and
the lower 8 bits will be stored in A.
2. Subtraction (SUBB)
The SUBB instruction performs subtraction by subtracting the source operand
and the borrow (CY) from the accumulator (A). If there is no borrow, CY is
considered zero.
Syntax:
SUBB A, source: Subtracts the source operand and the carry (borrow)
flag from the accumulator.
Operation:
The result is stored in the accumulator.
The source can be a register, an immediate value, or a memory location.
If the result requires borrowing, the carry flag (CY) is set.
Example:
MOV A, #30h ; Load A with 30h (48 in decimal)
MOV R2, #10h ; Load R2 with 10h (16 in decimal)
SUBB A, R2 ; A = A - R2 = 30h - 10h = 20h (32 in decimal)
2. OR(ORL)
The ORL instruction performs a bitwise logical OR between the accumulator
and the source operand. The result is stored in the accumulator.
Syntax: ORL A, source
Operation: A = A OR source
Examples:
MOV A, #0Fh ; Load A with 0Fh (00001111 in binary)
MOV R5, #F0h ; Load R5 with F0h (11110000 in binary)
ORL A, R5 ; A = 0Fh OR F0h = FFh (11111111 in binary)
Conclusion
The 8051 microcontroller’s arithmetic and logical operations form the
foundation for many embedded systems applications. These instructions allow
the microcontroller to perform fundamental tasks such as data manipulation,
decision-making, and controlling external hardware devices. The efficient
handling of arithmetic operations (like addition, subtraction, multiplication, and
division) and logical operations (such as AND, OR, XOR, and bit shifting) enables
the 8051 to manage a wide variety of real-time processes essential in fields
ranging from simple home automation to complex industrial systems.
The arithmetic instructions provide a mechanism for performing crucial
numerical calculations. For instance, addition and subtraction are
indispensable for applications like calculating sensor readings, adjusting timers,
or managing counters.