Download presentation
Presentation is loading. Please wait.
1
Presentation on Real Mode Memory Addressing
Presented By
2
Real Mode Memory Addressing
The first 1MB memory is Real memory or the Conventional memory * Segment 1 Segment 2 Segment n 0000h CS 8000h DS A000h SS 1MB offset 16 bit Segment registers 1 MB requires 20 bit address Each segment is 64 KB Offset address is 16 bit or 2 byte Actual address = segment address + offset address
3
Real Mode Memory Addressing
Real mode operation allows to address 1MB of memory space – even for the Pentium microprocessor This first 1MB memory is called the real memory or the conventional memory A combination of segment and offset address access the real memory Segment registers contains the beginning address of any 64KB memory segment The offset address selects the any location within the 64KB memory space
4
Segment Plus Offset Determines Address
To get the real address Pad 0H at the end of segment register Add the offset value 10000H F000H 1F000H CS = 1000H Offset = F000H 12340H 245FH 1479FH DS = 1234H Offset = 245FH Since each segment is 64 K, the offset address can take maximum of FFFFH Once, the beginning address is found in segment registers, ending address is calculated by adding FFFFH with the value of segment register after padding 0H after it. From Intel Microprocessor
5
Default Segment and Offset Registers
If CS = 1400H and IP/EIP = 1200 H The microprocessor access instruction from H+ 1200H = 15200H.
6
Allows relocation Suppose 1000H bytes of code 190H bytes of data
Figure 2-4: A memory system showing the placement of four memory segments Suppose 1000H bytes of code 190H bytes of data 200H bytes of stack Allows relocation Figure 2-5
7
Road Map Real Mode Memory Addressing Array, Loop and Accessing Memory
8
Array, Loop and Accessing Memory
DATA DW 50 ; DATA is a word with value 50 DATA1 DW 50 DUP (?) ; array of 50 uninitialized words DATA2 DW 50 DUP (0) ; array of 50 words initialized with 0 50 DATA DATA1 DATA2 Accessing memory MOV AX, 1020h MOV AX, [1020h] MOV [AX], 20 AX 1020h 1021h 0000h 0001h MOV CX, 10 ; loop count XYZ: ; statements LOOP XYZ
9
Example Program 1 Write a program that will initialize 50 bytes array with values 1 to 50 .MODEL SMALL .DATA DATAS DB 50 DUP (?) ; setup array of 50 bytes .CODE ; start of code segment .STARTUP ; start of program MOV AX, 1 MOV CX, 50 ; load counter with 50 MOV BX, OFFSET DATAS ; address of DATAS array AGAIN: MOV [BX], AX ; save values to array positions INC AX ; increment AX to next values INC BX ; increment BX to next elements LOOP AGAIN ; repeat 50 times .EXIT ; exit to DOS END ; end program
10
Example Program 2 Write a program that will initialize 50 bytes array in the following form .MODEL SMALL .DATA DATAS DB 50 DUP (?) ; setup array of 50 bytes .CODE ; start of code segment .STARTUP ; start of program MOV AX, 1 MOV CX, 50 ; load counter with 50 MOV BX, OFFSET DATAS ; address of DATAS array AGAIN: MOV [BX], AX ; save values to array positions INC AX ; increment AX to next values INC BX ; increment BX to next elements LOOP AGAIN ; repeat 50 times .EXIT ; exit to DOS END ; end program 50 DEC decrement
11
Example Program 2, Alternate Way
Write a program that will initialize 50 bytes array in the following form .MODEL SMALL .DATA DATAS DB 50 DUP (?) ; setup array of 50 bytes .CODE ; start of code segment .STARTUP ; start of program MOV AX, 1 MOV DI, 49 MOV CX, 50 ; load counter with 50 MOV BX, OFFSET DATAS ; address of DATAS array AGAIN: MOV [BX+DI], AX ; save values to array positions INC AX ; increment AX to next values DEC DI ; decrement DI LOOP AGAIN ; repeat 50 times .EXIT ; exit to DOS END ; end program
12
Example 3 Move array element 10H into array element 20H **** ***** ***
**** ***** *** ARRAY **** 29H 16 **** .MODEL SMALL .DATA Array DB 16 DUP (?) ; setup array DB 29H DB 30 DUP (?) .CODE .STARTUP ; start of program MOV BX, OFFSET ARRAY ; address of ARRAY MOV DI, 10H ; address element 10H MOV AL, [BX + DI] ; get element 10H MOV DI, 20H ; address element 20H MOV [BX+DI], AL ; save in element 20H .EXIT ; exit to DOS END ; end program Example 3-7: Intel Microprocessors - by Brey
13
Example 3, Alternate Way Move array element 10H into array element 20H
**** 29H 16 **** Example: 3-8, Brey
14
DATA Addressing Modes: Figure 3-2: by Brey
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.