Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!iuvax!uceng!mfinegan From: mfinegan@uceng.UC.EDU (michael k finegan) Newsgroups: comp.lang.c Subject: Re: Microsoft C far pointer dereferencing Message-ID: <5847@uceng.UC.EDU> Date: 18 Aug 90 17:24:29 GMT References: <9031@uhccux.uhcc.Hawaii.Edu> <5843@uceng.UC.EDU> <9041@uhccux.uhcc.Hawaii.Edu> Organization: Univ. of Cincinnati, College of Engg. Lines: 68 julian@uhccux.uhcc.Hawaii.Edu (Julian Cowley) writes: >In article <5843@uceng.UC.EDU> mfinegan@uceng.UC.EDU writes: >>>PutPixel (int x, int y, unsigned char c) >>>{ >>> unsigned char far *mem; >>> >>> FP_SEG (mem) = 0xa000; >>> FP_OFF (mem) = 320 * y + x; >>> >>> *mem = c; /* <-- this line gives a run-time error */ >>>} >> >>If you look at the manual page again, it says the use of FP_*** is library >>(i.e. memory model) dependent. For small and medium models, these macros >>will only work if the pointer mem is in the default data segment. You have >>it on the stack (subroutine automatic variables) - is that the problem ? >Unfortunately, no. ~ ~ ~ >[ps. that was using quick c, not microsoft c proper...possible bug?] They are certainly different libraries - but try using CL /AL to compile. >julian@uhccux.bitnet Funny, but the following works just fine on MSC v5.1 ... Did you select option to recompile all libraries with latest code when you installed the compiler (the idiots at MS should make it automatic, or send latest library precompiled!) - Mike mfinegan@uceng.UC.EDU -------------------------------------------------------------------------------- #include #include main(argc, argv) int argc; char **argv; { int i, j; unsigned char value; union REGS inregs, outregs; if(argc == 2) { value = argv[1][0]; /* set 320 by 200 by 256 graphics using assembler like interface */ inregs.x.ax = 0x0013; int86(0x10,&inregs,&outregs); for(i=0;i<200;i++) for(j=0;j<320;j++) putbyte(j, i, value); /* restore 80 by 25 text using assembler like interface */ inregs.x.ax = 0x0003; int86(0x10,&inregs,&outregs); } } unsigned char far *video_byte; putbyte(x, y, value) int x, y; unsigned char value; { FP_SEG(video_byte) = 0xa000; FP_OFF(video_byte) = 320*y + x; *video_byte = value; }