how to jump from bin to obj?
Posted: Thu Mar 26, 2009 11:35 am
Target: I want to change to a C-Kernel
Status:
I have four files:
1) bootloader (512 Byte) starting at 7C00h by boot signature, asm ->bin format
2) kernel part I: org 8000h, switching on A20 and to PM, asm -> bin format (filled with HLT to 1024 byte) http://www.henkessoft.de/OS_Dev/OS_Dev1 ... ocId412221
3) kernel part II: asm -> obj-Format, global start, jump to main
4) kernel part III: C -> obj
OK:
a) files 3 + 4 are linked with ld to bin format
b) the three binaries (boot, I, II+III) are merged by copy and sent to floppy disk
c) bootloader jumps to 8000h (I), next jump has to be done directly (e.g. jmp 0x08:0x86e3)
d) II calls III by _main
My problem:
kernel part I (bin) is not allowed to use "extern start " and jump to start, not allowed for binaries; I cannot assemble to object format, not allowed due to org (important).
Work-around: I look up the hex address of start in the binary, and jump direct to this address from 2 to 3. This works, but address changes.
File 1 & 2 are described in my tutorial, and work perfect.
Now I use for file II:
But I cannot jump to this (global) start by file I.
Hence, I use these three HLT. I find them in the Binary by f4f4f4 and jump directly to this address.
Please carry me out from this deadlock.
Must-be: Kernel I starts with 'org 0x8000'
Status:
I have four files:
1) bootloader (512 Byte) starting at 7C00h by boot signature, asm ->bin format
2) kernel part I: org 8000h, switching on A20 and to PM, asm -> bin format (filled with HLT to 1024 byte) http://www.henkessoft.de/OS_Dev/OS_Dev1 ... ocId412221
3) kernel part II: asm -> obj-Format, global start, jump to main
4) kernel part III: C -> obj
OK:
a) files 3 + 4 are linked with ld to bin format
b) the three binaries (boot, I, II+III) are merged by copy and sent to floppy disk
c) bootloader jumps to 8000h (I), next jump has to be done directly (e.g. jmp 0x08:0x86e3)
d) II calls III by _main
My problem:
kernel part I (bin) is not allowed to use "extern start " and jump to start, not allowed for binaries; I cannot assemble to object format, not allowed due to org (important).
Work-around: I look up the hex address of start in the binary, and jump direct to this address from 2 to 3. This works, but address changes.
File 1 & 2 are described in my tutorial, and work perfect.
Now I use for file II:
Code: Select all
[BITS 32]
[global start]
[extern _main] ; this is in the c file
hlt
hlt
hlt
start:
call _main
jmp $
Hence, I use these three HLT. I find them in the Binary by f4f4f4 and jump directly to this address.
Please carry me out from this deadlock.
Must-be: Kernel I starts with 'org 0x8000'