1 / 18

Introduction to Assembly Language

Introduction to Assembly Language. Overview. What is Assembly Language? Why is AL important to learn? Machine instructions AL Instructions Intel 8086 Architecture Hands on Activity. What is Assembly Language (AL)?.

Download Presentation

Introduction to Assembly Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Assembly Language

  2. Overview • What is Assembly Language? • Why is AL important to learn? • Machine instructions • AL Instructions • Intel 8086 Architecture • Hands on Activity

  3. What is Assembly Language (AL)? • To learn how a computer and its software really work, you need to view them at machine level. • Assembly language is a specific set of instructions for a particular computer system. • AL teaches you about the way the computer’s hardware and OS work together and how application programs communicate with the OS. • It is a programming language with a one-to-one correspondence between its statement and a computer’s main machine language.

  4. Cont… • Each computer or family of computers uses a different set of machine instructions and a different assembly language (the computer’s design influences the instructions it can execute). • An assembler – a program that converts or translates source-code programs into machine language, which may in turn be executed by the computer (runs under the disk operating systems MS-DOS or PC-DOS).

  5. Why is AL important to learn? • Provides opportunity to know more about the operations of the PC • Enable control of the PC – access to specific hardware features • Quicker, smaller and have larger capacities compared to other HL languages

  6. Machine Instructions • A machine instruction is a binary code that has a special meaning for a computer’s CPU – it tells the computer to perform a task. • Each machine instruction is precisely defined when the CPU is constructed, and it is specified to that type of CPU. For example: • 00000100 Add a number to the AL register. • 10100011 Move the AX register to another register

  7. Registers are high-speed storage locations inside the CPU which are used by nearly every instructions • They are identified by 2-letter names, such as AH, AL, AX and so on. • We refer to machine instructions using hexadecimal numbers because they take up less writing space.

  8. Assembly Language Instructions • Mnemonic – a short alphabetic code that literally “assists the memory” in remembering CPU instruction • It may be an instruction or a directive • E.g. an instruction MOV (move) • E.g. a directive DB (definite byte, used to create memory variables) • An instruction may contain zero, one or two operands.

  9. Intel 8086 Architecture • There are 14 internal registers in Intel 8086 • All of them are represented in 16-bit mode or equivalent to 4 digits in hexadecimal • They are grouped into several categories • For general-purpose registers, each of these is a combination of two 8-bit registers which are separately accessible as AL, BL, CL, DL (the "low'' bytes) and AH, BH, CH, and DH (the "high'' bytes) • For example, if AX contains the 16-bit number 1234h, then AL contains 34h and AH contains 12h

  10. Registers Instruction Pointer PC / IP General-purpose registers Special-purpose registers segment registers Status register FLAGS AX = AH + AL, BX = BH + BL , CX = CH + CL, DX = DH + DL SP, BP, SI, DI CS, DS, ES, SS Figure 1: 14 Registers in Intel 8086

  11. General Purpose Registers • There are 4 general-purpose registers, each of them is designed to play a particular role in common use: • AX – Accumulator Register • Used for operations involving i/o and most arithmetic such as MUL and DIV, require that one of the operands be in the accumulator • As a place to store data • BX – Base Register • The only general-purpose register which may be used for indirect addressing, MOV [BX], AX • As a place to store data • CX – Count Register • It may contain a value to control the number of times a loop is repeated or a value to shift/rotate bits left or right • As a place to store data • DX – Data Register • Used together with AX for the word-size MUL and DIV operations • As a place to store data

  12. Special Purpose Registers • There are 4 special-purpose registers: • Stack Pointer Register (SP) • Holds add of top of stack • Base Pointer Register (BP) • Holds add of ref point in the stack • Source Index Register (SI) • Holds memory add of source • Destination Index Register (DI) • Holds memory add of destination

  13. Segment registers • There 4 segment register: • Code Segment Register (CS) • Holds selector for code segment • Data Segment Register (DS) • Holds selector for data segment • Extra Segment Register (ES) • Holds selector for extra segment • Stack Segment Register (SS) • Holds selector for stack segment

  14. Status Register • The status register, FLAGS, is a collection of 1-bit values, which reflect the current state of the processor and the results of recent operations • 9 of the 16 bits are used in the 8086. In this lesson you will only learn 6 flags: • Carry flag • Parity flag • Sign flag • Zero flag • Overflow flag • Auxiliary Flag

  15. Instruction Pointer • The instruction pointer (sometimes called Program Counter - PC), IP, gives the address of the next instruction to be executed, relative to the code segment .

  16. Debug commands

  17. Example: 0100 MOV AX, 0123 Move value 0123H to AX 0103 ADD AX, 0025  Add value 0025H to AX 0106 MOV BX, AX  Move contents of AX to BX 0108 ADD BX, AX  Add contents of AX to BX 010A MOV CX, BX  Move contents of BX to CX 010C SUB CX, AX  Subtract contents of AX from CX 010E SUB AX, AX  Subtract AX from AX (clear AX) 0110 JMP 100  Go back to the start

More Related