Solved

Writing to VDU memory

Posted on 2003-11-08
9
1,205 Views
Last Modified: 2012-06-21
Why my program coding is ineffective to display the characters on the screen using VDU memory?

The coding is given as below:

/* printing the integers stored in an array */
#include<stdio.h>
#include<conio.h>

void main()
{
 int i;
 clrscr();
 char far *video;
 *video=0xB8000000;  /* for VGA/EGA/CGA type */
 int k, array[4]={ 1,2,3,4 };
 for(i=0,k=0; k<=4; i+=2,k++)
 {
  *(video+i)=array[k];  /* adding text */
  *(video+i+1)=65;  /* adding attributes (colors) */
 }
getch();
}

Please help!


0
Comment
Question by:gagandeep_1984
  • 4
  • 3
9 Comments
 
LVL 22

Expert Comment

by:grg99
ID: 9706994
This will noly work if you're using a compiler that generates 16-bit code.

What compiler and memory model are you using?

0
 
LVL 4

Expert Comment

by:dhyanesh
ID: 9707629
hi

a few errors in your code

/* printing the integers stored in an array */
#include<stdio.h>
#include<conio.h>

void main()
{
int i;
clrscr();
char far *video;
video=0xB8000000;  /* for VGA/EGA/CGA type */        //it should be video and not *video
int k, array[4]={ 1,2,3,4 };
for(i=0,k=0; k<=4; i+=2,k++)
{
 *(video+i)=array[k] + '0';  /* adding text */               //Here ascii value of zero is added to print correctly
 *(video+i+1)=65;  /* adding attributes (colors) */
}
getch();
}

Dhyanesh
0
 
LVL 1

Author Comment

by:gagandeep_1984
ID: 9709123
Dear grg99,

 Sorry, but I have a very less knowledge about memory model but the complier, which I  am using is the " Turbo-c 3.0" .

0
 
LVL 4

Expert Comment

by:dhyanesh
ID: 9709252
The program modified by me works fine under Turbo-c 3.0
0
New! My Passport Wireless Pro Wi-Fi Mobile Storage

Portable wireless storage to offload, edit, and stream anywhere.

High-capacity, wireless mobile storage designed to accompany professional photographers and videographers in the field to easily offload, edit and stream captured photos and high-definition videos.

 
LVL 1

Author Comment

by:gagandeep_1984
ID: 9747694
Dear Dhyanesh,

Sorry for the late response.
According to your coding, I compiled the program but it shows an error " Cannot convert ' unsigned long' to 'char far' " at that point where you were insisting to remove the pointer from the statement ( video=0xB8000000; ) . But when the pointer is used in that statement, the concerned error vanish. After compiling the program, I see nothing on screen . Am I doing something wrong?
Please help!

Gagan...
0
 
LVL 4

Accepted Solution

by:
dhyanesh earned 100 total points
ID: 9752900
hi

It works fine on my compiler. You can try to cast type it like

video = (char far *)0xB8000000L;

It has to be video and not *video. This is because *video will store 0xB8000000 at a location pointed by video.

However if 'video' is used then the statement makes 'video' point to location 0xB000000 which is starting location for VDU memory.

Dhyanesh
0
 
LVL 1

Author Comment

by:gagandeep_1984
ID: 9753173
Dear Dhyanesh ,
Thank you for your help to make this program a success.
The statement which you have given stated as " video=(char far *) B8000000; "  makes the program works fine.
But why does it gives a background of RED color?  and also the value B0000000 given by you runs under monochorme  video mode but mine is VGA mode.
0
 
LVL 4

Expert Comment

by:dhyanesh
ID: 9757704
hi

Sorry about the value B000000 it was a typing mistake. The value should be 0xB8000000.

Also if you want the text in red change following statement.

*(video+i+1)=RED;  /* adding attributes (colors) */

Dhyanesh
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now