flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Main > bootloader doesn't work

Author
Thread Post new topic Reply to topic
luish



Joined: 26 Jan 2018
Posts: 13

bootloader doesn't work

i am writing a bootloader that read the MBR of the OS at sector 7 and jmp to original MBR but instead of do it, my PC freeze.

Code:

start:
MOV AX,201H
MOV BX,0E00H
MOV CX,1
MOV DX,80H
INT 13H
MOV CX,7
MOV AX,301H
INT 13H
MOV CX,1BDH
MOV SI,example
MOV DI,0E00H
REP MOVSB
MOV AX,301H
MOV BX,0E00H
MOV AX,301H
MOV CX,1
INT 13H
RET

example:
MOV AX,201H
PUSH ES
MOV BX,0
MOV ES,BX
MOV BX,7C00H
MOV CX,7
INT 13H
POP ES
cs
jmp bx

codesize:





why my PC freeze when run my code?
Post 26 Jan 2018, 11:03
View user's profile Send private message Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1137

Since that's your first post, welcome to the forums.

Using visual indicators (through int 0x10 or directly writing to video memory) for debugging is usually a good idea. Printing, say, a dot every now and then will tell you exactly where your code is freezing.

It also never hurts to stick to the convention of including the 0x55AA boot signature at the end of the sector.
Post 26 Jan 2018, 20:55
View user's profile Send private message Reply with quote
luish



Joined: 26 Jan 2018
Posts: 13

INT 10h or write at video memory don't help me nothing for me. the problem is that PC is halted when cs change to 0 == 0:7C00h then PC halted. no one video indicators apppears on my display. why PC halt when CS == 0?
Post 29 Jan 2018, 11:10
View user's profile Send private message Reply with quote
luish



Joined: 26 Jan 2018
Posts: 13


Code:
...
example:
MOV AX,201H
PUSH ES
MOV BX,0
MOV ES,BX
MOV BX,7C00H
MOV CX,7
INT 13H
POP ES
cs
jmp bx                    ;when jmp to 0:7c00h windows MBR is started...

codesize:
windows MBR:
XOR     AX,AX
MOV     SS,AX
MOV     SP,7C00
MOV     ES,AX
MOV     DS,AX
MOV     SI,7C00
MOV     DI,0600
MOV     CX,0200
CLD
REPZ                            ;HERE IS WHEN THE PC IS HALTED. WHY IS HALTED HERE ???
MOVSB         


Post 29 Jan 2018, 12:16
View user's profile Send private message Reply with quote
luish



Joined: 26 Jan 2018
Posts: 13

i alredy soved my prblem mysef!!! thanks for none help me at these foruns!!! now i only want to modify the IVT with my bootloader!!! if someone want to hel me..................
Post 05 Feb 2018, 11:14
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2017, Tomasz Grysztar.