I am currently studying assembly through NASM assembler and I get
stuck in the difference between section and label. I
understood that section .dat, .bss or .text are used as a
standard to declaration or initialization of variables and as a linker hook
such as main() in C. But also, labels are used to assign a
section in the code. So what is the obscure truth behind this?
What is the difference between section and label in assembly in NASM?
3.7k Views Asked by ovrwngtvity At
        	1
        	
        
	There are 1 best solutions below
Related Questions in ASSEMBLY
- php Variable name must change in for loop
 - register_shutdown_function is not getting called
 - Query returning zero rows despite entries existing
 - Retrieving *number* pages by page id
 - Automatically closing tags in form input?
 - How to resize images with PHP PARSE SDK
 - how to send email from localhost using codeigniter?
 - Mariadb max Error while sending QUERY packet PID
 - Multiusers login redirect different page in php
 - Imaginary folder when I use "DirectoryIterator" in PHP?
 
Related Questions in LABEL
- php Variable name must change in for loop
 - register_shutdown_function is not getting called
 - Query returning zero rows despite entries existing
 - Retrieving *number* pages by page id
 - Automatically closing tags in form input?
 - How to resize images with PHP PARSE SDK
 - how to send email from localhost using codeigniter?
 - Mariadb max Error while sending QUERY packet PID
 - Multiusers login redirect different page in php
 - Imaginary folder when I use "DirectoryIterator" in PHP?
 
Related Questions in NASM
- php Variable name must change in for loop
 - register_shutdown_function is not getting called
 - Query returning zero rows despite entries existing
 - Retrieving *number* pages by page id
 - Automatically closing tags in form input?
 - How to resize images with PHP PARSE SDK
 - how to send email from localhost using codeigniter?
 - Mariadb max Error while sending QUERY packet PID
 - Multiusers login redirect different page in php
 - Imaginary folder when I use "DirectoryIterator" in PHP?
 
Related Questions in SECTIONS
- php Variable name must change in for loop
 - register_shutdown_function is not getting called
 - Query returning zero rows despite entries existing
 - Retrieving *number* pages by page id
 - Automatically closing tags in form input?
 - How to resize images with PHP PARSE SDK
 - how to send email from localhost using codeigniter?
 - Mariadb max Error while sending QUERY packet PID
 - Multiusers login redirect different page in php
 - Imaginary folder when I use "DirectoryIterator" in PHP?
 
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
 - Is it possible to use adb commands to click on a view by finding its ID?
 - How to create a new web character symbol recognizable by html/javascript?
 - Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
 - Heap Gives Page Fault
 - Connect ffmpeg to Visual Studio 2008
 - Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
 - How to avoid default initialization of objects in std::vector?
 - second argument of the command line arguments in a format other than char** argv or char* argv[]
 - How to improve efficiency of algorithm which generates next lexicographic permutation?
 - Navigating to the another actvity app getting crash in android
 - How to read the particular message format in android and store in sqlite database?
 - Resetting inventory status after order is cancelled
 - Efficiently compute powers of X in SSE/AVX
 - Insert into an external database using ajax and php : POST 500 (Internal Server Error)
 
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
 - How can I remove a specific item from an array in JavaScript?
 - How do I delete a Git branch locally and remotely?
 - Find all files containing a specific text (string) on Linux?
 - How do I revert a Git repository to a previous commit?
 - How do I create an HTML button that acts like a link?
 - How do I check out a remote Git branch?
 - How do I force "git pull" to overwrite local files?
 - How do I list all files of a directory?
 - How to check whether a string contains a substring in JavaScript?
 - How do I redirect to another webpage?
 - How can I iterate over rows in a Pandas DataFrame?
 - How do I convert a String to an int in Java?
 - Does Python have a string 'contains' substring method?
 - How do I check if a string contains a specific word?
 
                        
Well, there's a nice Manual, you know. http://www.nasm.us if you haven't got it.
It matters which output format you're using - the
-fswitch. In general...sectionandsegmentare aliases, they do the same thing. They are not case sensitive, you can useSEGMENTif you want to. Most output formats (not-f obj) have "known names" -.text,.data,.bss(and a few more). These are case sensitive -section .TEXTmay not do what you want. Typically,section .textis executable, but read-only. Attempting to write to it will cause a segmentation fault (or whatever Windows calls it - GPF?).section .datais for your initialized data -msg db "Hello World!", 0orfrooble_count dd 42.section .bssis for uninitialized data it only reserves space in memory - and is not included in the disk file. You can only use the "reserve" pseudo-instructions there -resb,resw,resd, etc. The parameter after it indicates how many bytes (etc.) you want to reserve. In-f binoutput format there are no sections/segments (that's what makes it a "flat binary") - Nasm just makes.textfirst, moves.dataafter it, and.bsslast - you can write 'em in any order you want.Labels do NOT define a section! Nasm just translates them to numbers - the address where they occur in your code - and that's what appears in your executable. You can use a label as a variable name, or as a point in your code that you might want to
callorjmpto. All the same to Nasm. Some assemblers "remember" the size you said a variable was, and will throw an error if you try to use it wrong. Nasm has amnesia - you can domov [mybyte], eaxwithout complaint. Sometimes this is useful, more often it's an error. A variable that's "too big" is generally not a problem - a variable that's "too small" can cause an error, which often doesn't show up until later. Tough to debug! A label may not start with a decimal digit (and a number must start with a decimal digit). A label that starts with a period (dot) is a local label. Its scope is from the last non-local label to the next non-local label. See the Friendly Manual for (much) more detail - this is just an intro.The word "main" doesn't mean anything special to Nasm, but is known to C (if you're linking against C). Some compilers spell it
main, some_main, some (OpenWatcom) even spell itmain_. It is the entrypoint - where execution starts when control is passed to your program. It does not need to be the first thing insection .text- but should be in that section, and should be declared "global" to tell the linker about it. "_start" is the default entrypoint for Linux (etc.). Unlike "main" it is notcalled, so you can'tretfrom it. Another name can be used, but you'll need to tell ld about it (-e myentry). It too should beglobal.That's enough for now. See the Manual, and come back if (Ha!) you have other questions.