How to stop infinite loop?

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
gabemaiberger
Member
Member
Posts: 40
Joined: Tue Nov 13, 2012 2:54 pm

How to stop infinite loop?

Post by gabemaiberger »

Hey I got a problem, my os is stuck at this one line of code

Code: Select all

jmp 0x200
it is meant to jump beyond the boot sector but it just loops infinitely.

Code: Select all

var myCat="marshmallow"
linguofreak
Member
Member
Posts: 510
Joined: Wed Mar 09, 2011 3:55 am

Re: How to stop infinite loop?

Post by linguofreak »

Without seeing more code than that we can't say anything.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: How to stop infinite loop?

Post by Nessphoro »

Receive an interrupt, change EIP.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: How to stop infinite loop?

Post by bluemoon »

gabemaiberger wrote:Hey I got a problem, my os is stuck at this one line of code

Code: Select all

jmp 0x200
it is meant to jump beyond the boot sector but it just loops infinitely.
No, the jmp itself do not perform loop.
It's like asking how to avoid blowing up a house, ignite the kitchen cooker is meant to have cooking fire but it just explode. :lol:

The problem lies on other things. What is on 0x200? it look like executing random garbage.
gabemaiberger
Member
Member
Posts: 40
Joined: Tue Nov 13, 2012 2:54 pm

Re: How to stop infinite loop?

Post by gabemaiberger »

I actually changed my code up a bit so my next problem is how to find my bootloader on the disk. It is supposed to be in the first nine sectors of a floppy disk but it can't find "BOOTLOAD.BIN". Here is some code.

Code: Select all

mov cx, WORD [0x0080]
mov di, 0x0200
.LOOP:
push cx
mov cx, 0x000C ;length of filename
mov si, ImageName ;move image name into si
push di
rep cmpsb
pop di
je LOAD_FILE
pop cx
add di, 0x0020
loop .LOOP
jmp FAILURE

LOAD_FILE:
mov si, msgCRLF
call DisplayMessage
mov dx, WORD [di + 0x001A]
mov WORD [cluster], dx
mov ax, 0x0100
mov es, ax
mov bx, 0
xor cx, cx
mov cl, BYTE[SectorsPerCluster]
mov ax, WORD[cluster]
call ClusterLBA
call ReadSectors
jmp DONE

Code: Select all

var myCat="marshmallow"
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to stop infinite loop?

Post by Combuster »

gabemaiberger wrote:It is supposed to be in the first nine sectors of a floppy disk
My crystal ball says it isn't. How are you trying to get it there?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
gabemaiberger
Member
Member
Posts: 40
Joined: Tue Nov 13, 2012 2:54 pm

Re: How to stop infinite loop?

Post by gabemaiberger »

by combining all code into boot.bin and using

Code: Select all

dd if=boot.bin of=/dev/sdf

Code: Select all

var myCat="marshmallow"
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: How to stop infinite loop?

Post by bluemoon »

There is not enough information for anyone to guess what's wrong.

How do you pack all the things into boot.bin? Did you verify it, and how?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: How to stop infinite loop?

Post by Combuster »

floppy disk
(...)
/dev/sdf
Sounds like you're using an USB mass storage device rather than a true floppy drive.

Other than that, playing hide and seek with your code is not going to get you an answer really fast. People already start ignoring this thread because it has too many replies.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply