8051 Assembly Language Programming
8051 Assembly Language Programming
1
introduction
mnemonics 8086
(lower level)
machine language
binary
(lower level)
2
introduction (cont’d)
assembly language program:
source code, symbolic code, not executable
machine language program:
binary coded instructions, object code, executable
assembler:
translates assembly to machine language
linker: when the object code is not “absolute”
(“relocatable”) linking is required to combine
relocatable modules
segment : unit of code or data memory
module : contains one or more segments (also
partial). An object code has one more more modules
program: merged single module executable in binary
form
3
assembler operation
ASM51 : cross-assembler
source file
object file
listing file
4
assembler operation (cont’d)
pass one
(symbol table)
pass two
(object & listing)
5
assembler operation (cont’d)
listing
source object
6
assembly language program format
• machine instructions (e.g. ADD, MOV, DIV)
• assembler directives (e.g. ORG, EQU, DB)
• assembler controls (assembler controls)
• comments ( ; comment from here)
7
assembly language program format
assembler controls
8
assembly language program format
• machine instructions (e.g. ADD, MOV, DIV)
• assembler directives (e.g. ORG, EQU, DB)
• assembler controls (assembler controls)
• comments ( ; comment from here)
9
assembly language program format
• special assembler symbols
used for register specific addressing modes
A, R0 – R7, DPTR, PC, C, AB, $
JNB TI, $
• indirect address
ADD A, @R0
• immediate data
MOV A #0FEH
• data address
MOV A, SBUF ; MOV A, 99H (same)
• bit address
JNB TI, $ ; TI is a predefined symbol
• code address
SJMP THERE
10
assembly language program format
forward reference
11
assemble time expression evaluation
12
assemble time expression evaluation
13
assemble time expression evaluation
14
assemble time expression evaluation
15
assemble time expression evaluation
16
assemble time expression evaluation
17
assemble time expression evaluation
18
assemble time expression evaluation
19
assemble time expression evaluation
20
assembler directives
non-executable mnemonics
21
assembler state control directives
22
assembler state control directives
23
assembler symbol definition directives
24
assembler symbol definition directives
25
assembler symbol definition directives
26
storage initialization / reservation directives
27
storage initialization / reservation directives
28
storage initialization / reservation directives
29
storage initialization / reservation directives
30
storage initialization / reservation directives
31
program linkage directives
32
segment selection directives
33
segment selection directives
34
assembler controls
35
linker operation
modular programming
Intel’s RL51
(linker/locator)
36
macros
37
macros
38
macros
39
macros
40
macros
41
macros
42
macros
43
macros
44
macros
45
references
46