1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

VI XỬ LÝ 8051 chap7 assembly programming

12 0 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Chapter 7 Assembly Language Programming
Trường học University of Science and Technology
Chuyên ngành Assembly Language Programming
Thể loại Bài tập lớn
Năm xuất bản 2012
Thành phố Hanoi
Định dạng
Số trang 12
Dung lượng 1,68 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

FIGURE 7–3 Use of the generic JMP mnemonic Symbol Table : Symbol →Address/Data • Assembly program – Machine instructions – Assembler Directives • Like Variable declaration in high-level

Trang 1

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)

Trang 2

FIGURE 7–2 Pseudo code sketch of a two-pass operator

PASS 1 – Establish symbol table

- Computing address/symbol

PASS 2 – Convert mnemonic code into machine code

Trang 3

FIGURE 7–3 Use of the generic JMP mnemonic

Symbol Table :

Symbol →Address/Data

• Assembly program

– Machine instructions

– Assembler Directives

• Like Variable declaration in high-level language

– Assembler controls

• Conditional compiling

– Comments

After ; to EOL

Trang 4

• Formant of Assembly language

– case insensitive

[label:] mnemonic [operation] [,operand] ; comment

Example :

• Constant expression

– Implement by assembler

Examples:

• Operators in constant expressions

– Arithmetic : + - * / MOD

– Logic : AND OR NOT XOR

– Relational : EQ NE LT LE GT GE

= <> < <= > >=

– Special : SHR SHL HIGH LOW ()

Trang 5

• 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

Trang 6

(2) Symbol define

– Segment

– EQU

– Storage initialization/reservation

– Program link

– Segment selection

(A) Segment define

In low-level language, the programmer need to manage the

location of program/data in memory

… ; the following program was form a segment

; called symbol,

; The content is segment_type (code or data)

segment_type can be one of

• CODE (program)

• XDATA (the extended data segment)

• DATA (direct address space, 00-7fH)

• IDATA (indirect address space, 00-7FH 80-FFH for 8052)

• BIT (bit address space)

• CSEG AT (equivalent to SEGMENT CODE)

• DSEG AT

• XSEG AT

• ISEG AT

• BSEG AT

Trang 7

(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

MOV R7, #LENGTH MOV R0, #BUFFER

BJNZ R7, LOOP

….

END

Trang 8

Example 2:

XSEG AT 4000H

MOVX @DPTR, A

CJNE A, #LOW(XBUFFER+XLENGTH+1),LOOP

CJNE A, #HIGH(XBUFFER+XLENGTH+1),LOOP

….

END

FIGURE 7–4 Use of the EXTRN and PUBLIC assembler directives

Multi-file : EXTERN, PUBLIC directive

(3) Program link

Trang 9

FIGURE 7–5 Defining and initiating absolute and relocatable segments

RSEG directive – reallocatable segment

FIGURE 7–6 Assembler controls supported by ASM51

Trang 10

FIGURE 7–7 Linker operation

Trang 11

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

Trang 12

(c) EXAMPLE.M51

Output of linkage editor -Symbol table

-Reallocatable address were computed already

Ngày đăng: 13/04/2023, 08:09

w