A Hello World Kernel black background at the beginning of the third line down, y
ID: 670687 • Letter: A
Question
A Hello World Kernel
black background at the beginning of the third line down, you would have to do the following:
Compute the address relative to the beginning of video memory:
Since one line is 80 characters long, the beginning of the third line down would be 80*(3-1) = 160
Multiply that relative location by 2 bytes / character: 160*2 = 320
Convert that to hexadecimal (e.g., using a converter: http://www.binaryhexconverter.com/decimal-to-hex-converter): 320 = 0x140
Add that to the starting address of video memory (0xB8000) to get the memory address: 0xB8000+0x140 = 0xB8140
Write 0x41, the ASCII code for the letter ‘A’, to address 0xB8140.
Write the color white (0x0F) to address 0xB8141
Explanation / Answer
Since 16 bit C provides no built in mechanism for writing to memory, you are provided with an assembly file, kernel.asm. This file contains a function putInMemory, which writes a byte to memory. The function putInMemory can be called from your C program and takes three parameters:
To write 'A' to address 0xB8140, you should call: putInMemory(0xB000, 0x8140, 'A');
To print out the letter A in white at the beginning of the third line of the screen, call:
putInMemory(0xB000, 0x8140, 'A');
putInMemory(0xB000, 0x8141, 0x7);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.