Chapter 6 8051 Programming
Chapter 6 8051 Programming
PROPRIETARY MATERIAL. © 2009 The McGraw-Hill Companies, Inc. All rights reserved. No part of this PowerPoint slide may be displayed, reproduced or distributed
in any form or by any means, without the prior written permission of the publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill
for their individual course preparation. If you are a student using this PowerPoint slide, you are using it without permission.
1
@ McGraw-Hill Education
3
@ McGraw-Hill Education
A Memory
Address
B
R0
07H 255 (FFH)
R7
4
@ McGraw-Hill Education
E.g. MOV R0, #55H ; Load R0 with 55H, The address of mem loc
MOV A,@R0 ; Load Accumulator with the contents of the memory location pointed by R0
A Memory
Address
B
R0 55H
55H 255 (FFH)
R7
5
@ McGraw-Hill Education
A Memory
Address
B
DPH 00H
DPL 55H 0055H 255 (FFH)
6
@ McGraw-Hill Education
7
@ McGraw-Hill Education
8
@ McGraw-Hill Education
11
@ McGraw-Hill Education
; Method-2
; Using Data Pointer (DPTR) Register
MOV DPTR, #55H ; Let 55H be the external data memory address
MOVX A,@DPTR ; Reads the content of 55H to Accumulator
MOV A, #00H ; Clear Accumulator
MOVX @DPTR, A ; Writes 0 to external memory 55H
17
@ McGraw-Hill Education
MOV 00H,#80H ; Load Data memory location 00H (R0) with 80H
MOV A,#0FFH ; Load Accumulator with FFH
MOV DPTR,#00FFH ; Load DPTR with 00FFH
INC 00H ; Increment the contents of Data memory-
; location 00H. It becomes 81H
INC A ; Increment the content of Accumulator. It-
; becomes 00H
INC DPTR ; Increment the content of DPTR Register. It-
; becomes 0100H
18
@ McGraw-Hill Education
19
@ McGraw-Hill Education
MOV 00H,#80H ; Load Data memory location 00H (R0) with 80H
MOV A,#0FFH ; Load Accumulator with FFH
DEC 00H ; Decrement the contents of Data memory-
; location 00H. It becomes 7FH
DEC A ; Decrement the content of Accumulator. It-
; becomes FEH
20
@ McGraw-Hill Education
Bitwise logical OR the content of Accumulator with the content of <loc> and
ORL <loc>,A <loc> = A|<loc> stores the result in memory location <loc>. <loc> can be any SFR or an internal
data memory
Bitwise logical OR the content of <loc> with an immediate constant and stores
ORL <loc>, <loc> = <loc>|const the result in memory location <loc>. <loc> can be any SFR or an internal data
#const memory
Bitwise logical AND the content of Accumulator with the content of <loc> and
ANL A,<loc> A=A&<loc> stores the result in Accumulator. <loc> can be B, R0,R1, …R7, or any SFR, an
internal data memory or an immediate constant or an internal data memory
pointed indirectly by indirect addressing register R0 or R1 and @
Bitwise logical AND the content of Accumulator with the content of <loc> and
ANL <loc>,A <loc> = A&<loc> stores the result in memory location <loc>. <loc> can be any SFR or an internal
data memory
Bitwise logical AND the content of <loc> with an immediate constant and
ANL <loc>, <loc> = <loc>&const stores the result in memory location <loc>. <loc> can be any SFR or an internal
#const data memory
Bitwise logical XOR the content of Accumulator with the content of <loc> and
XRL A,<loc> A = A^<loc> stores the result in Accumulator. <loc> can be B, R0,R1, …R7, or any SFR, an
internal data memory or an immediate constant or an internal data memory
pointed indirectly by indirect addressing register R0 or R1 and @ 21
@ McGraw-Hill Education
23
@ McGraw-Hill Education
24
@ McGraw-Hill Education
26
@ McGraw-Hill Education