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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!x1g2000yqb.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Fri, 4 Feb 2011 01:24:01 -0800 (PST) Organization: http://groups.google.com Message-ID: <05a3673e-fb97-449c-94ed-1139eb085c32@x1g2000yqb.googlegroups.com> References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <31c357bd-c8dc-4583-a454-86d9c579e5f4@m13g2000yqb.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1296811441 30446 127.0.0.1 (4 Feb 2011 09:24:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 Feb 2011 09:24:01 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: x1g2000yqb.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012111 Red Hat/3.0.6-1.el5 Firefox/3.0.6,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:17833 Date: 2011-02-04T01:24:01-08:00 List-Id: Ludovic Brenta wrote: > Syntax Issues wrote on comp.lang.ada: >> I am planning to start learning lower-level programming with ada, >> however, I was unable to find a solid tutorial on writing directly to >> a memory address or interfacing with assembly. Does anyone know where >> I can find a reference to some tutorials/information? Below is an >> example of code I would like to be able to implement. > >> ... >> unsigned int print(char *message, unsigned int line) >> { >> =A0 =A0 =A0 =A0 char *vidmem =3D (char *) 0xb8000; >> =A0 =A0 =A0 =A0 unsigned int i=3D 0; >> >> =A0 =A0 =A0 =A0 i=3D(line*80*2); >> >> =A0 =A0 =A0 =A0 while(*message!=3D0) // 24h Did I mention that *every* time I look at C code I see a bug? Sometimes, looking twice at the same code reveals two bugs! Here you do not check that message !=3D NULL; the condition should be: while (message && *message !=3D 0) >> =A0 =A0 =A0 =A0 { >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 vidmem[i]=3D *message; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *message++; > > *Every* time I look at C code, I see a bug. > I think this is a bug; it should read "message++" since you want to > increment the pointer, not the pointed-to character. > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 i++; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 vidmem[i]=3D 0x7; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 i++; >> =A0 =A0 =A0 =A0 }; >> >> =A0 =A0 =A0 =A0 return(1);}; -- Ludovic Brenta.