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 answers
Related Questions in ASSEMBLY
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- How to call a C language function from x86 assembly code?
- Binary Bomb Phase 2 - Decoding Assembly
- AVR Assembly Clock Cycle
- Understanding the differences between mov and lea instructions in x86 assembly
- ARM Assembly code is not executing in Vitis IDE
- Which version of ARM does the M1 chip run on?
- Why would %rbp not be equal to the value of %rsp, which is 0x28?
- Move immediate 8-bit value into RSI, RDI, RSP or RBP
- Unable to run get .exe file from assembly NASM
- DOSbox automatically freezes and crashes without any prompt warnings
- Load function written in amd64 assembly into memory and call it
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- running an imf file using dosbox in parallel to a game
Related Questions in LABEL
- How to Make MUI TextField label behave as default whilst having a Start Input Adornment
- Are C labels instructions or constants
- How to label each points in seaborn catplot with y values
- Why cannot I set font of `xlabel` in `plotmf` in MATLAB?
- Adjust labels on individual nodes in Sankey diagram using ggsankey
- Predict numbers from labeled images
- How to apply style if an input field is empty just only using CSS?
- How to retrieve the row/column names of a matrix in DolphinDB?
- How do I import images and labels stored in 2 different folders?
- Improve accuracy of yolov8 model
- Change font size for ggplot2 figures (axes titles, labels and numbers)
- Labels not Displaying on Scatterplot?
- How to number equations in braces
- Prometheus relabeling configureation incremental counter
- How to specify different colors for column labels in altair
Related Questions in NASM
- Is there some way to use printf to print a horizontal list of decrementing hex digits in NASM assembly on Linux
- scanf in x64 NASM results in segfault
- Seeking for the the method for adding the DL (data register) value to DX register
- Unable to run get .exe file from assembly NASM
- link.exe unresolved external symbol _mainCRTStartup
- x86 Wrote a boot loader that prints a message to the screen but the characters are completely different to what I expected
- Why do register arg values need to be re-assigned in NASM after an int 0x80 system call?
- Why does shr eax, 32 not do anything?
- Behavior of the adress 0x7e00 in different sectors and their alternatives
- No BIOS output from sector 1
- kernel.asm:60: error: comma, colon, decorator or end of line expected after operand
- New to Assembly, trying to get a loop working
- x86 BIOS stage 1 boot code halting after loop from interrupt
- Calling CreateWindowEx from x64 assembly
- Setting up Segment Registers, x86
Related Questions in SECTIONS
- Sections not displaying underneath
- fixed header,sidebar, footer with scrollable center for text, using menu link to load an outside html file into scrollable arae only
- Hello, I have an error on all of my products it says Liquid error (sections/main-collection-product-grid line 104): internal
- Click accepting everywhere on a section to open and close section
- How am I supposed to use the footer-component outside of the slider component
- Load course sections dynamically in moodle
- How to create separate prologue and epilogue for functions in gcc?
- Could you indicate the shapefile of Montevideo?
- Is there a way to collapse multiple functions at once but not all of them in vscode?
- NASM pads section to 512 bytes
- Create collapsible / nested menu on List Page in HUGO Site Generator
- How to show different sections of website separately on scroll
- Workaround to linker script "INSERT BEFORE" with GNU gold
- Multiple section query with section wise ordering in Craft CMS
- How can I make a snap scroller in a web page's inner section use the parent scroller when it reaches its start or end position?
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?
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)
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.