But I have an issue with g++ compiling code incorrectly.
I have a smallish amout of code, but the exact cause is here.
All this does is show my title 3 characters in from the top left and should pad 7 P characters after the title.
This works fine, as below in the disassembly
Code: Select all
inline void _ShowTitle()
{
unsigned short* pScreen = (unsigned short*)(0xB8000 + (3 * 2));
const char* ch = CurrentDisplayWindow->Title;
int i = 1;
for (i = 1; i <= TitleWidth; i++)
{
if (*ch == 0)
break;
*pScreen++ = MakeCharAndColor((char)*ch++, TitleForeground, TitleBackground);
}
i = 1;
while (i <= 7)
{
*pScreen++ = MakeCharAndColor('P', TitleForeground, TitleBackground);
i++;
}
}
Code: Select all
135: 84 c9 test cl,cl
137: 75 df jne 118 <_Z11StartKernelv+0x118>
139: b8 50 2f 00 00 mov eax,0x2f50
13e: b9 50 2f 00 00 mov ecx,0x2f50
143: be 50 2f 00 00 mov esi,0x2f50
148: bf 50 2f 00 00 mov edi,0x2f50
14d: 41 b8 50 2f 00 00 mov r8d,0x2f50
153: 41 b9 50 2f 00 00 mov r9d,0x2f50
159: 41 ba 50 2f 00 00 mov r10d,0x2f50
15f: 66 89 02 mov WORD PTR [rdx],ax
162: 66 89 4a 02 mov WORD PTR [rdx+0x2],cx
166: 66 89 72 04 mov WORD PTR [rdx+0x4],si
16a: 66 89 7a 06 mov WORD PTR [rdx+0x6],di
16e: 66 44 89 42 08 mov WORD PTR [rdx+0x8],r8w
173: 66 44 89 4a 0a mov WORD PTR [rdx+0xa],r9w
178: 66 44 89 52 0c mov WORD PTR [rdx+0xc],r10w
17d: f4 hlt
Code: Select all
135: 84 c9 test cl,cl
137: 75 df jne 118 <_Z11StartKernelv+0x118>
139: 66 0f 6f 05 00 00 00 movdqa xmm0,XMMWORD PTR [rip+0x0] # 141 <_Z11StartKernelv+0x141>
140: 00
141: f3 0f 7f 02 movdqu XMMWORD PTR [rdx],xmm0
145: f4 hlt
In case this is needed here are my command lines.
Code: Select all
$ x86_64-elf-g++ -c kernel.c -o kernel.o -ffreestanding -O3 -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -m64 -std=c++11
Code: Select all
$ objdump -d kernel.o -M intel