The 8051 Microcontroller - Chapter 7: Assembly Language Programming - Lê Chí Thông

Chap 7 Assembly Language
Programming
• Assembler
– Change mnemonic code into machine code
– Label can be used to represent symbolic address/data
– Directives : like pre-processing operator (#) in C
language.
• Linkage Editor
– Link objective code into executable file (*.obj → *.exe) 
pdf 12 trang thamphan 28/12/2022 2560
Bạn đang xem tài liệu "The 8051 Microcontroller - Chapter 7: Assembly Language Programming - Lê Chí Thông", để tải tài liệu gốc về máy hãy click vào nút Download ở trên.

File đính kèm:

  • pdfthe_8051_microcontroller_chapter_7_assembly_language_program.pdf

Nội dung text: The 8051 Microcontroller - Chapter 7: Assembly Language Programming - Lê Chí Thông

  1. 17-May-12 Chapter 7 Assembly Language Programming Chap 7 Assembly Language Programming • Assembler – Change mnemonic code into machine code – Label can be used to represent symbolic address/data – Directives : like pre-processing operator (#) in C language. • Linkage Editor – Link objective code into executable file (*.obj → *.exe) 1
  2. 17-May-12 FIGURE 7–3 Use of the generic JMP mnemonic Symbol Table : Symbol →Address/Data • Assembly program – Machine instructions MOV A, #0 – Assembler Directives • Like Variable declaration in high-level language – Assembler controls • Conditional compiling – Comments After ; to EOL . ; this is a comment 3
  3. 17-May-12 • Precedence of constant () HIGH LOW / MOD SHR SHL + - EQ NE LT LE GT GE = >= NOT AND OR XOR • Directives (1) Assembler state control • ORG – define the location of the code • END – directive to tell assembler the end of source file • USING – set the register bank Examples : ORG 100H ORG $+100H USING 3 PUSH AR7 ; now AR7 means $23H . END 5
  4. 17-May-12 (B) EQU like the named constant define in C (#define) Example: BASE EQU 10 other constants : #10H, $(current location) (C) Storage initialization/reservation – DS (define space, like unintialized array) – DBIT (define bit data) – DB (define byte data) – DW (define word data, low-byte in lower address) Example 1: DSEG AT 30H LENGTH: EQU 40 BUFFER: DS LENGTH PROG SEGMENT CODE MOV R7, #LENGTH MOV R0, #BUFFER LOOP: MOV @R0, #0 BJNZ R7, LOOP . END 7
  5. 17-May-12 FIGURE 7–5 Defining and initiating absolute and relocatable segments RSEG directive – reallocatable segment FIGURE 7–6 Assembler controls supported by ASM51 9
  6. 17-May-12 FIGURE 7–8a Annotated example: linking relocatable segments and modules. (a) ECHO.LST. (b) IO.LST. (c) EXAMPLE.M51. Address-relative content Need to fix in linkage - reallocatable FIGURE 7–8a Annotated example: linking relocatable segments and modules. (a) ECHO.LST. (b) IO.LST. (c) EXAMPLE.M51. Symbol Table 11