I'm actually trying to create my own kernel, and I have got some problem with video memory access :/
I need to access to video memory at boot, thus, I create a pointer to 0xB8000 address and then, I increment the pointer to access next location.
Basically, the code would be :
Code: Select all
volatile char *p = (volatile char *)0xB8000;
for (int i = 0; i < 6; ++i)
*(p++) = 'A';
But this doesn't work, no character displayed. It display nothing. But if I change incrementation position like this, it works, i can see the characters on the screen !
Code: Select all
volatile char *p = (volatile char *)0xB8000;
for (int i = 0; i < 5; ++i)
*p = 'A';
p++;
Code: Select all
volatile char *p = (volatile char *)0xB7FFF;
for (int i = 0; i < 5; ++i)
*(++p) = 'A';
Code: Select all
; Postfix
mov ecx, DWORD PTR _p$[ebp]
mov BYTE PTR [ecx], 65 ; 'A' character
mov edx, DWORD PTR _p$[ebp]
add edx, 1
mov DWORD PTR _p$[ebp], edx
; Prefix
mov ecx, DWORD PTR _p$[ebp]
add ecx, 1
mov DWORD PTR _p$[ebp], ecx
mov edx, DWORD PTR _p$[ebp]
mov BYTE PTR [edx], 65 ; 'A' character
The assembly code is from Visual C++ compiler, I don't have any GCC at work :/
I know the difference between prefix and postfix incrementation, and I see the difference between assembly code present here. But IMO, none of these differences leads to non printing characters on screen.
Thank you