Help with binary (loops?)

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.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Help with binary (loops?)

Post by Chandra »

abraker95 wrote:Opening a nutshell might be a VERY big struggle, but with a nutcracker or another reasonable tool you can easily get to the good stuff inside... in this case I'm trying to do it with bare hands, with everybody turning their back on me
No, no one is turning their back. That simply is your perception. Searching is the first step to learning, which you obviously lack. How wise is it to chose Turbo C as a tool to develop an OS? I know you've lots of options with compiler (GCC, Watcom C or probably Intel C Compiler) but I'm sure Turbo C comes nowhere in that list. Moreover, you seem to lack dedication and the reason being, if you'd ever glanced at the Wiki, I'm sure you'd have been pointed out to GCC. So, my recommendation here, is to grab a better tool (most of us prefer GNU C Compiler) read its manual, write plenty of user space programs with it and when you're ready, take off.

Best Regards,
Chandra
Last edited by Chandra on Thu Apr 07, 2011 5:34 am, edited 1 time in total.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
abraker95
Member
Member
Posts: 36
Joined: Mon Feb 14, 2011 7:39 am

Re: Help with binary (loops?)

Post by abraker95 »

Then using a MinGW compiler, how do you generate a 16 bit file?
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: Help with binary (loops?)

Post by Combuster »

*waves hand*
They be not the 16-bit apps you are looking for.


Seriously, follow the tutorial before trying to deviate from it.
"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 ]
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Help with binary (loops?)

Post by Chandra »

abraker95 wrote:Then using a MinGW compiler, how do you generate a 16 bit file?
.code16gcc can help to some extent, if used correctly. It tells the GNU assembler to generate 16-bit instructions. But if you plan to run you code on anything before 80386, it won't work. The only remaining option is to drop down to an assembler and take control over your machine.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
abraker95
Member
Member
Posts: 36
Joined: Mon Feb 14, 2011 7:39 am

Re: Help with binary (loops?)

Post by abraker95 »

Isn't Intel 80386 AKA i386 32 bit (the first 32 bit processor by Intel)? So I don't see the connection between the 32 bit processor I have right now and i386 and 16 bit. :?

I know Turbo C allows me to do operations such as write to vid ram, which I've never found how to do in MinGW. That's why I use it instead of MinGW. AT&T ASM is also annoying in MinGW.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Help with binary (loops?)

Post by Solar »

i386 is a synonym for IA32, Intel's 32bit architecture that was introduced with the Intel 80386.

But even a Pentium IV starts in real mode, i.e. running in 16bit mode until triggered to switch to 32bit mode (something most bootloaders can do for you, or you could do yourself with a couple of lines of ASM).

Not being able to figure something out (writing to video mem) is a reason to ask for help. Doing a workaround (TurboC) and then asking how to get the workaround going as you encounter problems will result in people poking you for the core of the problem (writing to video mem...).
Every good solution is obvious once you've found it.
abraker95
Member
Member
Posts: 36
Joined: Mon Feb 14, 2011 7:39 am

Re: Help with binary (loops?)

Post by abraker95 »

Ok, how do you do access vid ram in MinGW using C++?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Help with binary (loops?)

Post by Solar »

Have you had a look at the Wiki?
However, I recommend starting at the Main Page...
Every good solution is obvious once you've found it.
abraker95
Member
Member
Posts: 36
Joined: Mon Feb 14, 2011 7:39 am

Re: Help with binary (loops?)

Post by abraker95 »

Just tried the following:
Printing to Screen
Drawing In Protected Mode

Runtime error... I'm in protected mode. I don't know how to easily switch to real mode.

Translating this: http://wiki.osdev.org/Real_Mode to AT&T might be a pain :(
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: Help with binary (loops?)

Post by Combuster »

abraker95 wrote:Drawing In Protected Mode
Runtime error... I'm in protected mode. I don't know how to easily switch to real mode.
You have the right tutorial for the right mode, and you still want to switch to real mode to execute protected mode code?!

Image

Seriously, OS Development has an IQ requirement. You don't seem to meet it, or you pretend not to meet it as Chandra pointed out. If you either can't or don't want to, both options mean that you're better off doing something else.
"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 ]
abraker95
Member
Member
Posts: 36
Joined: Mon Feb 14, 2011 7:39 am

Re: Help with binary (loops?)

Post by abraker95 »

:shock: :oops:
You have the right tutorial for the right mode, and you still want to switch to real mode to execute protected mode code?!
:?: I guess I need more description on how to do it.

How about putting it baby steps?
Step 1: How to enter the real mode
Step 2: Using C++ write/access vid mem
Step 3: Any compile/link options?
Step 4: Making sure that runtime error won't appear

Honestly I like when stuff are straight forward, having to search all over the place and trying 10+ examples to get the same result gets a bit tiring.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Help with binary (loops?)

Post by gerryg400 »

Writing a simple O/S takes many hundreds (maybe thousands) of man-hours. If you're finding it a 'bit tiring' at this point trying 10+ examples then you have a problem. I'm not sure you will make it.
If a trainstation is where trains stop, what is a workstation ?
abraker95
Member
Member
Posts: 36
Joined: Mon Feb 14, 2011 7:39 am

Re: Help with binary (loops?)

Post by abraker95 »

Writing a simple O/S takes many hundreds (maybe thousands) of man-hours. If you're finding it a 'bit tiring' at this point trying 10+ examples then you have a problem. I'm not sure you will make it.
I think there is a difference between searching and coding.
It is also on the wiki.
Where do you see THESE baby steps in there:
Step 1: How to enter the real mode
Step 2: Using C++ write/access vid mem
Step 3: Any compile/link options?
Step 4: Making sure that runtime error won't appear
You gave me asm not c++
User avatar
Karlosoft
Member
Member
Posts: 277
Joined: Thu Feb 14, 2008 10:46 am
Location: Italy
Contact:

Re: Help with binary (loops?)

Post by Karlosoft »

If you read the articles perhaps you can find the information you need.
http://wiki.osdev.org/Real_mode
Go a bit down, there is the code to return in real mode. Oh yes no C++ code here, some operation are better performed in ASM.
Step 2: Using C++ write/access vid mem
With a pointer? The video mem is mapped in your ram at the addresses you can find in the wiki
However... 0xb8000 physical address for textual modes and 0xa0000 for graphic modes. This is all.

I used TCC too to write my bootoloader, but I got no error at compiling time and linking time. Can you show us your current configuration?
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Help with binary (loops?)

Post by neon »

I think there is a difference between searching and coding.
Yes, and programming involves both. Get used to it.
Step 1: How to enter the real mode
The CPU starts in real mode. Unless you have already entered protected mode, there is no reason nor necessity to enter real mode.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Post Reply