OVERVIEW OF
8051 FAMILY
Various 8051
Microcontrollers
􀂉 8751 microcontroller
􀂾 UV-EPROM
􀂃 PROM burner
􀂃 UV-EPROM eraser takes 20 min to erase
􀂉 AT89C51 from Atmel Corporation
􀂾 Flash (erase before write)
􀂃 ROM burner that supports flash
􀂃 A separate eraser is not needed
􀂉 DS89C4x0 from Dallas Semiconductor,
now part of Maxim Corp.
􀂾 Flash
􀂃 Comes with on-chip loader, loading program to
on-chip flash via PC COM port

OVERVIEW OF
8051 FAMILY
Various 8051
Microcontrollers
(cont’)
􀂉 DS5000 from Dallas Semiconductor
􀂾 NV-RAM (changed one byte at a time),
RTC (real-time clock)
􀂃 Also comes with on-chip loader
􀂉 OTP (one-time-programmable) version
of 8051
􀂉 8051 family from Philips
􀂾 ADC, DAC, extended I/O, and both OTP
and flash
Home Automation, Networking, and Entertainment Lab

Chung-Ping Young
楊中平
8051 ASSEMBLY
LANGUAGE
PROGRAMMING
The 8051 Microcontroller and Embedded
Systems: Using Assembly and C
Mazidi, Mazidi and McKinlay
Department of Computer Science and Information Engineering
National Cheng Kung University, TAIWAN 2 HANEL
INSIDE THE
8051
Registers
􀂉 Register are used to store information
temporarily, while the information
could be
􀂾 a byte of data to be processed, or
􀂾 an address pointing to the data to be
fetched
􀂉 The vast majority of 8051 register are
8-bit registers
􀂾 There is only one data type, 8 bits

INSIDE THE
8051
Registers
(cont’)
􀂉 The 8 bits of a register are shown from
MSB D7 to the LSB D0
􀂾 With an 8-bit data type, any data larger
than 8 bits must be broken into 8-bit
chunks before it is processed
D7 D6 D5 D4 D3 D2 D1 D0
8 bit Registers
most
significant bit
least
significant bit

INSIDE THE
8051
Registers
(cont’)
􀂉 The most widely used registers
􀂾 A (Accumulator)
􀂃 For all arithmetic and logic instructions
􀂾 B, R0, R1, R2, R3, R4, R5, R6, R7
􀂾 DPTR (data pointer), and PC (program
counter)
R6
R5
R4
R3
R2
R1
R0
B
A
R7
DPTR
PC PC (Program counter)
DPH DPL

INSIDE THE
8051
MOV
Instruction
MOV destination, source ;copy source to dest.
􀂾 The instruction tells the CPU to move (in reality,
COPY) the source operand to the destination
operand
MOV A,#55H ;load value 55H into reg. A
MOV R0,A ;copy contents of A into R0
;(now A=R0=55H)
MOV R1,A ;copy contents of A into R1
;(now A=R0=R1=55H)
MOV R2,A ;copy contents of A into R2
;(now A=R0=R1=R2=55H)
MOV R3,#95H ;load value 95H into R3
;(now R3=95H)
MOV A,R3 ;copy contents of R3 into A
;now A=R3=95H
“#” signifies that it is a value

INSIDE THE
8051
MOV
Instruction
(cont’)
􀂉 Notes on programming
􀂾 Value (proceeded with #) can be loaded
directly to registers A, B, or R0 – R7
􀂃 MOV A, #23H
􀂃 MOV R5, #0F9H
􀂾 If values 0 to F moved into an 8-bit
register, the rest of the bits are assumed
all zeros
􀂃 “MOV A, #5”, the result will be A=05; i.e., A
= 00000101 in binary
􀂾 Moving a value that is too large into a
register will cause an error
􀂃 MOV A, #7F2H ; ILLEGAL: 7F2H>8 bits (FFH)
If it’s not preceded with #,
it means to load from a
Add a 0 to indicate that memory location
F is a hex number and
not a letter

INSIDE THE
8051
ADD
Instruction
ADD A, source ;ADD the source operand
;to the accumulator
􀂾 The ADD instruction tells the CPU to add the source
byte to register A and put the result in register A
􀂾 Source operand can be either a register or
immediate data, but the destination must always
be register A
􀂃 “ADD R4, A” and “ADD R2, #12H” are invalid
since A must be the destination of any arithmetic
operation
MOV A, #25H ;load 25H into A
MOV R2, #34H ;load 34H into R2
ADD A, R2 ;add R2 to Accumulator
;(A = A + R2)
MOV A, #25H ;load one operand
;into A (A=25H)
ADD A, #34H ;add the second
;operand 34H to A
There are always
many ways to write
the same program,
depending on the
registers use

Post a Comment

0 Comments

Close Menu