#!/usr/bin/perl
#*
# Check the 64-bit number addition for numbers used in the RISC-V assembler examples.
#
# USAGE:
#     $0
#     $0 0x1F12345678
#     $0 0x1F12345678 0x44FFEDCBA9
#**

use strict;

# "Hexadecimal number > 0xffffffff non-portable at examples/RISC-V/RARS/multiprecision-add-check.pl line 14."
# And for a good reason. But I just want a quick-n-dirty check of the
# sum on my 64-bit machine... Therefore, "no warnings" at this
# point(S.G.):

no warnings;

my $n1 = 0x1F12345678;
my $n2 = 0x44FFEDCBA9;

if( @ARGV > 0 ) {
    $n1 = hex $ARGV[0];
}

if( @ARGV > 1 ) {
    $n2 = hex $ARGV[1];
}

use warnings;

printf "0x%08x + 0x%08x = 0x%08x\n", $n1, $n2, $n1 + $n2;

# Should output:
# 0x1f12345678 + 0x44ffedcba9 = 0x6412222221
# with default values.
