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
- (x64 Nasm) Writeline function on Linux
- Is the compiler Xcode uses to produce Assembly code a bad compiler?
- Why do we need AX instead of MOV DS, data directly with a segment?
- Bootloader in Assembly with Linux kernel
- How should the byte sequence 0x40 0x55 be interpreted by an x86-64 emulator?
- C++ code into assembly
- Drawing circles of increasing radius
- Assembly print on screen using pop ecx
- Equivalent to asm volatile in Gfortran?
- Show 640x480 BMP image with inline ASM c++
- Keep track of numbers entered in by a user in assembly
- 8086 Assembly Arrays with I/O
- DB ASM variable in Inline ASM C++
- What does Jump to means in callgrind?
- How to convert binary into decimal in assembly x8086?
Related Questions in LABEL
- some labels appear gray in Visual Studio 2010
- Retrieving string value from label and then parsing into an integer, pyqt4
- Stata: Retrieve variable label in a macro
- SAS proc sql - how to read in log of variable but retain the variable's label
- Labelling nodes in networkx
- Trouble dynamically changing state of checkbox with AJAX
- C++ Qt How do you make a label display a movie (gif) that you created using the form?
- JavaFX PiChart, my hover values blink
- JavaFX : Put chemical formula into Label
- Matlab insertObjectAnnotation labels error
- How to concatenate string with line breaks, all to be printed in a single label?
- Matplotlib axis time formatter
- C# : Label is not showing data
- jFreeCharts large number label display
- JavaFX Thread - Error on specific component (Label)
Related Questions in NASM
- (x64 Nasm) Writeline function on Linux
- Assembly print on screen using pop ecx
- Print a number in NASM - building an x86 Bootsector
- nasm: jump when input is NULL
- NASM: Makefile for library
- NASM issue on OSX 64-bit
- In NASM, does one usually use %define for typedefs?
- puts implementation in assembly with nasm x86-64
- assembly - How to boot kernel that is appended end of kernel?
- given hex input should be convert to decimal
- ASM, declaring float variables
- Understanding NASM Macro
- NASM convert Binary number to Decimal
- NASM memory not being accessed correctly?
- Truncation of nasm function returning value
Related Questions in SECTIONS
- How to define layout in AngularJS
- How to use Xamarin Droid Binding for Sectioned Recycler View
- Text in Html does not show correctly
- Should the system clock be set before copying the sections from rom to ram?
- custom list view with section headers
- How to get rid of zeros in the section numbering in LATEX report document class?
- What is the difference between section and label in assembly in NASM?
- How do I include section information in indexPathForSelectedRow
- How to identify the row index and section number of a clicked button in a custom cell inside tableview
- Is it possible align text to both the left and right in a section heading in a tableview?
- Adding subsections of self in the toctree
- link to another section on same page
- Adding background for TableView sections iOS
- Can't display multiple .md files in .rst toctree Sphinx
- Sections in UITableView with Custom Cells
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 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.