Use this code:
#include <stdint.h>
using namespace std;
extern "C" uint32_t magic;
extern "C" void *mbd;
extern "C" void kmain(void)
{
if ( magic != 0x2BADB002 )
{
/* Something went not according to specs. Print an error */
/* message and halt, but do *not* rely on the multiboot */
/* data structure. */
}
/* You could either use multiboot.h */
/* (http://www.gnu.org/software/grub/manual ... boot_002eh) */
/* or do your offsets yourself. The following is merely an example. */
//char * boot_loader_name =(char*) ((long*)mbd)[16];
/* Print a letter to screen to see everything is working: */
unsigned char *videoram = (unsigned char *) 0xb8000;
videoram[0] = 65; /* character 'A' */
videoram[1] = 0x07; /* light grey (7) on black (0). */
}
C++ Bare Bones kmain.cpp Error
- Griwes
- Member
- Posts: 374
- Joined: Sat Jul 30, 2011 10:07 am
- Libera.chat IRC: Griwes
- Location: Wrocław/Racibórz, Poland
- Contact:
Re: C++ Bare Bones kmain.cpp Error
Code: Select all
using namespace std;
It's funny how many people in the world put that line in their code without thinking about it or even knowing what it does... well, less funny when problems arise because of this.
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
Re: C++ Bare Bones kmain.cpp Error
I certainly don't call the bare bones tutorial an "operating system". All it does is print "A" on the screen. If someone wants to copy&paste it, its not much use until they develop it further.cxzuk wrote:I believe the argument is that the wiki should not provide a copy&paste operating system, but provide descriptions of theories, designs and structures.
Whether thats a good goal for the wiki, or if the errorsome code hinders learning of these? Im not sure.
I think the tutorial should definitely work if people follow the instructions. Especially since it is such a simple tutorial. Making a purposeful error in a tutorial will just cause people to post posts saying "The tutorial doesn't work!!!".
Currently developing Lithium OS (LiOS).
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."