Sunteți pe pagina 1din 12

Introduction to Program Segment

a typical Assembly Language Program consists of at least three segments; a code segment (CS), a data segment (DS), and a stack segment (SS). Code Segment (CS) contains the assembly language instructions that perform the tasks that the program was designed to accomplish.

Data Segment (DS) is used to store information that needs to be processed by the instructions in the code segment. Stack Segment (SS) is used to store information temporarily. Segment is an area of memory that includes up to 64k byte. And begins on an address evenly divisible by 16.

TYPES OF ADDRESSES: Physical Address/Linear Address is the 20-bit address that is actually put on the address pins of the 8086 microprocessors and decode by the memory interfacing circuity. actual physical location in the RAM/ROM within the one megabyte memory range. Range 00000h FFFFFh

Offset Address is a location within a 64k byte segment range. range 0000h FFFFh Logical Address consisting of a segment value and an offset address.

Segmentation Steps: 1) Multiply the segment address by 10h. 2) Add the product by the offset address. Alternative steps: 1) Start with the segment 2) Shift left the segment 3) Add the offset address

Part I- Code Segment Logical Address is formed by CS:IP Example: Compute for the Physical or Linear Address of 2500:95F3 Solution: Interpretation: 2500 * 10h The microprocessor 25000 will retrieve the instruction + 95F3 from memory location 2E5F3 starting at 2E5F3.

Alternative: 1) Start with the Segment 2 5 0 2) Shift left the segment 2 5 0 0 3) Add the offset 2 E 5 F

0 0 3

Logical Address Range 2500:up to 2500:FFFF Lowest Address Location 25000H(25000+0000) Highest Address Location 34FFFH(25000+FFFF)

LITTLE ENDIAN CONVENTION


Example: Show how the data are located in the data segment using Little Endian Convention. MOV Ax,88FFh ; load 88FF into Ax MOV [1500],Ax ; copy the contents of Ax to offset 1500h Answer: DS: 1501 88 DS: 1500 FF

Part II- Data Segment Logical Address is formed by DS:offset Example 1: Assume that DS is 5000 and the offset is 1950. Calculate the physical address of the byte. Solution: 1) Start with segment 5 0 0 0 2) Shift left the segment 5 0 0 0 0 3) Add the offset address 5 1 9 5 0

example 2: If the DS= 7FA2H and the offset is 438E. a) Calculate the physical address 7FA2 * 10h 7FA20 + 438E 83DAE

b) Calculate the lower range. 7FA2 * 10h 7FA20 + 0000 7FA20 7FA20(7FA20+0000)

c) Upper range 7FA20+FFFF

Part III- Stack Segment Logical Address is formed by SS:SP Example: If SS= 3500h and SP= FFFFEh a) calculate the b) calculate the physical address of lower range: the stack: 3500 3500 *10h * 10h 35000 35000 +0000 + FFFE 35000 44FFE 35000(35000+0000)

S-ar putea să vă placă și