0

What does 0xa55a mean here?

Code:

*cp = (uint16_t) 0xA55A;   
if (*cp != 0xA55A) {      /* 0xa55a means that? */
cp = (uint16_t*) (KERNBASE + MONO_BUF);
    addr_6845 = MONO_BASE;
} 
Blownhither Ma
  • 1,461
  • 8
  • 18
Alex Liu
  • 95
  • 1
  • 8

1 Answers1

5

This code tests if cp is a writable address to determine whether the mode should be CGA or MONO. If writing does not work then we cannot use this part of memory. The thing (garbage) to be written should be arbitrary. It has no special meaning as far as I know.

Before this, the program saves the value at cp in was so the garbage won't poison the memory.

Blownhither Ma
  • 1,461
  • 8
  • 18
  • In the other words, 0xa55a can it be any value? – Alex Liu Oct 18 '18 at 03:15
  • @AlexLiu Basically YES! I am not aware of any number you should avoid. Intuitively you would not choose something like 0. Just use a seemingly random number. I am happy to know if experiments show otherwise! – Blownhither Ma Oct 18 '18 at 03:26
  • Yes, I change the value to 0x0101 and it works. Haha, Thank you very much for your answer. – Alex Liu Oct 18 '18 at 03:33