Re: left and right bit shift assembly operators
Sam Hart <[email protected]>
| Newsgroups | gmane.os.opendarwin.general |
|---|---|
| Message-ID | <[email protected]> |
Indira wrote: > Since no-one answered my previous post hey give us some time :) > I want to add more details in regards to this cirtical problem that > we're experiencing. Here's the code snippet (Darwin for i86) that > generates a problem (the last line is the one that the compiler throws > an error on stating that "Relocation error. Absolute 0 assumed": > .file "devio.w" > .text > .long c.false, c.procedure_key > .L4: > .long x.L4, c.false > .long .L9 > .byte 0, 1 > .byte 0, 0 > .value 0 > .byte 14, 13, 0, 12, 0, 0 > .long .L5 > x.L4: > movl $.L4, %ebp > subl $48, %esp > pushl %ebp > .L6: > movl (%ebx), %eax > movl %eax, 4(%esp) > leal 8(%esp), %eax > movl %eax, -4(%ebx) > movl $2, -8(%ebx) > movl $tcgetattr, -12(%ebx) > leal -12(%ebx), %ebx > call c.031call_sys > cmpl $0, (%ebx) > leal 4(%ebx), %ebx > jns .L8 > movl $c.false, -4(%ebx) > leal -4(%ebx), %ebx > jmp .L7 > .L8: > movl $c.true, -4(%ebx) > leal -4(%ebx), %ebx > .L7: > .L5: > addl $52, %esp > movl 4(%esp), %ebp > ret > .align 4 > .LA: > .set .L9, ((.LA - x.L4) >> 2) + 9 > Here is what we know about the problem. > > 1) The bitwise right shift operator is the one that it has a problem > with. If we cut this operation on 3 different lines, the line that > includes the right shift id the one that it will have a problem on. ok, I cannot claim to know what the problem exactly is ( I hate x86 assembler ) but I can tell you what bugs me you are setting the label .L9 to be the address of label .LA ( right before this directive ) minus the address of label x.L4 very near the beginning of your .text section, you are then shifting the sum right by 2 ( dividing by 4 ) and adding 9. Chances are that value is before the .text section, could even be zero. Because x86 has variable sized instructions, it is pure guess work. > 2) The bitwise right shift is documented to work on Integers only. depending of your definition of integer :) > The defintion of L9 variable is stated to be of type long. where is that defined ? > We tried to make this an Integer, but we still experienced the same > trouble afterwards. because it looks like you are storing addresses there > I hope that you can now tell me something that I can do to fix this > problem. you have to work out what the intention of the original code was > Original post: > > We're porting an i86 software (poplog) from Linux for i86 to Darwin. > We're almost done with it, but experience a problem. > > Here's the problem: When we have a set instruction that reads as > following .set .L9, ((.LA-X.L4)>>2)+9, the right shift operator > generates a compile time error stating that " Relocation error. > Absolute 0 assumed". > > The problem is well identified, but we are somewhat clueless in > regards to the solution. Any help is well appreciated. hope this helps, I could be completely wrong I am really more familiar with PPC S a m ------------------------------------------------------- Drawing on my fine command of language, I said nothing.