Programming, for all ages and all languages.
niou
Posts: 1 Joined: Fri Aug 24, 2012 1:35 am
Post
by niou » Fri Aug 24, 2012 9:16 am
Hello everybody!
I was happily developing my own kernel and it worked great!
But something went wrong...
This code worked:
Code: Select all
void putch (const char character) {
volatile ushort *where;
where = (ushort*)0xb8000 + (1 * 2);
*where = character | (0x0f << 8);
}
But this one didn't!!
Code: Select all
void putch (const char character) {
volatile ushort *where;
ushort x = 1;
where = (ushort*)0xb8000 + (x * 2);
*where = character | (0x0f << 8);
}
While the first code prints the character on the screen, the second does nothing!! ):
Combuster
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:
Post
by Combuster » Fri Aug 24, 2012 12:50 pm
My crystal ball says you're either using CLI;HLT; in a VM or you're not using your compiler properly.
"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 ]
Nable
Member
Posts: 453 Joined: Tue Nov 08, 2011 11:35 am
Post
by Nable » Fri Aug 24, 2012 1:38 pm
Use bochs debugger, use it one more time, do it harder! (:
bluemoon
Member
Posts: 1761 Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong
Post
by bluemoon » Fri Aug 24, 2012 1:43 pm
It may not be the root cause but...
Code: Select all
ushort x = 1;
where = (ushort*)0xb8000 + (x * 2);
You are mixing ushort for pointer arithmetic, it's not a good habit, try:
Code: Select all
uintptr_t x = 1;
where = (uint16_t*)( (uintptr_t)0xb8000 + x*2 );
Love4Boobies
Member
Posts: 2111 Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania
Post
by Love4Boobies » Sat Aug 25, 2012 2:24 am
There's no need for uintptr_t there. But yes, I would also like to complain about using ushort, which doesn't exist.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[
Project UDI ]