Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Assembly Language

Similar presentations


Presentation on theme: "Introduction to Assembly Language"— 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: Add a number to the AL register. 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 Figure 1: 14 Registers in Intel 8086
General-purpose registers Special-purpose registers segment registers Status register Instruction Pointer PC / IP AX = AH + AL, BX = BH + BL , CX = CH + CL, DX = DH + DL SP, BP, SI, DI CS, DS, ES, SS FLAGS 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 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 DX – Data Register Used together with AX for the word-size MUL and DIV operations

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 In this lesson you will only learn 6 flags: Carry flag Parity flag Sign flag Zero flag Overflow flag Auxiliary Flag

15 Symbol Set Clear Carry Flag CF CY NC Parity Flag PF PE PO Zero Flag ZF ZR NZ Sign Flag SF NG PL Overflow Flag OF OV NV Auxiliary Flag AF AC NA

16 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 .

17 Debug commands Command Purpose r Display the contents of all registers
Alter the contents of a register u List the instructions contained in the given address and following in assembly language form D Display the contents of memory in hexadecimal format and as ASCII character starting with the address given e Enter values into memory, beginning at a specific location t Trace the execution of an instruction a Choose an address to write a program q Quit the debug session

18 Example: 0100 MOV AX, 0123 Move value 0123H to AX
0103 ADD AX,  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


Download ppt "Introduction to Assembly Language"

Similar presentations


Ads by Google