microprocessor i - lecture 05draelshafee.net/fall2019/microprocessor-i---lecture-05.pdf ·...
TRANSCRIPT
Lecture (05)
By:
Dr. Ahmed ElShafee
Dr. Ahmed ElShafee, ACU : Fall 2019, Microprocessors 11
Segmentation
• Segmentation is used to allow relocation of programs, i.e. programs can be loaded on different memory areas and still run correctly.
• Segmentation is used in the 8088/8086 microprocessors to allow the generation of 20‐bit addresses using 16‐bit registers.
Dr. Ahmed ElShafee, NileU : Fall 2017, Microprocessor System Design2
• In the Real Mode Operation a 20‐bit address (effective address) is obtained by shifting the segment address 4 bits to the left (X10H) and then adding the offset address
• The offset address is specified in the program. The segment address is specified by the operating system whenever the program is loaded.
• The code segment holds the machine codes of the program. The Instruction Pointer specifies the offset address in the code segment.Dr. Ahmed ElShafee, NileU : Fall 2017, Microprocessor System Design3
• The data segment holds the data used by the program. Most data references are specified in the data segment.
• The stack segment holds the stack of the program. The offset address in the stack segment is specified with the registers SP and BP.
• The extra segment is used as a data segment by some data movement instructions.
Dr. Ahmed ElShafee, NileU : Fall 2017, Microprocessor System Design4
Example
If DS =1600H find the maximum area occupied by the data segment. Find also the effective address, if the offset address is 1F00H.
Dr. Ahmed ElShafee, NileU : Fall 2017, Microprocessor System Design5
Solution
Starting address = DS X 10H = 1600H X 10H
= 16000H
Ending address = Starting address + FFFF
= 16000H + FFFFH = 25FFFH
Effective address= Segment:Offset = 1600:1F00
= Segment address X 10H + Offset
= 1600H X 10H + 1F00H
= 16000H + 1F00H = 17F00H
Dr. Ahmed ElShafee, NileU : Fall 2017, Microprocessor System Design6
The Memory Map of a Personal Computers• Transient Program Area (TPA): Holds the operating system (interrupt vectors, DOS BIOS, devices drivers, Command.com) and application programs.
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 17
• System Area: Holds the ROM BIOS, the video buffer area, and the BASIC language ROM.
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 18
• Extended Memory: Memory above the 1M conventional memory found in AT compatible computers . Its size depends on the RAM installed on the motherboard, and is limited by the size of the processor’s address bus.
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 19
Format of DOS programs
• All programs must have a code and a stack.
– Code is the part of the program that contains the instructions of the program.
– Stack is an area in the RAM used by the system to store return addresses, and by the programmer to store temporarily data. It is a Last In First Out (LIFO) buffer.
• Programs can also have a data area, where all data (variables) is stored.
• There are two basic types of programs:
– Commands (.COM). The data and the stack of the program are part of the Code segment. The stack is always located at the end of the segment. The first 256 bytes of the segment are reserved.
– Executable (.EXE). The code and stack and data of the program are located in different segments.
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 110
Format of the .COM programs
.MODEL SMALL
CSEG SEGMENT PARA 'CODE’ ;Start a Code segment
ASSUME CS:CSEG, DS:CSEG, SS:CSEG
ORG 100H ;Reserve first 256 locations
START: JMP MAIN ;Skip data area
{Place the data of the program here}
MAIN PROC NEAR ;Beginning of main procedure
{Place the code of the
program here}
RET ;Get return DOS address
MAIN ENDP ;End of main procedure
CSEG ENDS ;End of the segment
END START ;End of the program
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 111
Format of the .COM programs
.MODEL SMALL
.CODE
ORG 100H ;Reserve first 256 locations
START: JMP MAIN ;Skip data area
{Place the data of the program here}
MAIN PROC NEAR ;Beginning of main procedure
{Place the code of the
program here}
RET ;Get return DOS address
MAIN ENDP ;End of main procedure
END START ;End of the program
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 112
Example 01; hello world; masm
CSEG SEGMENT PARA ‘CODE’ ;Start a Code segment
ASSUME CS:CSEG, DS:CSEG, SS:CSEG
ORG 100H ;Reserve first 256 locations
START: JMP MAIN ;Skip data area
MSG DB "Hello World 01",'$‘
MAIN PROC NEAR ;Beginning of main procedure
LEA DX,MSG
MOV AH,9
INT 21H
INT 20H
RET
MAIN ENDP ;End of main procedure
CSEG ENDS ;End of the segment
END START ;End of the program
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 113
Example 02; hello world; masm
.MODEL SMALL
.CODE
ORG 100H ;Reserve first 256 locations
START: JMP MAIN ;Skip data area
MSG DB "Hello World 01",'$‘
MAIN PROC NEAR ;Beginning of main procedure
LEA DX,MSG
MOV AH,9
INT 21H
INT 20H
RET
MAIN ENDP ;End of main procedure
END START ;End of the program
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 114
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 115
Compiling and linking
Masm 01.asm
ML –AT 01.obj
01.com
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 116
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 117
Basic Input Output SystemBIOS• BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
• A BIOS function is invoked using the INT instruction. The actual function is specified by the contents of AH.
• ROM BIOS refers to BIOS procedures that are stored in a ROM placed on the motherboard. Some typical ROM BIOS are:
– INT 10H Video Driver
– INT 13H Disk Driver
– INT 14H Serial Port Driver
– INT 16H Keyboard Driver
• DOS BIOS refers to BIOS that are loaded from a disk after the computer is booted up. Most DOS BIOS are invoked using the INT 21H instruction.
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 118
Character Input from keyboard with Echo:
• INT 21H Function 01H:– Call With: AH = 01H
– Returns: AL = ASCII character pressed.
– Note: If AL is zero, then a function key is pressed.
– Example: The following macro reads a one digit number from the keyboard and returns the corresponding
binary value in AL.
GET1 MACRO
MOV AH,01 ;Specify function 01
INT 21H ;Call DOS BIOS
GET1 ENDM
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 119
Display Character on Standard Output Device
• INT 21H Function 02H:– Call With: AH = 02H
DL = ASCII code of character to be displayed
– Returns: AL = ASCII code of character displayed
– Note: Standard output device is normally the monitor.
– Example: The following macro displays a one digit number on the screen. The number is passed in DL as a binary number.
DSP1 MACRO
add DL,30H ;Convert from binary to ASCII
MOV AH,02 ;Specify function 02
INT 21H ;Call DOS BIOS
DSP1 ENDMDr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 120
Display a Character String
• INT 21H Function 09H:– Call With: AH = 09H
DS:DX = Segment:Offset address of the string.
– Returns: All registers unchanged.
– Note: Displays a character string up to the first occurrence of the dollar sign "$".
– Example: The following macro displays the character string MSG on the screen.
DMSG MACRO MSG
MOV DX, Offset MSG ;Point to MSG
MOV AH,09 ;Specify function 09
INT 21H ;Call DOS BIOS
DMSG ENDMDr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 121
• Buffered Keyboard Input
• INT 21H Function 0AH:– Call With: AH = 0AH
DS:DX = Segment:Offset address of the buffer
The first byte in the buffer should be loaded with the size of the buffer, i.e. the maximum numberof characters to be input.
– Returns: All registers unchanged.
The second byte in the buffer is equal to the number of characters entered. The characters entered are stored in the buffer starting from the third byte.
– Note: The functions ends if the user has typed in a number of characters equal to the first value in the buffer, or if the user has pressed the
“Enter” key. Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 122
The following procedure prompts the user to type in a text up to 30 characters long. The text entered is stored in the buffer BUF1. The procedure uses the DSPM macro of the previous example.
ORG 100H
MSG1 DB ‘Type in a text up to 30 characters long’, 0AH, 0DH,’$’
BUF1 DB 30, 00, 30 DUP(?)
MAIN PROC NEAR
DSPM MSG1 ;Display MSG1
MOV DX, Offset BUF1 ;Point to BUF1
MOV AH,0AH ;Specify function 0A
INT 21H ;Call DOS BIOS
RET
MAIN ENDPDr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 123
Example 03
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 124
ORG 100H jmp MAINMSG1 DB "Type in a text up to 30 characters long", 0AH, 0DH,'$'BUF1 DB 30, 00, 30 DUP(?)MSG2 DB "press any key to continue,..$"
DSP1 MACROADD DL,30H
MOV AH,02
INT 21H
DSP1 ENDM
DMSG MACRO MSGMOV DX, Offset MSG
MOV AH,09INT 21H
DMSG ENDM
GET1 MACROMOV AH,01INT 21H
GET1 ENDM
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 125
MAIN PROC NEARDMSG MSG1MOV DX, Offset BUF1MOV AH,0AHINT 21H DMSG MSG2GET1RET
MAIN ENDP
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 126
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 127
Example 03
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 128
ORG 100H jmp MAINMSG1 DB "Type in a text up to 30 characters long", 0AH, 0DH,'$'BUF1 DB 30, 00, 30 DUP(?)MSG2 DB "press any key to continue,..$"
DSP1 MACROADD DL,30H
MOV AH,02
INT 21H
DSP1 ENDM
DMSG MACRO MSGMOV DX, Offset MSG
MOV AH,09
INT 21H
DMSG ENDM
GET1 MACROMOV AH,01
INT 21H GET1 ENDM
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 129
GET2 MACRO BUFMOV DX, Offset BUFMOV AH,0AHINT 21H
GET2 ENDM
MAIN PROC NEARDMSG MSG1
GET2 BUF1DMSG MSG2GET1RET
MAIN ENDP
BIOS30
ASCII Codes
00 NUL01 SOH02 STX03 ETX04 EOT05 ENQ06 ACK07 BEL
• ASCII code is a standard 8-bit binary code for alphanumeric characters.
• It defines:– a group of control characters (00H to 20H and 7FH for Delete)– a group of printable characters (21H to 7EH)– a group of special graphics or multilingual characters (80H to FFH)
08 BS09 HT0A LF0B VT0C FF0D CR0E SO0F SI
ASCII Control Characters
10 DLE 11 DC112 DC2 13 DC3 14 DC4 15 NAK 16 SYN 17 ETB
18 CAN19 EM1A SUB1B ESC1C FS1D GS1E RS1F US
BIOS31
ASCII Codes - Printable Characters
20 Space21 !22 ”23 #24 $25 %26 &27 ’28 (29 )2A *2B +2C ,2D -2E .2F /
30 031 132 233 334 435 536 637 738 839 93A :3B ;3C <3D =3E >3F ?
40 @41 A42 B43 C44 D45 E46 F47 G48 H49 I4A J4B K4C L4D M4E N4F O
60 `61 a62 b63 c64 d65 e66 f67 g68 h69 i6A j6B k6C l
6D m6E n6F o
70 p 71 q72 r73 s74 t75 u76 v77 w78 x79 y7A z7B {7C |7D }7E ~
7F Del
50 P51 Q52 R53 S54 T55 U56 V57 W58 X59 Y5A Z5B [5C \5D ]5E ^5F _
Addressing Modes
• Addressing mode refers to the way the data needed by an instruction is specified.
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 132
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 133
Moving Data: IA32• Moving Data
mov Des, src:
• Operand Types
– Immediate: Constant integer data
• Example: 0x400, -533
– Register: One of 8 integer registers
• Example: eax, edx
• But esp and ebp reserved for special use
• Others have special uses for particular instructions
– Memory: 4 consecutive bytes of memory at address given by register
• Simplest example: ([eax])
• Various other “address modes”
%eax
%ecx
%edx
%ebx
%esi
%edi
%esp
%ebp
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 134
mov Operand Combinations
Cannot do memory‐memory transfer with a single instruction
mov
Imm
Reg
Mem
Reg
Mem
Reg
Mem
Reg
operand Src,Dest C Analog
mov eax, 0x4 temp = 0x4;
mov [eax], -147 *p = -147;
Mov edx, eax temp2 = temp1;
mov [edx], eax *p = temp;
Mov edx, [eax] temp = *p;
Src
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 135
int _tmain(int argc, _TCHAR* argv[]){unsigned intx1,x2,x3,y1,y2,y3,z1,z2,z3,address_z3;y1=147;y2=258;z1=741;_asm{//immediate addressing modemov eax,123 mov x1, eax// just to printmov x2,456// reg trans modemov eax, y1mov y2, eax// mem trans mode mov eax, z1mov z2,eax
lea ebx,z3mov address_z3,ebxmov edx,789mov [ebx],edx}
printf("x1=%d\n",x1);printf("x2=%d\n\n",x2);printf("y1=%d\n",y1);printf("y2=%d\n\n",y2);printf("z1=%d\n",z1);printf("z2=%d\n",z2);printf("z3::0x%x:%d\n\n",address_z3,z3);printf("Press any key to continue,...");char ch = getch();return 0;}
Example 05
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 136
Simple Memory Addressing Modes
• Normal (R) Mem[Reg[R]]
– Register R specifies memory address
mov eax, [ecx]
• Displacement D(R) Mem[Reg[R]+D]
– Register R specifies start of memory region
– Constant displacement D specifies offset
mov edx, 8[ebp]
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 137
Example 06
int _tmain(int argc, _TCHAR* argv[]){unsigned int src_arr[4]={12,34,56,78};unsigned int x1,x2,x3,x4;unsigned int des_arr[4];_asm{lea ebx,src_arrmov edx,[ebx]mov x1,edxmov edx,4[ebx]mov x2,edxmov edx,8[ebx]mov x3,edxmov edx,12[ebx]mov x4,edx
lea ebx,des_arrmov edx,x4mov [ebx],edxmov edx,x3mov 4[ebx],edxmov edx,x2mov 8[ebx],edx
mov edx,x1mov 12[ebx],edx}printf("x1=%d\n",x1);printf("x2=%d\n",x2);printf("x3=%d\n",x3);printf("x4=%d\n",x4);printf("des_arr[0]=%d\n",des_arr[0]);printf("des_arr[1]=%d\n",des_arr[1]);printf("des_arr[2]=%d\n",des_arr[2]);printf("des_arr[3]=%d\n",des_arr[3]);printf("Press any key to continue,...");char ch = getch();return 0;}
1> Immediate Addressing Mode
• The data needed is specified as a number in the machine code of a program. The data is specified by the programmer:
– as a numeric operand in the instruction,
e.g. MOV AL,87H ;AL 87H
MOV CX,34A6H ;CX 34A6H
MOV BL,8C2H ;Invalid (Data Mismatch)
– or as a label. The actual value is determined by the assembler.
e.g. MOV BX,OFFSET VAL3 ;BX Address of VAL3
MOV AH,CON1 ;AH CON1
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 138
Example 07
org 100h
jmp start
VAL1 EQU 39H
VAL2 DB 37
start:
nop
MOV BX,OFFSET VAL2
MOV AH,VAL1
END start
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 139
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 140
Example 08
ORG 100H
STRT: JMP MAIN
CON1 EQU 6CH
CON2 EQU 245AH
DAT1 DB 2FH,48H
DAT2 DB 4 DUP (0)
DAT3 DW 37AH
MAIN PROC NEAR
MOV SI,2310H
MOV BX,OFFSET DAT1
MOV AL,CON1
MOV CX,CON2
MOV AX,283CH
MOV AX,OFFSET DAT3
ENDP MAIN
END startDr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 141
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 142
ORG 100H Label Address DataSTRT: JMP MAINCON1 EQU 6CHCON2 EQU 245AHDAT1 DB 2FH,48HDAT2 DB 4 DUP (0)DAT3 DW 37AH
AX BX CXSI
MAIN PROC NEAR AH AL BH BL CH CLMOV SI,2310H MOV BX,OFFSET DAT1MOV AL,CON1 MOV CX,CON2 MOV AX,283CH MOV AX,OFFSET DAT3ENDP MAINEND start
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 143
ORG 100H Label Address Data
STRT: JMP MAIN start 0100‐0101 CODECON1 EQU 6CH DAT1 0102‐0103 2F48CON2 EQU 245AH DAT2 0104‐0107 00000000
DAT1 DB 2FH,48H DAT3 0108‐0109 7A03DAT2 DB 4 DUP (0)DAT3 DW 37AH
AX BX CXSI
MAIN PROC NEAR AH AL BH BL CH CLMOV SI,2310H NC NC NC NC NC NC 2310
MOV BX,OFFSET DAT1 NC NC 01 02 NC NC NCMOV AL,CON1 6CMOV CX,CON2 24 5AMOV AX,283CH 28 3CMOV AX,OFFSET DAT3 01 08ENDP MAINEND start
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 144
2> Register Addressing Mode
• Both of the operands are the contents of registers.
e.g. MOV AL,BH ;AL BH
MOV BX,CX ;BX CX
MOV AX,DL ;Invalid (Data Mismatch)
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 145
Example 09
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 146
ORG 100HSTRT: JMP MAINDATA1 DW 3620HDATA2 DW 0EEA5HDATA3 DW 9089HDATA4 DW 73F6HDATA5 DW 2006HMAIN PROC NEARMOV AX,DATA1MOV BX,DATA2MOV CX,DATA3MOV DX,DATA4MOV SI,DATA5
MOV BX,CXMOV AL,DHMOV CX,AXMOV AH,ALMOV SI,DXENDP MAINEND start
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 147
AX BX CX DXSI
AH AL BH BL CH CL DH DLMAIN PROC NEAR 36 20 EE A5 90 89 73 F6 2006MOV BX,CXMOV AL,DHMOV CX,AXMOV AH,ALMOV SI,DX
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 148
AX BX CX DXSI
AH AL BH BL CH CL DH DLMAIN PROC NEAR 36 20 EE A5 90 89 73 F6 2006MOV BX,CX 90 89MOV AL,DH 36 73MOV CX,AX 36 73MOV AH,AL 73MOV SI,DX 73F6
DATA1 DW 3620HDATA2 DW 0EEA5HDATA3 DW 9089HDATA4 DW 73F6HDATA5 DW 2006H
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 149
3> Direct Addressing Mode
• One of the operands is the contents of the memory location that is specified directly in the instruction.
e.g. MOV AL,[1008H] ;AL [1008H]
MOV BX,VALUE ;BX [VALUE]
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 150
Example 10
ORG 100H
STRT: JMP MAIN
DB ?
FRST DB 0C1H
VAL1 DW 8756H
ARR1 DB 9FH,0A6H,75H,8CH
MAIN PROC NEAR
MOV AL,[0104H]
MOV BX,[0108H]
MOV CH,FRST
MOV DX,VAL1
MOV AH,ARR1
MOV CL,ARR1+3
ENDP MAIN
END startDr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 151
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 152
ORG 100H Label Address DataSTRT: JMP MAIN FRST 0103DB ? VAL1 0104FRST DB 0C1H 0105VAL1 DW 8756H ARR1 0106ARR1 DB 9FH,0A6H,75H,8CH 0107
01080109
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 153
ORG 100H Label Address DataSTRT: JMP MAIN FRST 0103 C1DB ? VAL1 0104 56FRST DB 0C1H 0105 87VAL1 DW 8756H ARR1 0106 9FARR1 DB 9FH,0A6H,75H,8CH 0107 A6
0108 750109 8C
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 154
Label Address DataFRST 0103 C1VAL1 0104 56
0105 87ARR1 0106 9F
0107 A60108 750109 8C
AX BX CX DXSI
MAIN PROC NEAR AH AL BH BL CH CL CH CLMOV AL,[0104H]MOV BX,[0108H]MOV CH,FRSTMOV DX,VAL1MOV AH,ARR1MOV CL,ARR1+3
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 155
Label Address DataFRST 0103 C1VAL1 0104 56
0105 87ARR1 0106 9F
0107 A60108 750109 8C
AX BX CX DXSI
MAIN PROC NEAR AH AL BH BL CH CL CH CLMOV AL,[0104H] 56MOV BX,[0108H] 8C 75MOV CH,FRST C1MOV DX,VAL1 87 56MOV AH,ARR1 9FMOV CL,ARR1+3 8C
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 156
4> Register Indirect Addressing Mode
• One of the operands is the contents of the memory location that is specified by a register, or a combination of registers and an offset, in the instruction.
Index: Use of SI or DI to specify a memory location.
e.g. MOV AL,[SI] ;AL [SI]
- Base: Use of BX or BP to specify a memory location.
e.g. MOV AH,[BP] ;AL [BP]
- Base Relative: Use of BX or BP in combination with an offset to specify a memory location.
e.g. MOV AL,[BX+ 2] ;AL [BX + 2]
- Base Relative plus Index: Use of BX or BP in combination with an index register (SI or DI) and an offset to specify a memory location.
e.g. MOV AL,[BX+SI+8] ;AL [BX+SI+8]
MOV BX,ARR[BX+DI] ;BX ARR[BX+DI]
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 157
Example 11
ORG 100H
STRT: JMP MAIN
DAT1 DB 2FH,48H
DAT2 DB 12H,10H,18H
DAT3 DW 7A5H
DAT4 DW 37H
DAT5 DB 10H
MAIN PROC NEAR
MOV AX,7745H
MOV BX,0104H
MOV DI,0001
MOV SI,0002
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 158
MOV AL,[BX]
MOV AH,DAT2[SI]
MOV AL,DAT1[DI]
MOV AL,[BX+SI]
MOV AH,[BX+DI+3]
ENDP MAIN
END start
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 159
ORG 100H Label Address DataSTRT: JMP MAIN 0100DAT1 DB 2FH,48H 0101DAT2 DB 12H,10H,18H 0102DAT3 DW 7A5H 0103DAT4 DW 37H 0104DAT5 DB 10H 0105
0106010701080109010A010B
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 160
ORG 100H Label Address DataSTRT: JMP MAIN START 0100DAT1 DB 2FH,48H 0101DAT2 DB 12H,10H,18H DAT1 0102 2FHDAT3 DW 7A5H 0103 48HDAT4 DW 37H DAT2 0104 12HDAT5 DB 10H 0105 10H
0106 18HDAT3 0107 0A5H
0108 07HDAT4 0109 37H
010A 00HDAT5 010B 10H
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 161
AX BX CX DXSI di
MAIN PROC NEAR AH AL BH BL CH CL DH DLMOV AX,7745HMOV BX,0104HMOV DI,0001MOV SI,0002MOV AL,[BX]MOV AH,DAT2[SI]MOV AL,DAT1[DI]MOV AL,[BX+SI]MOV AH,[BX+DI+3]
Address Data
DAT1 0102 2FH
0103 48H
DAT2 0104 12H
0105 10H
0106 18H
DAT3 0107 0A5H
0108 07H
DAT4 0109 37H
010A 00H
DAT5 010B 10H
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 162
AX BX CX DXSI di
MAIN PROC NEAR AH AL BH BL CH CL DH DLMOV AX,7745H 77 45MOV BX,0104H 01 04MOV DI,0001 0001MOV SI,0002 0002MOV AL,[BX] 12MOV AH,DAT2[SI] 18MOV AL,DAT1[DI] 48MOV AL,[BX+SI] 18MOV AH,[BX+DI+3] 07H
Address Data
DAT1 0102 2FH
0103 48H
DAT2 0104 12H
0105 10H
0106 18H
DAT3 0107 0A5H
0108 07H
DAT4 0109 37H
010A 00H
DAT5 010B 10H
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 163
Example 12
ORG 100H
STRT: JMP MAIN
blank db 3 DUP (?)
Data1 db 4FH
Data2 db 8CH,5AH,0ACH,93H
Data3 dW 4F59H,7EA3H
Data4 db0F4H,09H,8AH,5CH,6AH
MAIN PROC NEAR
MOV AX,2F8AH
MOV BX,OFFSET Data4
MOV SI,3
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 164
MOV AL,Data1MOV AH,BLMOV AL,Data2+3MOV AX,Data3MOV AL,Data2[SI]MOV AL,[BX+1]MOV AL,[SI+102H]MOV AL,[BX+SI‐1]MOV AL,Data4[SI+2]MOV AL,Data2[SI+5]MOV AX,Data3+1ENDP MAINEND start
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 165
ORG 100H Label Address DataSTRT: JMP MAIN 0100blank db 3 DUP (?) 0101Data1 db 4FH 0102Data2 db 8CH,5AH,0ACH,93H 0103Data3 dW 4F59H,7EA3H 0104Data4 db 0F4H,09H,8AH,5CH,6AH 0105
0106010701080109010A010B010C010D010E010F011001110112
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 166
ORG 100H Label Address DataSTRT: JMP MAIN blank 0100blank db 3 DUP (?) 0101Data1 db 4FH 0102Data2 db 8CH,5AH,0ACH,93H 0103Data3 dW 4F59H,7EA3H 0104Data4 db 0F4H,09H,8AH,5CH,6AH Data1 0105 4F
Data2 0106 8C0107 5A0108 AC0109 93
Data3 010A 59010B 4F010C A3010D 7E
Data4 010E F4010F 090110 8A0111 5C0112 6A
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 167
LabelAddres
sData
blank 01000101010201030104
Data1 0105 4FData2 0106 8C
0107 5A0108 AC0109 93
Data3 010A 59010B 4F010C A3010D 7E
Data4 010E F4010F 090110 8A0111 5C0112 6A
AX BXSI
Address
ModeMAIN PROC NEAR AH AL BH BL
MOV AX,2F8AHMOV BX,OFFSET Data4MOV SI,3MOV AL,Data1MOV AH,BLMOV AL,Data2+3MOV AX,Data3MOV AL,Data2[SI]MOV AL,[BX+1]MOV AL,[SI+102H]MOV AL,[BX+SI‐1]MOV AL,Data4[SI+2]MOV AL,Data2[SI+5]MOV AX,Data3+1
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 168
AX BXSI Address Mode
MAIN PROC NEAR AH AL BH BLMOV AX,2F8AH 2F 8A immediate
MOV BX,OFFSET Data4 01 0E immediate
MOV SI,3 0003 immediate
MOV AL,Data1 4F Direct
MOV AH,BL 0E Reg.
MOV AL,Data2+3 93 Direct
MOV AX,Data3 4F 59 Direct
MOV AL,Data2[SI] 93 Reg. Ind.
MOV AL,[BX+1] 09 Reg. Ind.
MOV AL,[SI+102H] 4F Reg. Ind.
MOV AL,[BX+SI‐1] 8A Reg. Ind.
MOV AL,Data4[SI+2] 8B Reg. Ind.
MOV AL,Data2[SI+5] F4 Reg. Ind.
MOV AX,Data3+1 A3 4F Direct
LabelAddres
sData
blank 01000101010201030104
Data1 0105 4FData2 0106 8C
0107 5A0108 AC0109 93
Data3 010A 59010B 4F010C A3010D 7E
Data4 010E F4010F 090110 8A0111 5C0112 6A
•
Dr. Ahmed ElShafee, ACU : Fall 2018, Microprocessors 169
Thanks,..
Dr. Ahmed ElShafee, ACU : Fall 2019, Microprocessors 170