Thread: assembly

  1. #1
    Registered User
    Join Date
    Aug 2001


    sry, this is an assembler question but i really need a little help here.
    i spent like a day on looking up that info, but no site i found gave me the information i need. most sites just say that there are different address modes, but none says how the assembler differs between those.
    its really sucky that google doesnt support looking up symbols like * & $ etc...

    so: how does the assembler differ between immediates and addresses?
    e.g. jump relative 100 and jump to absolute address 100

    so i have seen things on sites like 100, *100, $100, what do these mean, and are there more of these operators?

    and how can addresses be marked to be relocatable/non-relocatable?

    does anyone know a good assembler forum?

    hm... and does anyone know a site which explains how to create a new segment?
    i mean i somehow need to create a segment descriptor, this descriptor is stored in which table - (global or local descriptor table)? on the other hand i need an selector to access that segment - how is selector obtained? which instructions are involved? and how much of this can i do in which privilege level? like does windows allow an ordinary application (privilege level 3) to create new segments? well i guess yes, but new segments cannot be more privileged than the current privilege level.

    uh well maybe just ignore the second part - if someone could give me a link on that id be very happy, but in the moment i need a quick answer to the first question
    signature under construction

  2. #2
    Join Date
    May 2005
    Not all assemblers use the same syntax, so you'll have to look up what your particular assembler is using. The GNU Assembler (invoked with 'as' in UNIX) uses AT&T syntax, so it works like this:
    movl $200, %eax         # Immediate mode - copy the value 200 to eax
    movl %eax, %ebx         # Register addressing mode - Copy the value in eax
                            # to ebx
    movl 200, %eax          # Direct addressing mode - Copy the value stored at
                            # memory address 200 to eax
    movl (%eax), %ebx       # - Indirect addressing mode (pointers) - Use the
                            # value in eax as an address, and then copy the value
                            # stored at that address to ebx
    movl 4(%ebp), %eax      # - Base pointer addressing mode - Same as indirect
                            # mode, only you use an offset. So this means fetch
                            # the value in ebp as an address, and then add the
                            # offset (4) to that address and copy the value at
                            # that address to eax.
    There's also indexed addressing mode, but it involves at bit more explanation.

    EDIT: fixed the layout breakage
    Last edited by ^xor; 06-26-2005 at 07:29 AM.

  3. #3
    Registered User
    Join Date
    Aug 2001
    thxalot, but what about this:
    	jmp end
    .globl main
    	jmp .data
    so in "function" main i jump to the data section and jump back to the end terminate

    why does
    jmp .data
    compile to (gdb output, btw, is there a way to disassemble a whole program? currently i always type "disassemble main", which only shows code in main)
    0x08048334 <main+0>: jmp 0x804951c <p.0+4>

    what does <p.0+4> mean?
    and since i am jumping to another segment (the data segment) wouldnt this require a far jmp (intersegment jump), thus a selectorffset combo?
    0x804951c looks like an ordinary absolute address. or is it just that gdb resolves the addresses since text and data segments for an executable always exist on the same (virtual) addresses?

    sry for asking all that stuff, but i am pretty much confused on how it works
    e.g in my book it says somthing like:

    if absolute jump
      offset = dest // dest is the operand 
    if offset > segment_limit
      #GP(0) // general protection exception
      eip = offset
    so am i right when:
    jmp 100 means: jump to location segment base + 100? thus 100 is interpreted as relative to the start of the segment?

    so actually my question reduces to how would i do:
    .) jump 100 bytes forward from the CURRENT LOCATION
    .) jump 100 bytes forward from the start of the SEGMENT
    .) jump 100 bytes forward from the start of the VIRTUAL ADDRESS SPACE
    Last edited by Raven Arkadon; 06-26-2005 at 07:52 AM.
    signature under construction

  4. #4
    Registered User
    Join Date
    Aug 2001
    a different question (because all my questions here are offtopic anway i dont start a new post for this)

    1) assembly: what is the meaning of asterisk(*) e.g. jmp *100?

    2) how does the assembler differ between relocatable addresses and absolute addresses?

    does it even make sense having relocatable addresses?
    i mean intrasegment calls/jumps are relative anyway -> thus no relocation needed
    if i refer to the absolte address foo (e.g. refering to the gdi.dll) i use the absolute address which is independing on where my program exisits in memory -> thus again no relocation needed
    so the only reason i can think of for having relocatable addresses is for using them as placeholders for addresses to symbols which were not known when the assembly program was compiled.
    in other words: relocatable addresses are just needed for linking and filling the appropriate addresses in.

    but what are the relocation entries in the exe file format for? i mean they just point to the locations in the file where the origin (address of where the exe is loaded to) needs to be added.

    3) mov %eax, (100)

    is 100 treated as an absolute address (thus address 100 in the virtual address space? or is it 100 bytes from the beginning of the segment which is selected by the ds register (did i understand it right, that all instructions like mov, add, sub, (thus arithmetic stuff) usually refer to the data segment for their data (unless there is an segment override prefix))?)

    oh i guess i cant simply jump to the gdi.dll - i rather need to do that via a call gate so i must do call selector : dummy offset
    signature under construction

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Learning Assembly
    By mrafcho001 in forum Tech Board
    Replies: 5
    Last Post: 03-12-2006, 05:00 PM
  2. C to assembly interface
    By Roaring_Tiger in forum C Programming
    Replies: 4
    Last Post: 02-04-2005, 03:51 PM
  3. assembly language...the best tool for game programming?
    By silk.odyssey in forum Game Programming
    Replies: 50
    Last Post: 06-22-2004, 01:11 PM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  5. C,C++,Perl,Java
    By brusli in forum C Programming
    Replies: 9
    Last Post: 12-31-2001, 03:35 AM