Results 1 to 5 of 5

Thread: word bits?

  1. #1

    word bits?

    Hi there, i'm having a few problems shifting a word about. i need to have the first 4 bits equal to 3 and the following 12bits to be an offset

    e.g.

    4bits = 3
    12bits = 2000

    i'm not sure if i am doing it correctly. doesnt seem to work.

    diff = a word value such as 2000

    Code:
    output := (Diff and $FFF) or (3 shl 12);
    any help will be appreciated
    Last edited by Colin; 28-03-2011 at 04:37 PM.

  2. #2
    When you say "first 4 bits" do you then mean most or least significant bits?

    My guess is that you mean least(sounds like you're doing some addressing), which means your code should look like:
    Code:
    output := ((Diff and $FFF) shl 4) or 3;
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3
    hi JSoftware, it is for reloc section of dll, according to documentation

    Code:
    The Block Size field is then followed by any number of Type or Offset field entries. Each entry is a WORD (2 bytes) and has the following structure.
    
    Offset	Size	Field	Description
    0	4 bits	Type	Stored in the high 4 bits of the WORD, a value that indicates the type of base relocation to be applied. For more information, see section 6.6.2, “Base Relocation Types.”
    0	12 bits	Offset	Stored in the remaining 12 bits of the WORD, an offset from the starting address that was specified in the Page RVA field for the block. This offset specifies where the base relocation is to be applied.
    actually the microsoft documentation lacks alot of information..

    note .... the result still seems to be incorrect.
    Last edited by Colin; 28-03-2011 at 06:39 PM.

  4. #4
    Why do you use the offset? I just took a look in the FPC linker code, and it only sets the IMAGE_REL_* 4bit value, and it even puts it in the 4 lowest bits
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  5. #5
    sorry i dont understand what you mean, can you clarify?

    EDIT:
    i think the value is not my problem it seems...i guess i am just writing the reloc block wrong, is there any small samples of outputting the .reloc block? thanks in advance.


    RE-EDIT:
    never mind i solved my problem - it was not this at all, there was missing information inside the ms documentation. thanks anyways.
    Last edited by Colin; 31-03-2011 at 12:47 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •