-
Notifications
You must be signed in to change notification settings - Fork 0
Directives
In programming, a directive is a language construct that specifies how the Assembler should process its input. Directives are not part of the grammar of a programming language.
The Assembler directives, also referred to as pseudo-operations, generally specify such information as the target plattform, mark separations between code sections, invoke macros, define reserved memory areas, and so on. Assemblers use a specific syntax to differentiate pseudo-operations from instructions, such as the pseudo-operations END, which might direct the assembler to stop assembling code.
The Assembler provides the DISPLAY directives that let you display a string on the console during assembly. You can use these directive to report on the progress of an assembly, either to let you know how far the assembly has progressed, or to let you know that a certain part of the code has been reached. The syntax for DISPLAY is
DISPLAY "text"
where text is a quoted string, that display a message on screen.
Use the END directive to mark the end of your source file. The syntax looks like this:
END [ startaddress ]
startaddress is an optional symbol or expression that specifies the address in your program where you want execution to begin. startaddress can be an address within the current program; it can also be an external symbol defined in another program. The Assembler ignores any text after the END directive in the source file.
Example:
MODEL P35S
SEGMENT CODE
start:
; Body of program goes here
ENDS
END start ; program entry point is 'start'
this line is ignored
You use the ENDS directive to close a segment. You must use the ENDS directive to close any segments opened with the SEGMENT directive. Here's the syntax of the ENDS directive:
ENDS [name]
name specifies the name of the segment to be closed. The Assembler will report an error message if name doesn't agree with the segment currently open. If the segment has no names, it is an unnamed segment. In this case, the Assembler assumes the currently open segment.
The EQU directive defines a string, or number. To use it, specify the following syntax,
name EQU expression
where name is assigned the expression. name must be a new symbol name that you haven't previously defined in a different manner.
The Assembler provides directives and predefined symbols that let you use the instructions included for particular calculator language. The HP calculator family provides a variety of programming language for you to use. The assembler supports the following directives:
| Directives | Meaning |
|---|---|
| P35S | Enables assembly of the polish instructions available only on the HP 35s calculator (RPN mode) |
Table language directives
Turbo Assebler uses a two-character code prep ended to symbols, which determines whether a symbol in a procedure has block scope. This local-symbol prefix is denoted with "@@". You can use the LOCALS directive to enable block-scoped symbols, and to set the local symbol prefix.
The MODEL directive lets you specify a language for the procedures in your program. Here's the syntax for the MODEL directive:
MODEL language
language specify the default procedure calling conventions/and the default syntax of your program code. You must specify the language otherwise the Assembler generate an error. You can additionally override the default language by using the language directive.
You can use the RADIX directives to change the current default radix and the decimal seperator. Use the following syntax:
RADIX expression
expression must have a value of either 2 (binary), 8 (octal), 10 (decimal), 16 (hexadecimal). The Assembler assumes that the current default radix is decimal.
The SEGMENT directive opens a segment. All code or data following it will be included in the segment, until a corresponding ENDS directive closes the segment. The syntax for the SEGMENT directive is:
SEGMENT [name] type
name is the name of the segment. You should name segments according to their usages. The segment name is a string that helps you to identify your segments.
type tells the Assembler how to handle the segment. A program needs at least a code segment (type CODE). Data and stack are using an extra segment with is own type attribute. The following table lists the legal values of the segment type. The type attribute for the segment directive is mandatory. If you don't specify the type, the Assembler generate an error.
| Type value | Meaning |
|---|---|
| CODE | Begins or continues the module's code segment. |
| DATA | Begins or continues the module's default initialized data segment. |
| STACK | Begins or continues a module's stack segment. |
Table segment types
Note that you can generate more than one segment per module in this way.
The Assembler provides the SET directives that let you assign a values to a registers. The SET directive defines only a numeric equate. To use it, specify
name SET expression
Where name is assigned the result of evaluating expression, which must evaluate a register within a stack segment. name can either be a new symbol name, or a symbol that you previously defined with SET.
The %TITLE directive sets the title in the listing file. %TITLE has the following syntax:
%TITLE "text"
The title text appears at the top of each page, after the name of the source file. You can use %TITLE as many times as you want.
- HP-35s Startpage
- Assembler
- Emulator
- Applications Book (en|de)
- Introduction
- Machine Related Operations
- Number Theory and Algebra
- Geometry and Trigonometry
- Miscellany
- Appendix