TSR Program to change case of characters on screen in windows/dos
Asked Answered
O

1

2

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.

Overman answered 10/10, 2012 at 18:1 Comment(3)
do you mean like upper case to lower case and vice versa?Desk
Why are you coding a TSR for DOS?Everlasting
it is a program to be written on windows.. We are using turbo cOverman
T
1

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.

Temporary answered 10/10, 2012 at 18:42 Comment(2)
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.Discredit
Actually 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 - ThanksTemporary

© 2022 - 2024 — McMap. All rights reserved.