#!/bin/bash # This script builds and runs the DEC64 tests for Linux running on a 64-bit # ARM processor. # DEC64's ARM source must be tweaked slightly to make it compatible with gcc: # 0. Comments start with a double slash, not a semicolon. # 1. The global directive, like all directives, is preceeded by a period. # 2. The area directive is not supported. We do, however, align. # 3. Labels must be suffixed with a colon. # 4. An 8 byte constant is declared with .quad rather than dcq. # 5. When shifting an address offset, an extra comma is required. # 6. The end directive is unnecessary. sed \ -E \ -e "s_;_//_g" \ -e "s/global ([a-z0-9_]+) \\[func\\]/.global \1/g" \ -e "s/area dec64, align=8, code, readonly/.align 8/g" \ -e "s/^([a-z0-9_]+)/\1:/g" \ -e "s/dcq/.quad/g" \ -e "s/x([0-9]) lsl 3/x\1, lsl 3/g" \ -e "/ end/d" \ dec64.linux.s \ || exit build_and_run() { # Compile, assemble and link a source file into a binary executable, then # run it. src=$1 bin=$2 gcc \ -o $bin \ dec64.linux.s \ dec64_string.c \ dec64_math.c \ $src \ && ./$bin } build_and_run dec64_test.c dec64_test \ && build_and_run dec64_string_test.c dec64_string_test \ && build_and_run dec64_math_test.c dec64_math_test \ || exit # This script has been tested on Debian 12 (Bookworm) with gcc v12.2.0.