I am compiling and running binaries (boot sector, stage 1, stage 2) for practice. The boot sector is asm and the first stage is asm which run fine. The second stage loads at 0x1000 and I have some asm which jumps to the start of my C Code. My jumps and calls seem to be off (short) by two bytes.
I have tried the code in Bochs and Qemu (stepping through it). All the code looks good. I have even disassembled it in IDA and every looks good. I assume it might be my lack of code alignment knowledge.
The 2nd stage starts at 0x1000:
0x1000: cli
0x1001: xor eax,eax
0x1003: mov eax,0x1f1a
0x1008: mov esp,eax
0x100a: sti
0x100b: jmp 0x1010
The first jump lands at 0x1010 (this is disassembled C code):
0x1010: push 0x16b4
0x1015: call 0x14ca <---
0x101a: add esp,0x4
0x101d: jmp 0x101d
The call above to 0x14CA actually lands at 0x000014c9, two bytes short.
As in the above code, I expect the jump or call to land at the operand address, but it always misses short by two bytes.