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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:7b9b:: with SMTP id p27mr11383793qtu.2.1579332773590; Fri, 17 Jan 2020 23:32:53 -0800 (PST) X-Received: by 2002:a9d:3d0a:: with SMTP id a10mr9164471otc.327.1579332773133; Fri, 17 Jan 2020 23:32:53 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!g89no8674898qtd.0!news-out.google.com!w29ni1621qtc.0!nntp.google.com!g89no8674893qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 17 Jan 2020 23:32:52 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=47.136.24.151; posting-account=o_Y23woAAACPYGlDsFV1OivhygPNSoRn NNTP-Posting-Host: 47.136.24.151 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Creating several types from a base type and conversion From: Ken Roberts Injection-Date: Sat, 18 Jan 2020 07:32:53 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57867 Date: 2020-01-17T23:32:52-08:00 List-Id: New to ada with a question about types. The theory is creating an old computer emulator. Memory is an array of BaseWord's (Older computer had 32K of memory, so making an array on a modern computer is peanuts). Creating a base type that is stored into the memory array type BaseWord is array (00 .. 29) of Boolean; pragma pack (BaseWord); Creating derived type(s) that can be returned from the memory section type DataWord is new BaseWord with record Upper : array 00 .. 8#77777# of Boolean; Lower : array 00 .. 8#77777# of Boolean; end record; for DataWord use record for Upper use 15 .. 29; for Lower use 00 .. 14; end record; pragma pack (DataWord); type InstructionWord is new BaseWord with record; (define field parameters) end record; for InstructionWord use record (define BaseWord fields bit locations) end record; Defining how characters for display are packed into memory type CharByte is array (0 .. 5) of Boolean; -- Character define type CharWord is record CharArray : array (0 .. 4) of CharByte; end record; for CharWord use record for CharArray (0) use 24 .. 29; for CharArray (1) use 18 .. 23; for CharArray (2) use 12 .. 17; for CharArray (3) use 6 .. 11; for CharArray (4) use 0 .. 5; end record; So the next question is how to convert between CharWord/BaseWord? For most stuff, memory will be returning either DataWord or InstructionWord for each memory access, but I'm also looking at an easier way to manage characters for text display on the emulated monitors.