I've been porting my kernel to x86-64 from x86 (better earlier than later), and I've run into a strange problem with my scrolling text function. Once scrolling is triggered, in the x86-64 kernel only, an invalid opcode occurs. In x86, it scrolls normally.
Here's the non-working part of the scrolling code, which shifts each line to the previous one:
Code: Select all
if (text_ypos >= TEXT_ROWS)
{
// Non-working code:
for (i = 0; i < TEXT_NUMOFCHARS - TEXT_COLUMNS; i++)
{
text_vidmem[i] = text_vidmem[i + TEXT_COLUMNS];
}
(more working code)
Stranger still, when I finally gave up and used inline assembly instead, it actually worked (for both kernels)!
Code: Select all
if (text_ypos >= TEXT_ROWS)
{
asm (
"mov %0, %%esi;"
"mov %1, %%edi;"
"mov %2, %%ecx;"
"rep movsw;"
:
: "n"(TEXT_MEMADDR + (TEXT_COLUMNS * 2)), "n"(TEXT_MEMADDR), "n"(TEXT_NUMOFCHARS - TEXT_COLUMNS)
: "esi", "edi", "ecx"
);
(working fine with this)
Is it my code, or is something in my GNU toolchain messing up?