Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNDERSTANDING ASSEMBLY LANGUAGE.

Similar presentations


Presentation on theme: "UNDERSTANDING ASSEMBLY LANGUAGE."— Presentation transcript:

1 UNDERSTANDING ASSEMBLY LANGUAGE

2 Instruction A microprocessor executes instructions given by the user.
Instructions should be in a language known to the microprocessor. Microprocessor understands the language of 0’s and 1’s only. This language is called Machine Language. An instruction is a binary pattern designed inside a microprocessor to perform a specific function . Intel 8085 has 246 instructions. Each instruction is represented by an 8-bit binary value.

3 Instruction The instruction set is a collection of pre-defined machine codes, which the CPU is designed to expect and be able to act upon when detected. Each machine code of an instruction set consists of two separate fields: The OPCODE is a short code which indicates what operation is expected to be performed. Each operation has a unique opcode. The OPERAND, or operands, indicate where the data required for the operation can be found and how it can be accessed (the addressing mode, which is discussed in full later).

4 Instruction The length of a machine code can vary - common lengths vary from one to twelve bytes in size. Opcodes are also given mnemonics (short names) so that they can be easily referred to in code listings and similar documentation.

5 Microprocessor understands Machine Language only!
Microprocessor cannot understand a program written in Assembly language. A program known as Assembler is used to convert an Assembly language program to machine language. Assembly language is the language in which the mnemonics (short-hand of instructions) are used to write a program.

6 Examples Opcode Operand MOV C, A ADD B MVI A, 32H B, F2H

7 A Machine language program to add two numbers
;Copy value 2H in register A ;Copy value 4H in register B ;A = A + B

8 Assembly Language of 8085 It uses English like words to convey the action/meaning called as MNEMONICS For e.g. MOV to indicate data transfer ADD to add two values SUB to subtract two values

9 Assembly language program to add two numbers
Note: Assembly language is specific to a given processor

10 Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
246 Instructions, e.g. MOV A,B 8085 instructions can be classified as Data Transfer (Copy) instructions Arithmetic instructions Logical and Bit manipulation Branching instructions Machine Control instructions

11 Example Data Transfer (Copy) Operations / Instructions
Load a 8-bit number 4F in register B Copy from Register B to Register A Load a 16-bit number 2050 in Register pair HL Copy from Register B to Memory Address 2050 Copy between Input/Output Port and Accumulator MVI B, 4FH MOV A,B LXI H, 2050H MOV M,B OUT 01H IN 07H

12 Example Arithmetic Operations / Instructions
Add a 8-bit number 32H to Accumulator Add contents of Register B to Accumulator Subtract a 8-bit number 32H from Accumulator Subtract contents of Register C from Accumulator Increment the contents of Register D by 1 Decrement the contents of Register E by 1 ADI 32H ADD B SUI 32H SUB C INR D DCR E

13 Example Logical & Bit Manipulation Operations / Instructions
Logically AND Register H with Accumulator Logically OR Register L with Accumulator Logically XOR Register B with Accumulator Compare contents of Register C with Accumulator Complement Accumulator Rotate Accumulator Left ANA H ORA L XRA B CMP C CMA RAL

14 Addressing Modes of 8085 Addressing modes specify the way in which the address of the operand is given in the instruction.          Opcode    [Operands] [;comments]   E.g.:     MVI   B, 05   : Here MVI (Move Immediate) is the opcode part and the rest is the operand part.                 MOV  A , B   : Here MOV is the opcode part and the rest is the operand part.                 ADD   B        : Here ADD is the opcode part and the rest is the operand part.       

15 Addressing Modes of 8085 The various formats of specifying operands are called addressing modes. Addressing modes of 8085: Register Addressing Immediate Addressing Memory Addressing Input/Output Addressing

16 1. Register Addressing In this addressing mode, a register contains the operand. Depending upon the instruction, the register may be the first operand, the second operand or both. Operands are one of the internal registers of 8085. Examples: MOV A, B ADD C

17 2. Immediate Addressing In the immediate addressing mode, direct data is given in the operand which move the data in accumulator. It is very fast. Value of the operand is given in the instruction itself Examples: MVI A, 20H LXI H, 2050H ADI 30H SUI 10H

18 3. Memory Addressing One of the operands is a memory location
Depending on how address of memory location is specified, memory addressing is of two types: Direct addressing Indirect addressing

19 3(a) Direct Addressing In the direct addressing mode, address of the operand is given in the instruction and data is available in the memory location which is provided in instruction. We will move this data in desired location. 16-bit Address of the memory location is specified in the instruction directly. Examples: LDA 2050H ;load A with contents of memory location with address 2050H STA 3050H ;store A with contents of memory location with address 3050H

20 Direct Addressing Diagram
Instruction Opcode Address A Memory Operand 6

21 3(b) Indirect Addressing
In the indirect addressing mode, the instruction specifies a register which contain the address of the operand. Both internal RAM and external RAM can be access via indirect addressing mode. A memory pointer register is used to store the address of the memory location. Example: MOV M, A ;copy register A to memory location whose address is stored in register pair HL H L A 30H 20H 50H 2050H 30H

22 Indirect Addressing Diagram
Instruction Opcode Address A Memory Pointer to operand Operand 6

23 HL Register The HL register is the only register that can be used to specify a memory address. It is called a pointer register because it points to a memory location. The H register contains the high byte of the address, and the L register the low byte. High and low bytes may be unfamiliar to you. Consider the decimal number 47. From convention we know that 4 is the number of "tens", and the 7 is the number of "units", high and then low. For the hex number 47, 4 is the number of "sixteens", and 7 is the number of "units". In the same way for the number 4768, 47 is the number of "two-hundred-fifty-sixes", and 68 is the number of "units". We split it this way because the first two digits can fit in the high byte (register) and the second two can fit in the low register.

24 MOV Instruction This instruction is used to copy the data from one place to another. The MOV instruction takes two operands. Syntax: Syntax of the MOV instruction is: The MOV instruction may have one of the following five forms:

25 MOV Instruction Examples:
MOV Rd, Rs (This instruction copies the content of Rs to Rd) MOV M, Rs (This instruction copies the content of register Rs to memory location pointed by HL Register) MOV Rd, M (This instruction copies the content of memory location pointed by the HL register to the register Rd.) *Note: the contents of the source register are not altered.

26 MVI Instruction MVI: move immediate date to a register or memory location. Examples: MVI Rd, #30H (30h is stored in register Rd) MVI M, #30H (30h is stored in memory location pointed by HL Reg)

27 4. Input/Output Addressing
8-bit address of the port is directly specified in the instruction Examples: IN 07H OUT 21H

28 5. Instruction & Data Formats
8085 Instruction set can be classified according to size (in bytes) as: 1-byte Instructions 2-byte Instructions 3-byte Instructions

29 1. One-byte Instructions
Includes Opcode and Operand in the same byte Examples: Opcode Operand Binary Code Hex Code Task MOV C, A 4FH Copy the contents of the accumulator in the register C. ADD B 80H Add the contents of register B to the contents of the accumulator. HLT 76H

30 2. Two-byte Instructions
First byte specifies Operation Code Second byte specifies Operand Examples: Opcode Operand Binary Code Hex Code MVI A, 32H 3EH 32H B, F2H 06H F2H

31 3. Three-byte Instructions
First byte specifies Operation Code Second & Third byte specifies Operand Examples: Opcode Operand Binary Code Hex Code LXI H, 2050H 21H 50H 20H LDA 3070H 3AH 70H 30H

32 An example assembly language program
Address Instruction 202A MVI A, 21 ;Copies 21 into accumulator 202C MVI B, 2A ;Copies 2A into B register 202E ADD B ;Adds B reg content with Acc and stores the result in Acc. 202F STA 41 FF ; Stores the Acc (the sum) into the memory location 41 FF. 2032 HLT ; Stops the program

33 Another example assembly language program
Address Instruction 2020 MVI B, 24 ;Copies 24 into accumulator 2022 INR B ;Increment B reg content by 1 2023 MOV A, B ;Copies B register into Acc. 2024 SUB B ;Subtracts B reg content from Acc and stores the result in Acc. 2025 STA 5F FF ; Stores the Acc content into the memory location 5F FF. 2028 HLT ; Stops the program


Download ppt "UNDERSTANDING ASSEMBLY LANGUAGE."

Similar presentations


Ads by Google