Search code examples
assemblycallobject-code

Why do assembly call address have 0xFBFFFFFF added to them?


Ok so I am writting an assembler for an OS I am developing. It is coming along great I have about all mov instructions and now I want to implement instructions like call and jmp. I really do not have good documentation so I am looking at machine code generated by NASM to find out opcodes and such. I wanted to see what the opcode for call was so I compiled some code that started with a label at the begging. I expected the address after the call opcode to be 00 00 00 00 but it was FB FF FF FF. I thought it had to do with the symbols so I compiled code with call 0x000000 to see what happened and the address was exactly the same (0xFBFFFFFF). Can someone explain this to me I am confused.


Solution

  • Showing the actual code you are disassembling would be useful. Most likely that number is a little-endian negative offset. 0xFFFFFFFB = -5 in 2s complement. Did you write:

    Label: call Label
    

    If call is a 1-byte opcode with a 4-byte relative offset that would make sense.