পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Thursday, January 26, 2017

Assembly - Memory Segments

We have already discussed the 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 −

segment .text    ;code segment
   global_start    ;must be declared for linker 
 
_start:            ;tell linker entry point
   mov edx,len    ;message length
   mov ecx,msg     ;message to write
   mov ebx,1    ;file descriptor (stdout)
   mov eax,4    ;system call number (sys_write)
   int 0x80    ;call kernel

   mov eax,1       ;system call number (sys_exit)
   int 0x80    ;call kernel

segment .data      ;data segment
msg db 'Hello, world!',0xa   ;our dear string
len equ $ - msg          ;length of our dear string
When the above code is compiled and executed, it produces the following result −
Hello, world!

Memory Segments

A segmented 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 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.

No comments:

Post a Comment