Page 1 of 1

problem to pass from asm to c

Posted: Sun Jul 04, 2021 5:28 am
by Strong214356
hi I am a dev who love try things and I have one project, it's to make an entire os with my friends but I have a problem and I don't know that who can answer it so I put it here:

when my machine start there is an blue screen which is normal but my machine is rebooting again and again I am on linux I use BOCHS os emulator an thats my code, https://github.com/Strong214356/LPOS the first code who load in the bios is bootloader.asm (the comp.sh file is my compiler script tell me if something could be wrong in it) and I am loocking at a youtube serie: https://www.youtube.com/playlist?list=P ... a8l0Jb6l8-

can someone help me or did I have to put my question on an another forum

thanks for your answers

Re: problem to pass from asm to c

Posted: Sun Jul 04, 2021 11:27 pm
by bzt
Welcome to OSDev forum!
Strong214356 wrote:when my machine start there is an blue screen which is normal
No it's not normal. With bochs, you should see messages in white on black background.
Strong214356 wrote:but my machine is rebooting again and again
That's because you made an error which causes an exception, but you haven't set up exception handlers yet, which cause another exception, so you end up with a triple fault, that reboots the CPU.
Strong214356 wrote:I am on linux I use BOCHS os emulator
You can configure bochs to drop you in the debugger in case of a triple fault. It can also print the exceptions, so you can see where the first exception happens. Add these to your bochs.rc file:

Code: Select all

info: action=report
error: action=report
panic: action=ask
If you really are on linux, then these won't work:

Code: Select all

config_interface: win32config
display_library: win32
Replace them with correct drivers.
Strong214356 wrote:I am loocking at a youtube serie: https://www.youtube.com/playlist?list=P ... a8l0Jb6l8-
Yeah, watching a youtube tutorial is not something that you do with OSDev. This isn't a user space application usage kind of thing, developing an OS is very very HARD, and requires lots and lots of knowledge and experience. Watching some video won't substitute that experience.

You probably should start by reading our wiki instead of watching youtube. Here are some links:
- Introduction
- Beginner Mistakes
- Getting Started
- Using Bochs

Now, about your bootloader.asm, there are so many things wrong with it.
- you assume that your code is loaded and executed at 0:0x7C00 (requires ORG 0x7C00), but it could be 0x7C0:0 (requires ORG 0) as well (read more about real mode segmentation to learn why these two result in the same linear address).
- you should start your code with a short jump, some BIOS checks for this
- you haven't set up the segment registers (you can't access data otherwise, and you haven't set up code segment either)
- you haven't set up a stack (you can't use the "call" instruction otherwise)
- you haven't set the CPU flags (most notably the direction and interrupt flags)

Cheers,
bzt

Re: problem to pass from asm to c

Posted: Tue Jul 06, 2021 6:22 pm
by Thunderbirds747
Strong214356 wrote:hi I am a dev who love try things and I have one project, it's to make an entire os with my friends but I have a problem and I don't know that who can answer it so I put it here:

when my machine start there is an blue screen which is normal but my machine is rebooting again and again I am on linux I use BOCHS os emulator an thats my code, https://github.com/Strong214356/LPOS the first code who load in the bios is bootloader.asm (the comp.sh file is my compiler script tell me if something could be wrong in it) and I am loocking at a youtube serie: https://www.youtube.com/playlist?list=P ... a8l0Jb6l8-

can someone help me or did I have to put my question on an another forum

thanks for your answers
Greetings and welcome to OSDev, where we help you understand OSDeving!
You can browse around the Interwebz if you are learning OSDev, Google will most certainly help you, but IOHO (In Our Honest Opinion), it's best you take some courses on YouTube, Codecademy in order to familiarise yourself with programming.
The best way is research source code, the Wiki has some resources to help you get started.
If you don't really know much stuff, no worries, copy and paste, it's totally acceptable here on OSDev Forum!
Bochs uses its own video driver embedded into SeaBIOS, but you can find some BIOS roms on the Web
Thank you,
Timothy. :D