I'm writing a os (not very original) and i have a boot sector wich work fine,
a kernel loader wich work fine, a kernel wich work fine but ... it dosn't see my string.
here is my kernel :
Code: Select all
void ADNos_main(){
char *video = ( char *)0xB8000;
const char *message = "ADN.os first boot ! :)";
const long size = 80*25;
long loop;
//clear the screen
for (loop=0; loop<size; loop++) {
*video++ = 0;
*video++ = 0x1;
}
// test first character
video = (char *)0xB8000;
int i = 0;
char c = message[0];
if(c=='A')
{
*(video+160) = 'O';
*(video+161) = 0xf;
*(video+162) = 'K';
*(video+163) = 0xf;
}else
{
*(video+160) = 'K';
*(video+161) = 0xf;
*(video+162) = 'O';
*(video+163) = 0xf;
}
// dysplay message
while(c!='\0')
{
*video++ = c;
*video++ = 0xf;
c = message[i++];
}
while(1);
}
Code: Select all
gcc -c ./kernel/kernel.c -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -o ./bin/kernel.o
ld -i -e ADNos_main -Ttext 0x100000 -o ./bin/kernel.tmp ./bin/kernel.o -M ./bin/kernel.tmp > kernel.map
objcopy -R .note -R .comment -R .indent -R .stab -R .stabstr-S -O binary ./bin/kernel.tmp ./bin/kernel.bin
The test for the first character is KO
and the message is never displayed
The command "ndisasm ./bin/kernel.bin -u"
give :
Code: Select all
00000000 53 push ebx
00000001 BA00800B00 mov edx,0xb8000
00000006 BB00000000 mov ebx,0x0
0000000B B8CF070000 mov eax,0x7cf
00000010 C60200 mov byte [edx],0x0
00000013 42 inc edx
00000014 C60201 mov byte [edx],0x1
00000017 42 inc edx
00000018 48 dec eax
00000019 79F5 jns 0x10
0000001B BA00800B00 mov edx,0xb8000
00000020 B900000000 mov ecx,0x0
00000025 0FB603 movzx eax,byte [ebx]
00000028 3C41 cmp al,0x41
0000002A 751E jnz 0x4a
0000002C C605A0800B004F mov byte [0xb80a0],0x4f
00000033 C605A1800B000F mov byte [0xb80a1],0xf
0000003A C605A2800B004B mov byte [0xb80a2],0x4b
00000041 C605A3800B000F mov byte [0xb80a3],0xf
00000048 EB1C jmp short 0x66
0000004A C682A00000004B mov byte [edx+0xa0],0x4b
00000051 C682A10000000F mov byte [edx+0xa1],0xf
00000058 C682A20000004F mov byte [edx+0xa2],0x4f
0000005F C682A30000000F mov byte [edx+0xa3],0xf
00000066 84C0 test al,al
00000068 7412 jz 0x7c
0000006A 8802 mov [edx],al
0000006C 42 inc edx
0000006D C6020F mov byte [edx],0xf
00000070 42 inc edx
00000071 89C8 mov eax,ecx
00000073 41 inc ecx
00000074 0FB60418 movzx eax,byte [eax+ebx]
00000078 84C0 test al,al
0000007A 75EE jnz 0x6a
0000007C EBFE jmp short 0x7c
0000007E 90 nop
0000007F 90 nop
00000080 41 inc ecx
00000081 44 inc esp
00000082 4E dec esi
00000083 2E6F cs outsd
00000085 7320 jnc 0xa7
00000087 666972737420 imul si,[edx+0x73],word 0x2074
0000008D 626F6F bound ebp,[edi+0x6f]
00000090 7420 jz 0xb2
00000092 2120 and [eax],esp
00000094 3A29 cmp ch,[ecx]
00000096 0000 add [eax],al
00000098 0000 add [eax],al
0000009A 0000 add [eax],al
0000009C 0000 add [eax],al
0000009E 0000 add [eax],al
ebx seems to the pointer to 'message':
00000025 0FB603 movzx eax,byte [ebx] --> char c = message[0];
and
00000074 0FB60418 movzx eax,byte [eax+ebx] --> c = message[i++];
I dont know why the message pointer seems to be bad
Someone could help me ?