Wednesday, March 23, 2016

8051 Increment Byte and DPTR

Increment Byte

INC increments the indicated variable by 1. An original value of 0FFH overflows to 00H. No flags are affected. Three addressing modes are allowed: register, direct, or register-indirect.

Note: When this instruction is used to modify an output port, the value used as the original port data will be read from the output data latch, not the input pins.

INC A
Encoding: 0 0 0 0 0 1 0 0

INC Rn
Encoding: 0 0 0 0 1 n n n

INC direct address
Encoding: 0 0 0 0 0 1 0 1 direct address

INC @Ri
Encoding 0 0 0 0 0 1 1 i

ORG 0H
START :
MOV A, #10
INC A ; A = 10 + 1 = 11
MOV R0, A
INC R0 ; R0 = 11 + 1 = 12
MOV 34h, R0
INC 34h ; ram location 34h = 12 + 1 = 13
MOV R0, #34h
INC @R0 ; ram location 34h = 13 + 1 = 14
END; end of asm source file


Increment Data Pointer
INC DPTR increments the 16-bit data pointer by 1. A 16-bit increment (modulo 216) is performed, and an overflow of the low-order byte of the data pointer (DPL) from 0FFH to 00H increments the high-order byte (DPH). No flags are affected.

This is the only 16-bit register which can be incremented.

Encoding: 1 0 1 0 0 0 1 1

Registers DPH and DPL contain 12H and 0FEH, respectively. The following instruction sequence,

INC DPTR
INC DPTR
INC DPTR

changes DPH and DPL to 13H and 01H.



Related topics:
8051 Decrement Byte   |   8051 Logical AND for Byte and Bit   |   8051 Logical OR for Byte and Bit   |   8051 Logical XOR for Byte   |   8051 Addition

List of topics: 8051

No comments:

Post a Comment