12. Barcode generator

The Barcode generator makes it possible to generate barcode for RPN programs. To use it you will need a Postscript level 2 (or later) 1 printer. To read the barcode into the HP-41, an HP 82153A Wand is required.

The Barcode generator is a command line tool named barcode. Running it from the command line with the ``–help`` option will give a sign-on message and display accepted options:

Calypsi barcode generator for Hewlett-Packard Nut version 5.16

Usage: barcode [--version] [--media MEDIA] [--private] [-I DIRECTORY] FILE
  use 'barcode --help' for detailed help

Available options:
  --version                Display version number
  --media MEDIA            Media, one of 'A4' or 'Letter', defaults to 'A4'
  --private                Private program barcode
  -I DIRECTORY             Include directory
  -h,--help                Show this help text

The input source file can either be an RPN source file or a raw binary image (using .raw file extension).

12.1. Language

The Barcode Generator will accept the same kind of source files as the RPN compiler, see RPN language. A source file that contains the .local directive is not accepted, see Invoking local MCODE instructions.

12.2. Preprocessor

The Barcode generator uses a full featured C preprocessor to handle the input source file. The preprocessor provides the normal features you will find in a C preprocessor, the ability to include header files, macro expansions, conditional compilation and use of C style comments.

Wikipedia is a good place to look for an introduction with many examples on how to use the C preprocessor.

When used in the Barcode generator, the following macros are predefined:

Table 12.1 Predefined processor symbols

Preprocessor symbol

Description

__CALYPSI_NUT__

An integer that is 1 when the Nut target (including NEWT variant) is used.

__CALYPSI_BARCODE__

An integer that is 1 when the Barcode generator is used.

__CALYPSI_RAM_USE__

An integer that is 1 when the Barcode generator is used.

12.3. Branches and labels

Local branches are automatically selected depending on branch distance. The distance for a compiled small branch is slightly shorter in RAM compared to ROM, which is taken into account.

A fixed local GTO and XEQ instruction 2 in a program has reserved space in the instruction to store the offset to its destination label. The first time such instruction is executed, the branch offset is unknown and the calculator will search for the destination label. Once found, the offset is stored together with the instruction to speed up execution the next time the instruction is encountered.

However, some GTO instructions exists in a smaller (space saving form) that only can store short offsets. The RPN compiler will encode such branches in their long version if needed, to ensure that there is room to store the compiled offset to the destination label.

Footnotes

1

The reason it does not work with Postscript level 1 is that a feature to compensate for accumulating errors is used. Today, level 1 printers are rare, level 2 was introduced in 1991.

2

This excludes indirect branches and branches to alpha labels. Such branch instructions lack space to store the offset the the label.