The 8051 Microcontroller and Embedded Systems: 8051 Assembly Language Programming
The 8051 Microcontroller and Embedded Systems: 8051 Assembly Language Programming
The 8051 Microcontroller and Embedded Systems: 8051 Assembly Language Programming
Embedded Systems
CHAPTER 2
8051 ASSEMBLY
LANGUAGE
PROGRAMMING
1
OBJECTIVES
List the registers of the 8051 microcontroller
Manipulate data using the registers and MOV instructions
Code simple 8051 Assembly language instructions
Assemble and run an 8051 program
Describe the sequence of events that occur upon 8051 power-up
Examine programs in ROM code of the 8051
Explain the ROM memory map of the 8051
Detail the execution of 8051 Assembly language instructions
Describe 8051 data types
Explain the purpose of the PSW (program status word) register
Discuss RAM memory space allocation in the 8051
Diagram the use of the stack in the 8051
2
Current Tech
3
Current Tech
4
SECTION 2.1: INSIDE THE 8051
Registers
Figure 2–1a
Some 8-bit Registers of the 8051
5
SECTION 2.1: INSIDE THE 8051
Registers
External memory pointer
6
SECTION 2.1: INSIDE THE 8051
most widely used registers are
– A, B
– R0, R1, R2, R3, R4, R5, R6, R7
– DPTR and PC
all registers are 8-bits, except DPTR and the program counter
which are 16 bit
register A is used for all arithmetic and logic instructions
register B is also used for some arithmetic instructions
simple instructions MOV and ADD
7
SECTION 2.1: INSIDE THE 8051
MOV instruction
– MOV destination, source ;copy source to destination
8
SECTION 2.1: INSIDE THE 8051
ADD instruction
– ADD A, source ;ADD the source operand
;to the accumulator
9
SECTION 2.2: INTRODUCTION TO 8051
ASSEMBLY PROGRAMMING
Structure of Assembly language
10
SECTION 2.3: ASSEMBLING AND
RUNNING AN 8051 PROGRAM
11
SECTION 2.3: ASSEMBLING AND
RUNNING AN 8051 PROGRAM
13
SECTION 2.3: ASSEMBLING AND
RUNNING AN 8051 PROGRAM
Ist file
– lst file is useful to the programmer because it lists all the
opcodes and addresses as well as errors that the assembler
detected
– uVision assumes that the list file is not wanted unless you
indicate that you want to produce it
– file can be accessed by an editor such as Note Pad and
displayed on the monitor or sent to the printer to produce a
hard copy
– programmer uses the list file to find syntax errors
– only after fixing all the errors indicated in the lst file that the
obj file is ready to be input to the linker program
14
SECTION 2.4: THE PROGRAM COUNTER
AND ROM SPACE IN THE 8051
15
SECTION 2.4: THE PROGRAM COUNTER
AND ROM SPACE IN THE 8051
16
SECTION 2.4: THE PROGRAM COUNTER
AND ROM SPACE IN THE 8051
17
SECTION 2.4: THE PROGRAM COUNTER
AND ROM SPACE IN THE 8051
18
SECTION 2.4: THE PROGRAM COUNTER
AND ROM SPACE IN THE 8051
20
SECTION 2.5: 8051 DATA TYPES AND
DIRECTIVES
21
SECTION 2.5: 8051 DATA TYPES AND
DIRECTIVES
22
SECTION 2.5: 8051 DATA TYPES AND
DIRECTIVES
23
SECTION 2.5: 8051 DATA TYPES AND
DIRECTIVES
24
SECTION 2.6: 8051 FLAG BITS AND
THE PSW REGISTER
Figure 2–5
RAM Allocation in the 8051
27
SECTION 2.7: 8051 REGISTER BANKS
AND STACK
29
SECTION 2.7: 8051 REGISTER BANKS
AND STACK
30
SECTION 2.7: 8051 REGISTER BANKS
AND STACK
31
SECTION 2.7: 8051 REGISTER BANKS
AND STACK
32
SECTION 2.7: 8051 REGISTER BANKS
AND STACK
33
SECTION 2.7: 8051 REGISTER BANKS
AND STACK
Figure 2–7
Register’s Screen from
ProView 32 Simulator
34
SECTION 2.7: 8051 REGISTER BANKS
AND STACK