MASD – The Machine Language and System RPL Compiler

MASD is used for compiling assembly language and System RPL.

Introduction

Warnings

The operating system can not control what a low level program is doing. Therefore, any programming error is likely to cause the calculator to crash (with potential memory loss). A careful developer will always save source code in the internal flash ROM or port 1 for protection before trying low level programs.

This document does not intend to be a programming course — it just presents the syntax of the compiler. Ample resources are available on the web (www.hpcalc.org) to learn how to program the Saturn CPU in assembler, how to program in System RPL or how to program in ARM assembly.

With the introduction of the new ARM based series of calculators, some new things have been included that are not backward compatible with previous calculators. The careful programmer should be wary of this.

Starting MASD

To compile a program, put the source code on the level 1 of the stack and type ASM (the development library must be attached) or use the ASM menu of the Development library.

If you have a new version of MASD packaged as a library 259, the command to type is asm (note the lowercase).

Modes

MASD can be used to compile program in 3 different languages: Saturn ASM, ARM ASM and System RPL. Although some things are common to all modes, some are not. As a programmer, you should always know the current mode.

Compilation directives instructions are used to switch from one mode to another:

!ASM (switch to Saturn ASM mode, referred in the rest of this document as the Saturn mode) !RPL (switch to System RPL mode)

!ARM (switches to ARM ASM mode) In addition, in RPL mode,

CODE

%here we are in ASM mode

ENDCODE

Allows switching from RPL mode to Saturn mode (and generate an assembly program object)

Syntax

MASD expects a character string (called source) on the stack level 1. A source is a set of instructions, comments, and separation characters and ends with a carriage return and an @ character. MASD is case sensitive, so be careful, as «loop» and «LOOP» are two different things for MASD. Separation characters are those with an ASCII number below 32. They include spaces, tabs, line feed and carriage return.

In Saturn mode, some instructions need a parameter. Separation characters between an instruction and the parameter are spaces, tabs, and points. Therefore A+B.A can be used instead of A+B A.

In ARM mode, parameters for the instruction are separated by spaces and commas. In Saturn or ARM mode, comments can be placed everywhere and begin with % or ; and finish at the end of the current line.

In RPL mode, comments are delimited by ‘(’ ‘)’ as isolated characters and can be multi line. A line that starts with a ‘*’ on the first character will also be considered a comment.

The Development Library 611

Page 509
Image 509
HP 48gII Graphing manual Masd The Machine Language and System RPL Compiler, Introduction, Starting Masd, Modes, Syntax