#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    82
    Rep Power
    11

    Registers in assembly


    What are they exactly and how do they work? I can't seem to find any tutorial that goes in depth about it. For example, I have this Hello World program:
    assembly Code:
    section .data
            hello: db 'Hello world!',10
            helloLen: equ $-hello
    section .text
            global _start
    _start:
            mov eax,4
            mov ebx,1
            mov ecx,hello
            mov edx,helloLen
     
            int 80h
     
            mov eax,1
            mov ebx,0
            int 80h

    That's about as far as every tutorial will take me, but I have no idea what's going on here. Can anyone explain to me or link me to something that can help?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    271
    Rep Power
    16
    Spend some time in the architecture section where all the registers are described.

    Intel Programmer Manual

    Assembler syntax varies from one assembler to another in the Intel world, but once you understand the underlying processor architecture, those differences degenerate to just an annoyance.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    To answer your question briefly, a register is a piece of data (typically 32 bits) that the processor has immediate access to. There are very few of them (on the x86 platform, there are 8 general-purpose registers). To manipulate other data in memory, it's therefore customary to move the data into registers, do whatever you want with it there, and then move it back to memory. On some architectures (e. g. SPARC, if I recall), this is the only way to manipulate data in main memory, since the instruction set has no instructions to operate directly on main memory except to move data to and from registers. However, Intel is different, since many instructions can operate on memory directly.

    Take a look at Schol-R-Lea's long list of assembly resources: http://forums.devshed.com/showpost.p...60&postcount=6

    I'm not saying it's the best, but this helped me when I was starting out with x86 assembly: http://www.drpaulcarter.com/pcasm/

    To fully understand the code you posted, you'll need to delve into Linux assembly, since the "int 80h" system call protocol is specific to Linux.

IMN logo majestic logo threadwatch logo seochat tools logo