INSTRUCTION FORMAT A source language statement consits of a label, an operation code, an operand, and comments. The label is used when needed as a reference by other statements. The operation code may be a mnemonic machine operation or an assembly directing pseudo code. An operand may be an expression consisting of an alphanumeric symbol, a number, a special character, or any of these combined by arithmetic operations. (For the Extended Assembler, an operand may also be a literal.) Indicators may be appended to the operand to specify certain functions such as indirect addressing. The comments portion of the statement is optional. 2.1 STATEMENT CHARACTERISTICS The fields of the source statement appear in the following order: Label Opcode Operand Comments FIELD DELIMETERS One or more spaces separate the fields of a statement. An end-of-statement mark terminates the entire statement. On paper tape this mark is a return, (CR), and a line feed, (LF). [1] A single space following the end-of-statement mark from the previous source statement is the null field indicator of the label field. CHARACTER SET The characters that may appear in a statement are as follows: A through Z 0 through 9 . (period) * (asterisk) --------------------- [1] A circled symbol, e.g. (CR), represents an ASCII code or Teleprinter key. 2-1 HEWLETT-PACKARD ASSEMBLER CODING FORM ---------------------------------------------------------------------------- | PROGRAMMER: | DATE: | PROGRAM: | PAGE: OF | ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- | Label Operation Operand Comments | |----------------------------------------------------------------------------| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ---------------------------------------------------------------------------- SAMPLE CODING FORM (Actual Size 11 x 13 1/2) 2-2 + (plus) - (minus) , (comma) = (equals) () (parenthesis) (space) Any other ASCII characters may appear in the Remarks field (See Appendix A). The letters A through Z, the numbers 0 through 9, and the period may be used in an alphanumeric symbol. In the first position in the Label field, an asterisk indicates a comment; in the Operand field, it represents the value of the program location counter for the current instruction. The plus and minus are used as operators in arithmetic address expres- sions. The comma seprates several operation codes, or an expression and an indicator in the Operand field. An equals sign indicates a literal value. The parentheses are used only in the COM pseudo instruction. Spaces separate fields of a statement. They may also be used to establish the format of the output list. Within a field they may be used freely when following +, -, ,, or (. STATEMENT LENGTH A statement may contain up to 80 characters including blanks, but exluding the end-of-statement mark. Fields beginning in characters 73-80 are not processed by the Assembler. 2.2 LABEL FIELD The Label field identifies the statement and may be used as a reference point by other statements in the program. Te field starts in position one of the statement; the first position foloowing an end-of-statement mark for the preceding statement. It is termated by a space. A space in position one is the null field indicator for the label field; the statement is unlabeled. LABEL SYMBOL A label must be symbolic. It may have one to five characters consisting of A through Z, 0 through 9, and the period. The 2-3 first character must be alphabetic or a period. A label of more than five characters could be entered on the source lan- guage tape, but the Assembler flags this condition as an error and truncates the label from the right to five characters. Examples: 1 5 10 15 20 25 30 35 40 ---------------------------------------- LDA NO LABEL .ABCD VALID LABEL .1234 VALID LABEL A.123 VALID LABEL . VALID LABEL 1.AB ILLEGAL LABEL - FIRST CHARACTER NUMERIC ABC123 ILLEGAL LABEL - TRUNCATED TO ABC12 A*BC ILLEGAL LABEL - ASTERISK NOT ALLOWED IN LABEL ABC NO LABEL - THE ASSEMBLER ATTEMPTS TO INTERPRET ABC AS AN OPERATION CODE Each label must be unique within the program; two or more statements may not have the same symbolic name. Names which appear in the Operand field of an EXT or COM pseudo instruction may not also be used as statement labels in the same subprogram. Examples: 1 5 10 15 20 25 30 35 40 ---------------------------------------- COM ACOM(20),BC(30) LB EQU 160 VALID LABEL EXT XL1,XL2 START LDA LB VALID LABEL N25 VALID LABEL XL2 ILLEGAL LABEL - USED IN EXT BC ILLEGAL LABEL - USED IN COM N25 ILLEGAL LABEL - PREVIOUSLY DEFINED 2-4 ASTERISK An asterisk in position one indicates that the entire statement is a comment. Positions 2 through 80 are available; however, positions 1 through 68 only are printed as part of the assembly listing on the 2672A Teleprinter. An asterisk within the Label field is illegal in any position other than one. 2.3 OPCODE FIELD The operation code defines an operation to be performed by the computer or the Assembler. The Opcode field follows the Label field and is separated from it by at least one space. If there is no label, the operation code may begin anywhere after position one. The Opcode field is termated by a space im- mediately following an operation code. Operation codes are organized in the following categories: Machine operation codes Memory Reference Register Reference Input/Output, Overflow, and Halt Extended Arithmetic Unit Pseudo operation codes Assembler control Object program linkage Address and symbol definition Constant definition Storage allocation Arithmetic subroutine calls Assembly Listing Control (Extended Assembler) Operation codes are discussed in detail in Chapters 3 and 4. 2.4 OPERAND FIELD The meaning and format of the Operand field depend on the type of operation code used in the source statement. The field follows the Opcode field and is separated from it by at least one space. It is terminated by a space except when the space follows , + - ( or, if there are no comments, by an end-of- statement mark. 2-5 The operand field may contain an expression consisting of one of the following: Single symbolic term Single numeric term Asterisk Combination of symbolic terms, numeric terms, and the asterisk joined by the arithmetic operators + and -. An expression may be followed by a comma and an indicator. Programs being assembled by the Extended Assembler may also contain a literal value in the Operand field. SYMBOLIC TERMS A symbolic term may be one to five characters consisting of A through Z, 0 through 9, and the period. The first character must be alphabetic or a period. Examples: 1 5 10 15 20 25 30 35 40 ---------------------------------------- LDA A1234 VALID IF DEFINED ADA B.1 VALID IF DEFINED JMP ENTRY VALID IF DEFINED STA 1ABC ILLIGAL OPERAND - FIRST CHARACTER NUMERIC STB ABCDEF ILLEGAL OPERAND - MORE THAN FIVE CHARACTERS A symbol used in the Operand field must be a symbol that is defined elsewhere in the program in one of the following ways: As a label in the Label field of a machine operation As a label in the Label field of a BSS, ASC, DEC, OCT, DEF, ABS, EQU or REP pseudo operation As a name in the Operand field of a COM or EXT pseudo operation As a label in the Label field of an arithmetic subroutine pseudo operation. 2-6 The value of a symbol is absolute or relocatable depending on the assembly option selected by the user. The assembler as- signs a value to a symbol as it appears in one of the above fields of a statement. If a program is to be loaded in absolute form, the values assigned by the assembler remain fixed. If the program is to be relocated, the actual value of a symbol is established on loading. A symbol may also be made absolute through use of the EQU pseudo instruciotn. A symbolic term may be preceded by a plus or minus sign. If preceded by a plus or no sign, the symbol refers to its associ- ated value. If preceded by a minus sign, the symbol refers to the two's complement of its associated value. A single nega- tive sombolic operand may be used only with the ABS pseudo operation. NUMERIC TERMS A numeric term may be decimal or octal. A decimal number is represented by one to five digits within the range 0 to 32767. An octal number is represented by one to six octal digits followed by the letter B; (0 to 177777B). If a numeric term is preceded by a plus or no sign, the binary equivalent of the number is used in the object code. If pre- ceded by a minus sign, the two's complement of the binary equivalent is used. A negative numeric operand may be used only with the DEX, DEC, OCT, and ABS pseudo operations. In an absolute program, the maximum value of a numeric operand depends on the type of machine or psuedo instruction. In a relocatable program, the value or a numeric operand may not exceed 77B. Numeric operands are absolute. Their value is not altered by the assembler or the loader. ASTERISK An asterisk in the Operand field refers to the value in the program location counter (or base page location counter) at the time the source program statement is encountered. The asterisk is considered a relocatable term in a relocatable program. EXPRESSION OPERATORS The asterisk, symbols, and numbers may be joined by the arithmetic operators + and - to form arithmetic address ex- pressions. The Assembler evaluates an expression and pro- duces an absolute or relocatable value in the object code. 2-7 Examples: If P1 and P2 are program relocatable terms; B1 and B2, base page relocatable; C1 and C2, common relocatable; and A, an absolute term; then the following are absolute terms: A-C1+C2 A-P1+P2 C1-C2+A A+A P1-P2 B1-B2 *-P1 B1-B2-A -C1+C2+A B1-* -P1+P2 -A-P1+P2 The asterisk is base page relocatable or program relocatable depending on the location of the instruction. RELOCATABLE EXPRESSIONS A relocatable expression is one whose value is changed by the loader. All relocatable expressions must have a positive value. A relocatable expression may contain any odd number of relo- catable terms, alone, or in combination with absolute terms. All relocatable terms must be of the same type. Terms must be paired by sign with the odd term being positive. A relocatable expression reduces to a single positive relo- catable term, adjusted by the valued represented by the abso- lute terms and paired relocatable terms associated with it. Examples: If P1, P2 and P3 are program relocatable terms; B1, B2 and B3, base page relocatable; C1, C2 and C3, common relocatable; and A, an absolute term, then the following are relocatable terms: P1-A C1-A B1+A P1-P2+P3 C1-C2+C3 C1+A *+A *-P1+P2 *-A A+B1 A+C1 -A-P1+P2+P3 B1-B2+B3-A C1-C2+C3-A A+* *+P1-* P1-P2+* -C1+C2+C3 2-10 LITERALS Actual literal values may be specified as operands in re- locatable programs to be assembled by the Extended Assembler. The Extended Assembler converts the literal to its binary value, assigns an address to it, and substitutes this address as the operand. Locations assigned to literals are those immediately following the last location used by the program. A literal is specified by using an equal sign and a one- character identifier defining the type of the literal. The actual literal alue is specified immediately following this identifier; no spaces may intervene. The identifiers are: =D a decimal integer, in the range -32767 to 32767, including zero. [1] =F a floating-point number; any positive or negative real number in the range 10**-38 to 10**38, including zero. [1] =B an octal integer, one to six digits, b1b2b3b4b5b6, where b1 may be 0 or 1, and b2-b7 may be 0 to 7. [1] =A two ASCII characters. [1] =L an expression which, when evaluated, will result in an absolute value. All symbols appearing in the expression must be previously defined. If the same literal is used in more than one instruction, only one value is generated, and all instructions using this literal refer to the same location. Literals may be specified only in the following memory reference instructions and pseudo instructions: ADA DSB AND MPY \ LDA LDB XOR DIV > may use =D, =B, =A, =L CPA CPB IOR / DLD FAD \ FMP FSB > may use =F FDV / --------------------- [1] See CONSTANT DEFINITION, Section 4.4. 2-11 Examples: LDA =D7980 A-Register is loaded with the binary equiv- alent of 7980 base 10. IOR =B777 Inclusive "or" is performed with contents of A-Register and 777 base 8 LDA =ANO A-Register is loaded with binary representa- tion of ASCII characters NO. LDB =LZETZ-ZOOM+68 B-Register is loaded with the value resulting from the absolute expression FMP =F39.75 Contents of A- and B-Registers multiplied by floating-point constant 39.75. INDIRECT ADDRESSING The HP computers provide an indirect addressing capability for Memory Reference instructions. The operand portion of an indirect instruction contains an address of another location rather than an actual operand. The secondary location may be the oeprand or it may be indirect also and give yet another loacation, and so forth. The chaining ceases when a location is encountered that does not contain an indirect address. Indirect addressing provides a simplified method of address modifi- cations as wall as allowing access to any location in core. The Assembler allows specification of indirect addressing by appending a comma and the letter I to any Memory Reference operand other than one referring to an external symbol. The actual operand of the instruction may be given in a DEF pseudo operation; this pseudo operation may also be used to indicate further levels of indirect addressing. Examples: 1 5 10 15 20 25 30 35 40 ---------------------------------------- AB LDA SAM,I EACH TIME THE ISZ IS EXECUTED, AC ADA SAM,I THE EFFECTIVE OPERAND OF AB AND AD ISZ SAM AC CHANGE ACCORDINGLY. . . . SAM DEF ROGER 2-12 A relocatable assembly language program, however, may be designed without concern for the pages in which it will be stored; indirect addressing is not required in the source lan- guage. When the program is being loaded, the loader provides indirect addressing whenever it detects an operand which does not fall in the current page or the base page. The loader sub- stitutes a reference to the base page and then stores an indirect address in this referenced location. References to the same operand from other pages will be linked through the same loca- tion in the base page. BASE PAGE ADDRESSING The computer provides a capability which allows the Memory Reference instructions to address either the current page or the base page. The Assembler or the loader adjusts all instruc- tions in which the operands refer to the base page; specific nota- tion defining an operand as a base page reference is not required in the source program. CLEAR FLAG INDICATOR The majority of the input/output instructions can alter the status of the input/output interrupt flag after execution or after the particular test is performed. In source lanuage, this function is selected by appending a comma and a letter C to the Operand field. Examples: 1 5 10 15 20 25 30 35 40 ---------------------------------------- STC IO7,C CLEAR FLAG IO7 AFTER CONTROL BIT IS SET OTB IO5,C CLEAR FLAT IO5 AFTER MOVE 2.5 COMMENTS FIELD The comments field allows the user to transcribe notes on the program that will be listed with source language coding on the output produced by the Assembler. The field follows the Operand field and is separated form it by at least one space. The end-of-statement mark, (CR)(LF), or the80th character in the entire statement terminates the field. If the listing is to be produced on the 2752A Teleprinter, the total statement length, excluding the end-of-statement mark, should not ex- 2-13 ceed 52 characters, the width of the source language portion of the listing. Statements consisting solely of comments may contain up to 68 characters including the asterisk in the first position. On the list output, statements consisting entirely of comments begin in position 5 rather than 21 as with other source statements. If there is no operand present, the Comments field should be omitted in the NAM and END pseudo operations and in the input/ output statements SOC, SOS and HLT instruction. If a comment is used, the Assembler attempts to interpret it as an operand. 2-14