build.bat
Code: Select all
nasm -f aout ot.asm -o entry.o
gcc -c ot.c -o ot.o
ld -T link.ld -o OT.SYS entry.o ot.o
copy OT.SYS A:\OT.SYS
pause
Code: Select all
bits 16 ; we are still in real mode
global start
extern _k_main
; we are loaded at linear address 0x10000
start:
call _k_main ;call our c source
cli
hlt ;stop execution
Code: Select all
void k_clear_screen();
unsigned int k_printf(char *message, unsigned int line);
k_main() // like main in a normal C program
{
//k_clear_screen();
k_printf("Starting OT-DOS..", 0);
};
void k_clear_screen() // clear the entire text screen
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
while(i < (80*25*2))
{
vidmem[i]=' ';
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
unsigned int k_printf(char *message, unsigned int line) // the message and then the line #
{
char *vidmem = (char *) 0xb8000;
unsigned int i=0;
i=(line*80*2);
while(*message!=0)
{
if(*message=='\n') // check for a new line
{
line++;
i=(line*80*2);
*message++;
} else {
vidmem[i]=*message;
*message++;
i++;
vidmem[i]=WHITE_TXT;
i++;
};
};
return(1);
};
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x010000 : {
code = .; _code = .; __code = .;
*(.text)
}
.data : {
data = .; _data = .; __data = .;
*(.data)
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
}
end = .; _end = .; __end = .;
}