• Keine Ergebnisse gefunden

Other Absolute Elements

Im Dokument Manual For the HP 9845 (Seite 98-104)

There are additional absolute elements which may be used in expressions. These are

"machine addresses", short-precision numbers, and full-precision numbers.

A machine address is one of the following

-• An assembler pre-defined symbol.

• A symbol associated with an EQU or SET pseudo-instruction whose expression is evaluated as a machine address (Le., it contains a pre-defined symbol or another EQU-associated symbol whose expression contains a pre-defined symbol).

defined from assembly to assembly. By defining a machine address in one module (with an EQU or SET), it then becomes available to you with the same value in other modules which you assemble.

For example, if you were to assemble a module containing

-I~JURCE R100: EQU A+100

then RIOO is a machine address following the above rules, just as if the assembler had pre-defined it. If you don't do any SCRATCH or GET statements in the meantime, then the next assembly you do would also have this symbol available without ever having to define it.

When full-precision numbers (like - 2.5, 3E3, 3.141592) and short-precision numbers (like 1.5, - 2.55, 3.141595, 3.E3S) are used in expressions, they become the entire expression.

This is because these numbers are only intended as simple data-generating devices in literals and in OAT pseudo-instructions. Explicitly, the rules for using full- and short-precision numbers

are-• They may only appear alone in an expression, i. e., they may not be in combination with other elements .

• They may only appear in literals and in OAT pseudo-instructions.

Utilities

A number of utilities have been provided to help make your programming tasks easier and to give you direct access to some of the operating system's capabilities and routines.

Descriptions of the utilities are made in conjunction with those topics where the utilities playa part. The form of the description of a utility is somewhat standardized. Each description will tell

you-• The name of the utility.

• The general procedure for using the utility.

• Any special requirements which must be satisfied for the utility to work properly.

• A step-by-step calling procedure for the utility.

• The exit conditions.

Utilities are a form of subroutine, so to execute them it is necessary to execute a jump-to-subroutine instruction (JSM) if you want the utility to return to the routine which calls it. Most utilities execute a RET 1 instruction to return, so in some cases where you follow a utility call with a RET 1 of your own, you can save the RET instruction by using the JMP (unconditional branch) instruction instead. For example, a typical utility call looks like

-LDA =TE"rllp

LDB =F'o i ntET .J~3H GE"t. E" 1 efllE"nt

but if it happened to be followed by a RET 1

-LIlA =T erilp LDB =F'oi nt.E"r"

J::;t'1 Get E" 1 efilent.

PET

the calling procedure could be changed to

-LDA =Temp LDE: =F'o i r-:t Er .-"fI'W Get. e 1 f"ment

and you save a word of code: the effect is otherwise the same. Check the exit conditions for a utility before using this approach.

Utilities which you use in a module must have their names in an EXT pseudo-instruction for that module. Otherwise, the assembler is unable to tell that you meant a utility and not one of your own labels, causing an "undefined reference" assembly error.

The contents of any or all of the processor registers may be altered after a return from a utility.

Be sure to save the contents of registers that you are using before you call a utility.

If you are using interrupts, the interrupt system mayor may not be enabled upon return from a utility. Use the EIR and DIR instructions to ensure the proper state of the interrupt system upon return from a utility. A system utility cannot be called from an interrupt service routine (lSR).

Appendix F contains a short description of the utilities.

The utilities currently available are

Tests the busy bits of a BASIC variable

Aborts an ICALL statement with a particular error number Accesses substrings (or parts of parameters)

Same as "Get bytes", but used for array elements Same as "Get= value", but used for array elements Accesses the file-pointer of an assigned file

Returns the characteristics of a variable passed as a parameter or existing in common

Returns the value of a BASIC variable

Data type conversion from integer to full-precision Establishes hardware linkages for interrupts

Prepares to read a physical record from mass storage Reads a physical record from mass storage

Writes a physical record to mass storage

Verifies a physical record was written to mass storage Changes or interrogates select-code for standard printer Outputs a string with no CR-LF sequence

Outputs a string to the standard printer Replaces substrings (or parts of parameters)

Same as "Put_bytes", used for elements in an array Same as "Put_value", used for elements in an array Manipulates the file-pointer of a file

Changes the value of a BASIC variable Provides access to all the arithmetic routines Data type conversion from full-precision to integer Data type conversion from full-precision to short Data type conversion from short-precision to full Allows immediate printing with printing utilities

Chapter 5

Arithmetic

Summary: Arithmetic operations are reviewed and the arithmetic utilities are discus-sed. Floating point and BCD arithmetic are explained, as well as integer arithmetic.

Numerical calculations are a large part of any computer's operations. Implemented within the System 45's processor are both integer and primitive Binary Coded Decimal (BCD) floating-point arithmetic operations. These operations are needed because three of the four BASIC variable data types (explained in Chapter 3) are represented either as BCD floating point numbers or as integer (binary) values. To be specific, full-precision numbers are presented as 12-digit, BCD floating point numbers, short-precision numbers are represented as 6-digit, floating point numbers, and integers are represented as binary numbers. This chapter deals with integer and floating point operations and is intended for those readers who may have no acquaintance with this topic, or perhaps only a passing one. The particular machine instruc-tions involved with such arithmetic are reviewed.

Because the processor provides only rudimentary floating-point operations and because com-plete floating-point operations (e.g., subtract, divide) are not easy to write, BCD arithmetic utilities have been provided to perform these calculations and are discussed later in this chap-ter. Integer arithmetic operations are less complex; thus utilities can be written by you, as described in the following section. If you are not interested in doing your own BCD or integer arithmetic, it is recommended that you skip immediately to "Arithmetic Utilities".

Due to its speed increases over BCD floating point arithmetic, integer arithmetic is recom-mended when you are performing the addition, subtraction, or multiplication of integers.

Integer Arithmetic

Im Dokument Manual For the HP 9845 (Seite 98-104)