How to boot your C++ code

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
MazyCrazy
Posts: 4
Joined: Fri Mar 24, 2017 8:10 am
Libera.chat IRC: MazyCrazy

How to boot your C++ code

Post by MazyCrazy »

Hello.
I had read this publication: http://viralpatel.net/taj/tutorial/hell ... loader.php , but didn't find, how to boot another code (in second sector).
How does the loader know where it is? How can I make a jump from one sector to another?
Thanks in advance.
starmanz
Posts: 17
Joined: Sat Mar 18, 2017 4:52 am

Re: How to boot your C++ code

Post by starmanz »

I don't suggest you use C++ when you are a beginner. Try out Wikipedia's INT 13h references. Look for stuff on Google.

This will help you with loading kernels in Assembly.

INT 13h AH=02h: Read Sectors From Drive

Parameters:

AH 02h
AL Sectors To Read Count
CH Cylinder
CL Sector
DH Head
DL Drive
ES:BX Buffer Address Pointer

Results:

CF Set On Error, Clear If No Error
AH Return Code
AL Actual Sectors Read Count

If you don't know Assembly, learn it.
AX BX CX DX BP SP SI DI. The registers that never die. 16-bit... will always sit... in a book where people look. My signature is terrible! I think we all know that.
MazyCrazy
Posts: 4
Joined: Fri Mar 24, 2017 8:10 am
Libera.chat IRC: MazyCrazy

Re: How to boot your C++ code

Post by MazyCrazy »

I know masm, but I did not work with such a low level. You can write how to start C++ from Assembly.
starmanz
Posts: 17
Joined: Sat Mar 18, 2017 4:52 am

Re: How to boot your C++ code

Post by starmanz »

Microsoft Assembler (MASM) doesn't have the same syntax than what operating system development has.

For example, we have invoke box and things.
NASM and FASM (with os development) doesn't have .code or .data if you know what I mean.
AX BX CX DX BP SP SI DI. The registers that never die. 16-bit... will always sit... in a book where people look. My signature is terrible! I think we all know that.
MazyCrazy
Posts: 4
Joined: Fri Mar 24, 2017 8:10 am
Libera.chat IRC: MazyCrazy

Re: How to boot your C++ code

Post by MazyCrazy »

I know!!! Now I am using NASM. Please, answer the question.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: How to boot your C++ code

Post by iansjack »

You are beginning to sound impatient and a little demanding. This is rarely a productive attitude.

Starmanz answered your question in his first reply to you. You use "int 0x13" to load the sector to wherever you choose in memory. Then you use the appropriate "jmp" instruction to transfer control to it.

You might find more productive to follow the "bare bones" tutorials in this Wiki rather than the one you quoted. Although, IMO, all these tutorials just lead people to think they are writing an operating system when they are doing nothing of the sort. You really need to study a lot of theory first to make sure you know what it is that you want to do and what is necessary to achieve that aim. Then you can start how to actually tackle the problem on your own rather than just cutting and pasting questionable code.
starmanz
Posts: 17
Joined: Sat Mar 18, 2017 4:52 am

Re: How to boot your C++ code

Post by starmanz »

Also, copying and paste from tutorials is not recommended. Did Tim Patterson find a YouTube (made in 2004) video to make an operating system? No, he learnt Assembly.

Tim Patterson made x86 DOS.

You need to learn Assembly first. Just copying and pasting will get you nowhere and if you steal someone's code (depending on the license), you're probably breaking laws.

Also, you can't really boot C++ code. There always must be some Assembly.
I encourage you to learn. I am starting to learn Win32 (MASM) Assembly as well.
Check out DOS Assembly since that can be good to learn about interrupts and things.

I'm still in early stages with my Assembly but I know something.
AX BX CX DX BP SP SI DI. The registers that never die. 16-bit... will always sit... in a book where people look. My signature is terrible! I think we all know that.
Post Reply