From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID,SUBJ_ALL_CAPS autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b4f26c164c846938 X-Google-Attributes: gid103376,public From: Nick Roberts Subject: Re: VIDEO MEMORY ACCESS WITH POINTERS Date: 1999/11/29 Message-ID: <3841FA9B.31E9D1F4@callnetuk.com>#1/1 X-Deja-AN: 554436781 Content-Transfer-Encoding: 7bit References: <81p3sh$h2m$1@news.colba.net> <38409762.0@news.pacifier.com> X-Original-NNTP-Posting-Host: da130d13.dialup.callnetuk.com X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 29 Nov 1999 15:02:19 GMT, da130d13.dialup.callnetuk.com Organization: Computer Consultant MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-29T00:00:00+00:00 List-Id: DuckE wrote: > > with system.storage_elements; > > procedure video_memory_example is > > max_video_memory : constant := 16#2000#; > > type video_cell is mod 2**16; > > type video_memory_type is > array( 1 .. max_video_memory ) of video_cell; > > video_memory : video_memory_type; > for video_memory'address use > system.storage_elements.to_address( 16#b8000000# ); > pragma volatile( video_memory ); > > begin > video_memory( 1 ) := 16#4141#; > end video_memory_example; Strictly, this solution needs two extra declarations: for video_cell'Size use 16; for video_memory_type'Component_Size use 16; These declarations will ensure that the types video_cell and video_memory_type both have the correct size and format. Each should be inserted just after the declaration of the type itself. It would probably (but not necessarily) be more convenient for the array index range to be 0..max_video_memory-1. It may be more convenient to declare the array as a two-dimensional array, but (interestingly) the Ada standard provides no way to specify or interrogate whether an array is stored in row-major or column-major order, so you can't do this if you need portability. (Row-major order is recommended in the RM95, but you should check what your compiler does.) In addition, I think it's worth pointing out that the type video_cell could be broken down into its component parts (by making it a record or array type), and also that, in a big program, it will likely be worth encapsulating all accesses to bare video memory (by putting it all into a separate package, with an appropriate interface - e.g. procedures for drawing lines, or text, or whatever). -- Nick Roberts http://www.adapower.com/lab/adaos Always call for the professionals. (If they don't help, call for me ;-)