Tero Koskinen Articles


Using Ada.Sequential_IO to create simple hexdump utility

There is every now and then need for viewing the file contents as "raw" bytes shown as hex numbers. Usually, operating systems have tool 'hexdump' to do this. But it is not hard to create one from scratch. Here is one example how to create a simple hexdump utility in …

Create multiple instances of same package using parameterless generics

There are some cases when you want to create and use multiple instances of same package. This is easily done by creating a generic package which does not take any parameters: generic package Counter is function Get_Number return Natural; end Counter; package body Counter is Counter_Value : Natural := 0; function Get_Number …

Use Ada 2012 aspects to specify variable locations

Earlier with Ada 95 and Ada 2005, if you wanted to put a variable to some specific memory location, you had to use 'for Variable'Address use X' statement and Volatile pragma for that: My_Var : Unsigned_32; for My_Var'Address use System'To_Address (16#FF00#); pragma Volatile (My_Var); With Ada 2012 this becomes simpler …




Checking file header with Adacontrol

Many times you want to make sure that your code has correct comment block at the beginning of the source code file. This comment block can contain the source code license, copyright information, the name of the author, or description of the file. Adacontrol can help you here with its …

Redirecting Text_IO output to a file

One, probably not so often used, feature of Ada.Text_IO is an ability to redirect output (Put, Put_Line, Newline) to a file. It happens simply by opening a file where you want to redirect the output and then calling Set_Output procedure. Example below shows how it is done: with Ada …

Checking "out" parameters with Adacontrol

Have you ever accidentally written code like this? procedure Example_Proc (X : out Boolean) is begin null; -- Do something, but do not touch X end Example_Proc; with Example_Proc; procedure Main is My_Flag : Boolean; begin Example_Proc (My_Flag); end Main; In the above code, parameter X with mode "out" is left untouched. Because …