I would like to know how can we change the letters of the characters on screen using C. It is a TSR program using dos.h header file.
-
do you mean like upper case to lower case and vice versa? – Keith Miller Oct 10 '12 at 18:02
-
Why are you coding a TSR for DOS? – Adam Rosenfield Oct 10 '12 at 18:08
-
it is a program to be written on windows.. We are using turbo c – Jinu Joseph Daniel Oct 10 '12 at 18:13
1 Answers
I might be able to help partially from what i remember of my early undergrad.
In DOS, the address 0xB8000000 (0xB800:0 as segment:offset rightly pointed out in comments) is the starting address of text mode video memory (0xA8000000 being that for graphics). Any thing written into this area is copied directly to vga card. Now every character on the screen is made up of two bytes. First byte was the ascii character and second was the color.
So effectively you take a far pointer in 16 bit c (since a normal near pointer won't do) and assign it the above address. Then assuming your screen size (25*80) or whatever * 2 is the total number of single byte addresses filling your screen.
I remember having written the equivalent of a trivial printf function using above.
Getting back to your problem, you have to write code which loops through all even addresses starting from above address till screen size. Even address because odd one represents color. There it checks if the assigned character is valid ascii and add or subtract according to needs e.g. 'A' + 32 would get you 'a' and so on.
Question remains about when your above program does this. I believe you can have some interrupt or similar thing in dos.h which triggers every time any screen character is changed. But this part is not very clear in my memory.
See if that works for you.

- 5,412
- 4
- 28
- 68
-
`0xB8000000` has way too many zeroes in it and is either wrong or confusing. The real-mode address is `0xB800:0` (segment:offset). The physical address it corresponds to is `0xB8000`. – Alexey Frunze Oct 10 '12 at 21:30
-
1Actually the origin of writing it was remembering the assignment char far *p = 0xB8000000L; A far pointer is four bytes so the address is specified as equivalent of flat 32bit. Though i agree the conceptual 0xB800:0 is better in text. I would edit that - Thanks – fkl Oct 11 '12 at 03:49