home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!hp9000.csc.cuhk.hk!cucs5.cs.cuhk.hk!cucs17.cs.cuhk.hk!lou1347
- From: lou1347@cucs17.cs.cuhk.hk
- Newsgroups: comp.lang.c
- Subject: Problem on getting video ram data
- Message-ID: <1992Aug12.170428.1@cucs17.cs.cuhk.hk>
- Date: 12 Aug 92 09:04:28 GMT
- Sender: news@cucs5.cs.cuhk.hk
- Organization: Dept of Computer Sci, CUHK
- Lines: 44
-
- In last message says that:
-
- > Leo> I wanna write a program which load the data in video ram
- > directly in PC.
- >
- > Leo> void release(void)
- > Leo> {
- > Leo> unsigned int count=0,vcount,code,inused;
- > Leo> unsigned char far *video;
- > Leo> while(count<usedno)
- > Leo> {
- > Leo> inused=0; video=(char far *)0xb8000000;
- > Leo> for(vcount=0;vcount<2000;vcount++)
- > Leo> {
- > Leo> code=(*video++)+(*video++ & 8)?256:0;
- >
- > According to "The C Pocket Reference" by Herbert Schildt,
- > Osborne McGraw-Hill, ?: operator's presedence is lower than
- > +'s, so code is either 256 or 0.
-
- Thanks, but I still in trouble. I wrote another test program like that:
-
- #include <stdio.h>
- main()
- {
- char a[]={10,20},*video;
- int code;
- video=a;
- code=(*video++)+((*video++ & 8)?256:0);
- printf("%d\n",code);
- }
-
- The bracket is added. I expect the result to be 10. But It give 276!!
- (If I split it into two lines, the result will be 10).
-
- I think the problem is that the operand after '+' do first so that the
- first *video got 20 and second *video got 10 which give the result 276.
-
- But I know that in C,'+' sign will do from left to right. ( I also write a
- program to test it and it is true ) So what is the result?
-
- I am using turbo C 2.0.
-
- Regards
-