Page 1 of 1
how to output strings when in p mode?
Posted: Mon May 17, 2004 10:34 am
by asmboozer
the first question as above. is there any relations among the interupts?
2) when I read the intel system programming manual, which part should I pay more attention to?and why?
so far only the two. thanks any advice given!
Re:how to output strings when in p mode?
Posted: Mon May 17, 2004 11:40 am
by DennisCGc
To output strings, you should create your own printing routine.
The characters should be copied to 0xb8000, where the text video address is.
Re:how to output strings when in p mode?
Posted: Mon May 17, 2004 2:41 pm
by Schol-R-LEA
To answer the second question first, I would say that the crucial sections are memory management and protected mode operations. Just about everything else is shaped to so extent by how you handle these two sets of issues. I realize that this is quite a vague answer, but without knowing more about what you've already done I couldn't be more specific.
As for the text video output, it is one of the most deceptively simple parts of the PC system, assuming you are already in the text mode you want to be in. In the boot-default text mode (mode 3, IIRC), the text screen is mapped to one of four 'text pages' in main memory, each of which is 4 kbytes in size. Each page holds the memory map of a full 25x80 character screen; the reason there are four of them is so that the software could switch between different screens without having to write to video memory (much slower than ordinary RAM) each time, as well as to allow screens to be 'built' before they are displayed. In practice, you need only worry about text page 0 for now, which is the default page on boot up. In text mode 3, page 0 starts at absolute memory address 0x0B8000.
Each character is represented in video memory by two bytes: the character byte, which holds the extended-ASCII value of the character, and the attribute byte which determines how it is displayed (three bits for foreground color, one for high or low intensity, three more for background color, and the last for blinking/non-blinking). To write a character to the upper right-hand corner of the screen, you only need to save a character to 0xB8000, and an attribute value to 0xB8001.
Since the screen shows 80 characters per line, and 25 vertical lines, this means that you can treat the video memory as a 25x80 array or char-attrib pairs.
Re:how to output strings when in p mode?
Posted: Tue May 18, 2004 2:53 am
by Pype.Clicker
there are also plenty of information about printing strings in the
wikiFaQ and in BonaFide & OSRC websites (check .:QuickLinkz:.)
Re:how to output strings when in p mode?
Posted: Wed May 19, 2004 11:27 pm
by asmboozer
since os is already in protected mode, why does the absolute memory address 0x0B8000 work yet?
Re:how to output strings when in p mode?
Posted: Thu May 20, 2004 12:32 pm
by Schol-R-LEA
I'm not sure what you mean. Assuming that you are using a 'flat' memory model, and virtual memory and paging have not yet been enabled, then absolute (i.e., physical) addresses are exactly what you would be using.
OTOH, if you are using a multi-segment model, or have virtual memory paging engaged, then yes, you would have to map the logical addresses to the physical ones. In a multi-segment model, the easiest solution is probably to map a segment onto each video page.; if you are using paging, you would simply disable paging for that section of memory.
C&CW. HTH.