ALT by Bilal Ahmed Shaik - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

img24.png

 

  Assembly Memory Segments

 

  We have already discussed three sections of an assembly program. These sections represent various memory segments as well.

 

  Interestingly, if you replace the section keyword with segment, you will get the same result. Try the following code:

 

img25.png

 

  When the above code is compiled and executed, it produces fol owing result:

 

img26.png 

  Memory Segments

 

  A segm ented memory model divides the system memory into groups of independent segments, referenced by pointers located in the segment registers. Each segment is used to contain a specific type of data. One segment is used to contain instruction codes, another segment stores the data elements, and a third segment keeps the program stack.

 

  In the light of the above discussion, we can specify various memory segments as:

 

   Data segment - it is represented by .data section and the .bss. The .data section is used to declare BILAL AHMED SHAIK

the memory region where data elements are stored for the program. This section cannot be expanded after the data elements are declared, and it remains static throughout the program.

 

  The .bss section is also a static memory section that contains buffers for data to be declared later in the program. This buffer memory is zero-filled.

Code segment - it is represented by .text section. This defines an area in memory that stores the instruction codes. This is also a fixed area.

Stack - this segment contains data values passed to functions and procedures within the program.