AHHHH Old problem haunts again

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

AHHHH Old problem haunts again

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Post by Pype.Clicker »

any chance you may have a "use32" in one of those #include'd files?
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post 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 ?.
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Post by Mikae »

Are you sure about value 0x10000 of 'org' directive? This is greater than a segment's size. May be, you meant 0x1000?
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post 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.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Post 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".
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post 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
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post 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.
Post Reply