Page 1 of 1

AHHHH Old problem haunts again

Posted: Wed Oct 18, 2006 5:30 am
by AndrewAPrice
I rewrote my kernel main source file (main.s) after my old one became too fragmented and unreadable. Here's part of my new main.s:

Code: Select all

use16
org 0x10000

jmp start

; 16-bit includes
....


; boot code here
start:
    jmp   pword 0x08:start_32

use32
start_32:
    ;code continues here
    ...
When ever I try to assemble it, FASM throws a "value out of range" error for "jmp start". I know the position of my start label has nothing to do with it, as "jmp $" also returns a "value out of range" error.

I remember solving this problem before, but after reading over my old source file and the source of various other OS's I really have no idea what to do. Maybe the problem is I'm tired and need some sleep.

Posted: Wed Oct 18, 2006 7:34 am
by Pype.Clicker
any chance you may have a "use32" in one of those #include'd files?

Posted: Wed Oct 18, 2006 9:38 am
by Dex
Do you have any code like this

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Fill free space with zeroes ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

times 510- ($-0)  db 0

;;;;;;;;;;;;;;;;;;;;;;;;;;
;; End of the sector ID ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;

dw 0xaa55
But that give a differant error
or is you org ?????
in the right place ?.

Posted: Wed Oct 18, 2006 10:18 am
by Mikae
Are you sure about value 0x10000 of 'org' directive? This is greater than a segment's size. May be, you meant 0x1000?

Posted: Wed Oct 18, 2006 7:13 pm
by AndrewAPrice
I'm sure it's 0x10000. When I start in realmode, I am starting from 0, and accessing memory as [pointer - 0x10000], but when I enter real mode, memory locations are correct.

I think I may be able to fix it by 'jumping' to '[start - 0x10000]' instead of just 'start'. I'll try it later when I'm home.

Posted: Thu Oct 19, 2006 1:04 am
by Pype.Clicker
MessiahAndrw wrote: I think I may be able to fix it by 'jumping' to '[start - 0x10000]' instead of just 'start'. I'll try it later when I'm home.
jumping to "start - 0x10000" would definitely increase your chances, but beware that "jmp [start - 0x10000]" would just mean "pick a value at memory address (start - 0x10000) and then jump there".

Posted: Fri Oct 20, 2006 8:03 pm
by AndrewAPrice
I fixed it with using

Code: Select all

jmp (start - 0x10000)
Even a simple loop has to be:

Code: Select all

jmp ($ - 0x10000)
:D

Posted: Sat Oct 21, 2006 12:17 am
by Candy
Are you running a 16-bit kernel?

If so, does it happen to run at 0x1000:0x0000?

If so, your org should always equal the second number, in this case that's 0. If you don't, it'll complain.