microprocessor lecture
DESCRIPTION
Microprocessor LectureTRANSCRIPT
ASSEMBLY LANGUAGE
LECTURE:3
ASSEMBLY LANGUAGE
LECTURE:3
THE MICROPROCESSORTHE MICROPROCESSOR
DATA ADDRESSING MODESDATA ADDRESSING MODES
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
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
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
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
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
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:
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’
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
EXAMPLESEXAMPLES
• MOV AL,NUMBER• MOV AX,COW• MOV HOME,AX
• MOV AL,NUMBER• MOV AX,COW• MOV HOME,AX
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
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
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