Lecture Microcomputer principles and applications - Chapter 3: Assembly language programming

15 50 0
Lecture Microcomputer principles and applications - Chapter 3: Assembly language programming

Đ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

Contents: Introduction to Assembly, Instruction Cycle, Addressing Modes

Chapter Assembly language programming 3.1 Introduction to Assembly High level vs Assembly High level languages • More programmer friendly • More ISA independent • Each high-level statement translates to several instructions in the ISA of the computer Assembly language • Lower level, closer to ISA • Very ISA-dependent • Each instruction specifies a single ISA instruction • Makes low level programming more user friendly • More efficient code Microcomputer principles and applications 3.1 Introduction to Assembly Assembler syntax {label[:]} mnemonic {operand list} {;comment} • Symbols: ⋄ ⋄ ⋄ • Used as labels, constants, and substitution values and stored in a symbol table A symbol name is a string of up to 200 alphanumeric characters (A-Z, a-z, 0-9, $, and _), cannot contain embedded blanks, is case sensitive The first character cannot be a number Labels: ⋄ Labels are symbols Microcomputer principles and applications 3.1 Introduction to Assembly Assembler syntax {label[:]} mnemonic {operand list} {;comment} • Labels: ⋄ ⋄ ⋄ ⋄ • Begined in column and is optionally followed by a colon The value of a label is the current value of the Location Counter (address within program) A label on a line by itself is a valid statement Labels used locally within a file must be unique Mnemonics: ⋄ Cannot start in column If it does, it is interpreted as a label Microcomputer principles and applications 3.1 Introduction to Assembly Assembler syntax {label[:]} mnemonic {operand list} {;comment} • Mnemonics: ⋄ ⋄ ⋄ • Contains one of the following items: Instruction, Assembler directive, Macro directive, Macro invocation A label on a line by itself is a valid statement Labels used locally within a file must be unique Operands: ⋄ ⋄ ⋄ Contains one or more operands An operand may consist of: symbols, constants, expressions Operands are separated with commas Microcomputer principles and applications 3.2 Instruction Cycle • • • • • • Instruction Fetch (Get what you need to do) Instruction Decode (Understand what you need to do) First Operand Fetch (Not enough information, get some more) Second Operand Fetch (Still not enough information, get some more) Execute (Do it !) Write back (Write result of the operation) Microcomputer principles and applications 3.3 Addressing Modes Source Addressing Modes • • • • • • • Register Indexed Symbolic (PC Relative) Absolute Address Indirect Register Indirect Auto-increment Immediate Microcomputer principles and applications 3.3 Addressing Modes Destination Addressing Modes • • • • Register Symbolic (PC Relative) Absolute Address Indexed Microcomputer principles and applications 3.3 Addressing Modes 3.3.1 Register Mode Example: mov R5, R6 Explanation: Moves the content or the register R5 into R6 without altering R5 Usefulness Save a register to another Microcomputer principles and applications 3.3 Addressing Modes 3.3.2 Indexed Mode Example mov 4(R5), R6 Explanation • • • Add to the content of R5 inside the CPU Fetch the memory address from the forementionned computation Store the value into R6 Usefulness Access an item in memory (eg an array) with a constant offset Microcomputer principles and applications 3.3 Addressing Modes 3.3.3 Symbolic Mode Example mov 0x1234, R6 explanation • • • Add 0x1234 to the PC to generate the address Fetch the memory from the address of the forementionned computation Store the value into R6 Usefulness Access an array of data stored in the program memory Microcomputer principles and applications 3.3 Addressing Modes 3.3.4 Absolute Mode Example mov &0xDEAD, R6 Explanation • • Fetch the memory from the address 0xDEAD Store the value into R6 Usefulness Access memory at a known address (eg Peripheral) Microcomputer principles and applications 3.3 Addressing Modes 3.3.5 Indirect Register Mode Example mov @R8, R6 Explanation • • Fetch the memory at the address contained in R8 Store the value into R6 Usefulness Use a register as a pointer to memory Microcomputer principles and applications 3.3 Addressing Modes 3.3.6 Indirect Autoincrement Mode Example mov @R8+, R6 Explanation • • • Fetch the memory at the address contained in R8 Store the value into R6 Increment R8 Usefulness • • Copy a data to somewhere else in instruction Stack Popping Microcomputer principles and applications 3.3 Addressing Modes 3.3.7 Immediate Mode Example mov #0xBEEF, R6 Explanation Load R6 with 0xBEEF Usefulness Initialize a register with a value Microcomputer principles and applications ... be unique Operands: ⋄ ⋄ ⋄ Contains one or more operands An operand may consist of: symbols, constants, expressions Operands are separated with commas Microcomputer principles and applications. .. Immediate Microcomputer principles and applications 3.3 Addressing Modes Destination Addressing Modes • • • • Register Symbolic (PC Relative) Absolute Address Indexed Microcomputer principles and applications. .. code Microcomputer principles and applications 3.1 Introduction to Assembly Assembler syntax {label[:]} mnemonic {operand list} {;comment} • Symbols: ⋄ ⋄ ⋄ • Used as labels, constants, and substitution

Ngày đăng: 12/02/2020, 21:23

Từ khóa liên quan

Mục lục

  • Chapter 3Assembly language programming

    • 3.1 Introduction to Assembly

    • 3.1 Introduction to Assembly

    • 3.1 Introduction to Assembly

    • 3.1 Introduction to Assembly

    • 3.2 Instruction Cycle

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

    • 3.3 Addressing Modes

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan