This collection contains Ada example programs designed to teach Ada programming concepts for the uada80 compiler targeting the Z80 processor running CP/M.
- AdaCore Learn Platform - Free interactive courses covering Ada fundamentals, tasking, SPARK, and more
- Introduction to Ada (PDF) - Comprehensive PDF guide from AdaCore
- Ada Resource Association - Tutorials, courses, books, and learning materials
- Ada Programming Wikibook - Community-maintained tutorial covering all Ada topics (PDF version)
- Ada Distilled - Concise guide for experienced programmers
- Ada 95 Tutorial (Coronado) - 33 chapters covering the entire language
- Ada95 Lovelace Tutorial - Self-paced tutorial by David Wheeler
- Free Ada E-Books at AdaForge - 18 free e-books including "Ada - a crash course"
- FreeComputerBooks Ada Section - "Ada 95: The Craft of Object-Oriented Programming" and more
- Class Central Ada Courses - Curated list of free and paid courses
- edX Ada Programming - Online courses from various providers
- Udemy Ada for Beginners - Beginner-focused course
- Ada Reference Manual - Official language standard
- awesome-ada on GitHub - Curated list of Ada resources
This collection contains 90+ example programs organized by concept:
01_basics/ - Getting Started
hello_world.adb- The simplest Ada programhello_use.adb- Using "use" clausescomments.adb- Ada comment syntaxidentifiers.adb- Naming rulesreserved_words.adb- Ada keywordsprogram_structure.adb- Program organizationsemicolons.adb- Statement terminatorsblocks.adb- Declare blocks
02_types/ - Type System
integer_types.adb- Integer types and literalsrange_types.adb- Custom integer rangesmodular_types.adb- Unsigned wraparound typesboolean_type.adb- Boolean operationscharacter_type.adb- Character typeenumeration_types.adb- User-defined enumerationssubtypes.adb- Constrained subtypestype_conversions.adb- Explicit type conversion
03_variables/ - Variables and Constants
variables.adb- Variable declarationsconstants.adb- Named constantsinitialization.adb- Initialization patterns
04_operators/ - Operators
arithmetic_ops.adb- +, -, *, /, mod, rem, **relational_ops.adb- =, /=, <, >, <=, >=logical_ops.adb- and, or, xor, notstring_ops.adb- & concatenationprecedence.adb- Operator precedence
05_control_flow/ - Control Structures
if_statement.adb- If-then-elsecase_statement.adb- Case (switch)while_loop.adb- While loopsfor_loop.adb- For loops with rangesbasic_loop.adb- Loop with exitnamed_loops.adb- Named loops and exitfor_of_loop.adb- Ada 2012 iterator loopsgoto_statement.adb- Goto (use sparingly!)null_statement.adb- The null statement
06_arrays/ - Arrays
basic_arrays.adb- Array basicsarray_aggregates.adb- Initialization syntaxarray_attributes.adb- 'First, 'Last, 'Range, 'Lengtharray_slices.adb- Array slicingmultidim_arrays.adb- Multi-dimensional arraysunconstrained_arrays.adb- Dynamic boundsarray_of_arrays.adb- Arrays vs matrices
07_records/ - Records
basic_records.adb- Record typesrecord_aggregates.adb- Record initializationnested_records.adb- Records in recordsvariant_records.adb- Discriminated recordsrecord_with_array.adb- Arrays in records
08_subprograms/ - Procedures and Functions
procedures.adb- Procedure basicsfunctions.adb- Function basicsparameter_modes.adb- in, out, in Outdefault_parameters.adb- Default valuesoverloading.adb- Name overloadingrecursion.adb- Recursive subprogramslocal_declarations.adb- Local scopeexpression_functions.adb- Ada 2012 expression functions
09_packages/ - Packages
package_intro.adb- Package basicsstack_pkg.ads/.adb- Specification and bodyuse_stack.adb- Using packagesprivate_types.adb- Information hidingchild_packages.adb- Hierarchical packages
10_exceptions/ - Exception Handling
basic_exceptions.adb- Try-catch basicsuser_exceptions.adb- Custom exceptionsexception_propagation.adb- Exception propagationexception_info.adb- Exception informationpredefined_exceptions.adb- Standard exceptions
11_access_types/ - Pointers
basic_access.adb- Access type basicslinked_list.adb- Dynamic data structuresaccess_parameters.adb- Access parameters
12_generics/ - Generic Programming
generic_procedure.adb- Generic proceduresgeneric_function.adb- Generic functionsgeneric_package.adb- Generic packagesgeneric_formal_params.adb- Formal parameters
13_tasking/ - Concurrent Programming
basic_task.adb- Task basicstask_types.adb- Task typesrendezvous.adb- Task communicationprotected_objects.adb- Shared data
14_attributes/ - Attributes
scalar_attributes.adb- Type attributesarray_attrs.adb- Array attributesobject_attributes.adb- Object attributes
15_strings/ - String Handling
fixed_strings.adb- Fixed-length strings
16_io/ - Input/Output
text_io_basics.adb- Text I/O basicsinteger_io.adb- Integer I/O formatting
17_derived_types/ - Type Derivation
derived_types.adb- Creating new types
18_pragmas/ - Compiler Directives
pragma_examples.adb- Common pragmas
19_contracts/ - Contract Programming
contract_examples.adb- Pre/Post conditions
20_applications/ - Practical Examples
calculator.adb- Simple calculatorprime_numbers.adb- Prime algorithmssorting.adb- Sorting algorithmsbinary_search.adb- Binary searchtemperature_converter.adb- Unit conversionnumber_guessing.adb- Simple gamemorse_code.adb- Morse encodertodo_list.adb- Task manager
These examples are designed to work with the uada80 compiler which targets the Z80/CP/M environment:
- ~57K TPA (Transient Program Area) on 64K system
- Use small, focused examples
- Avoid large arrays when possible
- Standard Integer is 16-bit (-32768 to 32767)
- Use
rangetypes to constrain values - No native 32/64-bit without libraries
- Software floating point available but slow
- Integer arithmetic preferred
- Use fixed-point or scaled integers when possible
- Supported via timer interrupts
- Use protected objects for shared data
- Keep task count minimal
- Console via BDOS function calls
- File I/O in 128-byte sectors
- 8.3 filename format
- Study the examples - Each file demonstrates one concept
- Read the comments - Explanations are in the code
- Compile and run - Use uada80 to compile
- Experiment - Modify examples to learn
# Compile an example
python -m uada80 hello_world.adb -o hello.com
# Run in CP/M emulator
cpmemu hello.comSuggested order for beginners:
- Basics (01_basics/) - Start here!
- Types (02_types/) - Ada's strong typing
- Variables (03_variables/) - Data storage
- Operators (04_operators/) - Expressions
- Control Flow (05_control_flow/) - Logic
- Arrays (06_arrays/) - Collections
- Records (07_records/) - Structures
- Subprograms (08_subprograms/) - Functions
- Packages (09_packages/) - Modularity
- Exceptions (10_exceptions/) - Error handling
- Access Types (11_access_types/) - Pointers
- Generics (12_generics/) - Templates
- Tasking (13_tasking/) - Concurrency
- Applications (20_applications/) - Put it together!
These examples cover the core language. Additional topics that could be added:
- File I/O examples specific to CP/M
- Hardware interfacing (ports, interrupts)
- More algorithms (graph, tree operations)
- Text processing utilities
- Simple games
Feel free to add more examples! Guidelines:
- One concept per file
- Extensive comments explaining the concept
- Keep examples small (Z80 memory constraints)
- Test with uada80 before submitting
- 80un - Unpacker for CP/M compression and archive formats (LBR, ARC, squeeze, crunch, CrLZH)
- cpmdroid - Z80/CP/M emulator for Android with RomWBW HBIOS compatibility and VT100 terminal
- cpmemu - CP/M 2.2 emulator with Z80/8080 CPU emulation and BDOS/BIOS translation to Unix filesystem
- ioscpm - Z80/CP/M emulator for iOS and macOS with RomWBW HBIOS compatibility
- mbasic - Modern MBASIC 5.21 Interpreter & Compilers
- mbasic2025 - MBASIC 5.21 source code reconstruction - byte-for-byte match with original binary
- mbasicc - C++ implementation of MBASIC 5.21
- mbasicc_web - WebAssembly MBASIC 5.21
- mpm2 - MP/M II multi-user CP/M emulator with SSH terminal access and SFTP file transfer
- romwbw_emu - Hardware-level Z80 emulator for RomWBW with 512KB ROM + 512KB RAM banking and HBIOS support
- scelbal - SCELBAL BASIC interpreter - 8008 to 8080 translation
- uada80 - Ada compiler targeting Z80 processor and CP/M 2.2 operating system
- uc80 - ANSI C compiler targeting Z80 processor and CP/M 2.2 operating system
- ucow - Unix/Linux Cowgol to Z80 compiler
- um80_and_friends - Microsoft MACRO-80 compatible toolchain for Linux: assembler, linker, librarian, disassembler
- upeepz80 - Universal peephole optimizer for Z80 compilers
- uplm80 - PL/M-80 compiler targeting Intel 8080 and Zilog Z80 assembly language
- z80cpmw - Z80 CP/M emulator for Windows (RomWBW)