i'm italian, so, my english is poooor !!
i've a problem...a big problem....
well, this is my code:
video.cpp
Code: Select all
//Video.cpp
#include "video.h"
Video::Video()
{
pos=0 ; off=0 ;
videomem = (unsigned short*) 0xb8000 ;
}
Video::~Video() {}
void Video::clear()
{
unsigned int i;
for(i=0; i<80>=80)
{
pos=0 ;
off += 80 ;
}
if(off>=(80*25))
{
clear() ; //should scroll the screen, but for now, just clear
}
videomem[off + pos] = (unsigned char) c | 0x0700 ;
pos++ ;
}
Code: Select all
//Video.h
#ifndef VIDEO_H
#define VIDEO_H //so we don't get multiple definitions of Video
class Video
{
public:
Video() ;
~Video() ;
void clear() ;
void write(char *cp) ;
void put(char c) ;
private:
unsigned short *videomem ; //pointer to video memory
unsigned int off ; //offset, used like a y cord
unsigned int pos ; //position, used like x cord
}; //don't forget the semicolon!
#endif
Code: Select all
//Kernel.cpp
#include "video.h"
int main(void)
{
Video vid ; //local, (global variables need some Run-Time support code)
vid.put('p');
vid.write("hi all") ;
while(1);
}
Code: Select all
; Loader.asm
[BITS 32] ; protected mode
[global start]
[extern main] ; this is in our C++ code
start:
call main ; call int main(void) from our C++ code
cli ; interrupts could disturb the halt
hlt ; halt the CPU
Code: Select all
/* Link.ld */
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
i compile c++ source with -nostdlib -fno-builtin -fno-rtti -fno-exceptions
and link them with -Tlink.ld
look the Kernel.cpp, the instruction vid.put('p'); work, but the instruction vid.write("hi all"); does not work (i have the reboot of pc).
now look video.cpp, and function write, I thought in an error in the cycle (for) so i try to comment all like this
Code: Select all
void Video::write(char *cp)
{
// char *str = cp, *ch;
// for (ch = str; *ch; ch++) put(*ch);
}
remember that i'm italian, my english....is poor !!
can anyone help me ??
or
anyone can help me ??