microprocessor lecture

14
ASSEMBLY LANGUAGE LECTURE:3 THE MICROPROCESSOR

Upload: rayan-isran

Post on 07-Dec-2015

212 views

Category:

Documents


0 download

DESCRIPTION

Microprocessor Lecture

TRANSCRIPT

Page 1: Microprocessor Lecture

ASSEMBLY LANGUAGE

LECTURE:3

ASSEMBLY LANGUAGE

LECTURE:3

THE MICROPROCESSORTHE MICROPROCESSOR

Page 2: Microprocessor Lecture

DATA ADDRESSING MODESDATA ADDRESSING MODES

Page 3: Microprocessor Lecture

DATA ADDRESSING MODES DATA ADDRESSING MODESMOV AX,BXMOV= opcodeAX and BX = operand

different ways of specifying data are called the data addressing modes

MOV AX,BXMOV= opcodeAX and BX = operand

different ways of specifying data are called the data addressing modes

Page 4: Microprocessor Lecture

DATA ADDRESSING MODESDATA ADDRESSING MODES

• Register Addressing• Immediate Addressing • Direct Addressing• Register Indirect Addressing• Base plus Index Addressing• Register Relative Addressing• Base Relative Plus Index Addressing

• Register Addressing• Immediate Addressing • Direct Addressing• Register Indirect Addressing• Base plus Index Addressing• Register Relative Addressing• Base Relative Plus Index Addressing

Page 5: Microprocessor Lecture

The register addressing mode involves the use of registers to holdThe data to be manipulated. Memory is not accessed when this

addressing mode is executed

Examples:MOV BX,DX ; copy the contents of DX into BXMOV AX,BX ; copy the contents of AX into BXADD AL,BH ; add the contents of BX into AL

Note:the source and destination register must match in size

Error Statement: MOV CL,AXSince the source is a 16 bit registers and destination is 8-bit

register.

The register addressing mode involves the use of registers to holdThe data to be manipulated. Memory is not accessed when this

addressing mode is executed

Examples:MOV BX,DX ; copy the contents of DX into BXMOV AX,BX ; copy the contents of AX into BXADD AL,BH ; add the contents of BX into AL

Note:the source and destination register must match in size

Error Statement: MOV CL,AXSince the source is a 16 bit registers and destination is 8-bit

register.

Register Addressing ModeRegister Addressing Mode

Page 6: Microprocessor Lecture

Examples:Examples:

• MOV AL,BL• MOV CH,CL• MOV AX,CX• MOV SP,BP• MOV DS,AX• MOV SI,DI

• MOV AL,BL• MOV CH,CL• MOV AX,CX• MOV SP,BP• MOV DS,AX• MOV SI,DI

Page 7: Microprocessor Lecture

In the immediate addressing mode, the source operand is constant. In the immediate addressing mode, as the name implies, when the instruction is assembled, the operand comes immediately after the opcode. For this reason, this addressing mode can be used to load information into any of the registers except the segment register and flag registers.

In the immediate addressing mode, the source operand is constant. In the immediate addressing mode, as the name implies, when the instruction is assembled, the operand comes immediately after the opcode. For this reason, this addressing mode can be used to load information into any of the registers except the segment register and flag registers.

Immediate Addressing ModeImmediate Addressing Mode

Page 8: Microprocessor Lecture

MOV AX,2550H; move 2550H into AXMOV CX,625 ; load decimal value 625 into CXMOV BL,40H ; load 40H into BL

In case of data segment registers:

MOV AX,2550HMOV DS,AX

In other words the following would produce an error:MOV DS,0123H; illegal

MOV AX,2550H; move 2550H into AXMOV CX,625 ; load decimal value 625 into CXMOV BL,40H ; load 40H into BL

In case of data segment registers:

MOV AX,2550HMOV DS,AX

In other words the following would produce an error:MOV DS,0123H; illegal

Examples:Examples:

Page 9: Microprocessor Lecture

EXAMPLESEXAMPLES

• MOV AL,44• MOV AX,44H• MOV SI,0• MOV CH,100• MOV AL,’A’• MOV AX,’AB’

• MOV AL,44• MOV AX,44H• MOV SI,0• MOV CH,100• MOV AL,’A’• MOV AX,’AB’

Page 10: Microprocessor Lecture

In register direct Addressing mode the data is in some memory location and the address of the data in memory comes immediately after the instruction.

MOV DL,[2400]

In register direct Addressing mode the data is in some memory location and the address of the data in memory comes immediately after the instruction.

MOV DL,[2400]

Register direct Addressing ModeRegister direct Addressing Mode

Page 11: Microprocessor Lecture

EXAMPLESEXAMPLES

• MOV AL,NUMBER• MOV AX,COW• MOV HOME,AX

• MOV AL,NUMBER• MOV AX,COW• MOV HOME,AX

Page 12: Microprocessor Lecture

PROBLEM:PROBLEM:

• Find the physical address of the memory location and its content after execution of the following. Assuming DS:1512H

• Mov AL,99H• MOV [3518],AL

• Find the physical address of the memory location and its content after execution of the following. Assuming DS:1512H

• Mov AL,99H• MOV [3518],AL

Page 13: Microprocessor Lecture

SOLUTION:SOLUTION:

• First AL is initialized to 99H• Then the content of AL are moved to logical

address DS:3518• Shifting Ds left and adding it to the offset gives

the physical address of 18638H (15120h + 3518H= 18638H). That means after the execution of the 2nd instruction, the memory location with address 18638H will contain the value 99h

• First AL is initialized to 99H• Then the content of AL are moved to logical

address DS:3518• Shifting Ds left and adding it to the offset gives

the physical address of 18638H (15120h + 3518H= 18638H). That means after the execution of the 2nd instruction, the memory location with address 18638H will contain the value 99h

Page 14: Microprocessor Lecture

PROBLEM:PROBLEM:

• Find the physical address of the memory location and its content after execution of the following. Assuming DS:1012H

• Mov AL,64H• MOV [4318],AL

• Find the physical address of the memory location and its content after execution of the following. Assuming DS:1012H

• Mov AL,64H• MOV [4318],AL