HP35s macro assempler


Programs for HP35s resemble assembly programs. Like assembly programs, they may benefit from symbolic label resolution, named constants and more advanced macro features. Machine code generation is not required, since "machine code" is not directly available. What is required is a nicely formatted, ready for entry output with all lines numbered, all labels and names resolved.

Programmer's comments in "ready for entry" may be supressed for brevity, on the other hand, sometimes it may be beneficial to have "full listing" of source code and formatted/generated output.

Since HP35s does not have very large programs, performance is not an issue and perl is used as an implementation language. Perl is also a language of arithmetic macro expressions whenever they appear in the code.




Each calculator command occupies one line in the source text. It is referred to as "target command". Target command must not start at first character of the line. Target command is written using ASCII/unicode character approximation of the HP35s commands as they are written in calculator user manual.


';' and '#' outside of meaningful expressions start the comment which lasts till end of line. Comments are completely discarded from the output.


Non-whitespace character in the first position of a line represents a label. Entire sequence of non-whitespace characters up-to the first colon (':') or whitespace is considered the label for the current line (or the first line starting from the current that contains target command).

Symbols 1H .. 9H have special meaning. They can be referred from target commands as <1F> .. <9F> as forward references and <1B> .. <9B> as backward references (H stands for "here"). In another words <2B> means "closest previous label 2H" and <2F> means "closest following label 2H". This implements "local symbols" as described in 1.3.2'

Labels can be used in the target commands in a form of


Labels that start with $ have special meaning. Instead of generating target command, the sequence of characters marked by the label is interpreted as perl expression, which is evaluated and its result is stored in the perl variable with the same name as label. All the limitations on the characters that can be present in perl variable name apply.


Target command may contain a perl expression in {} (or may consist entirely of such expression). The sequence {...} with everything between braces is substituted with the result of evaluation of perl expression and becomes part of generated target commands. It may be usful to generate commands or numeric constants of special form, which do not have obvious mathematical formulas.

Pseudo commands

Some words located in the target command position do not generate target command, but instead control the process of generation.

Conditional compilation

  .if perl_expression
If perl_expression evaluates to non-zero, then target_commands_1 is used for code generation, otherwise target_commands_2.


  .assert perl_expression
Fails compilation if perl_expression evaluates to false. This is useful to ensure that configuration constants that guide code generation make sense and do not fall outside of operational limits.


  .include filename
Implemention postponed until I actually need it or someone asks for it.

Naming registers

REG command assigns NAME to register char. It can be referenced by register using commands as <NAME>. In this case char will be substituted for <NAME> in all target commands.

A register may be assigned several different names if its meaning and use changes during program execution.

Assigning labels

NAME LABEL line_number
LABEL creates new label with value line_number. It can be used to refer to parts of a program that are not defined in the current source text.

Command line options

debug print
cut lines to given width, 0=unlimited
asciize output; replace certain unicode charactes with combination of ascii characters that convey similar meaning
mark lines with GTO and XEQ
output portion of line with a single closing quote in it (normally, do not do this)
the sequence of characters following this option defines what kind of output will be produced and in what sequence
override definition of $NAME in source text and use value instead

[ HP35s index | Feedback ]