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.
Hello, i have a project for developping an operating system, i have create all source files and i compeled them but it dosn't work, why?? please help me .
I use DJGPP compiler and LD linker.
boot.asm:
[BITS 16]
[global start]
[extern _main]
jmp 07c0h:start
msg db "Welcom hateM",0
start:
mov ax, cs
mov ds, ax
mov es, ax
printt:
lodsb
cmp al,0
je donee
mov ah,0eh
int 10h
jmp printt
donee:
ret
times 510-($-$$) db 0
dw 0xAA55
system.c (kernel):
#include <dos.h>
#define WHITE 0x07;
unsigned int putchh(char x);
int main(void){
int i;
char *str="Je suis Hatem in My OS .";
for(i=0;i<15;i++){
putchh(str);
}
for (;;);
return 0;
}
unsigned int putchh(char x){
union REGS regs;
regs.h.ah=0x2;
regs.h.al=x;
__asm__(
"int $0x10\n"
);
return 1;
}
First of all, you are trying to build a 16-bit os with a 32-bit compiler. There are several other scary things about your style, but the essence is that you miss one or more keystones in your understanding of the architecture.
"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 ]
Your problem is the "combination" of the regs union and the piece of assembly. These two won't mix and gcc doesn't know that the values in regs union should end in the registers. You have two options:
1.
Use a function (I don't know the name of the function b.t.w.) that handles the regs union and a bios call.
2.
Set the registers using assembly... You may have some trouble with the variable x, but that can be solved this way:
Something like this. For more information, or if this code doesn't compile work (don't blame me, I haven't tested it) I sugest you google for inline assembly in gcc.