Op-codes


The VAX has about 256 op-codes, ie. about 256 fundamental operations (some cheaper VAXes leave some operations out, some expensive VAXes use tricks to implement more than 256 operations.)

So the opcode part of a machine instruction is usually one byte.

There may be up to 6 fields of the machine instruction used to specify operands. Usually there are one, two, or three operands.

A operand specifier field of a machine instruction may take up several bytes. Details on how a VAX machine instruction are in chapter 8. Here is an example from an assembly listing, Figure 5.2, p. 72,(just look it over, don't try to figure out every detail):

  machine language        address     line of assembly language
  -------^--------        ---^---    -------------^-------------
FF62 CF FF49 CF 14 28       00C9     MOVC3 #NAMESIZE,LINEIN,NAME   
------- -------  ^ ^
   |       |     | |
   |       |     | +--- opcode
   |       |     |
   |       |     +--- operand one
   |       |
   |       +--- operand two
   |
   +--- operand three

Recall that VAX software shows the bytes in increasing addresses from right to left, so that the opcode "28" is at (relative) address 00C9, the next byte "14" is at address 00CA, and so on.

Mnemonics

"Mnemonic" means "memory aid", from the Greek word for memory. Back in the days when programmers actually did program by writing machine code directly, it was hard to remember opcodes. So, programmers started using "mnemonics" like MOVC3 instead of opcodes like 28. (Actually, this was long before VAXes were available.)

A VAX mnemonic stands for one opcode---an 8-bit pattern. Some opcodes have more than one mnemonic, since the exact same bit operations might be used in different contexts.

A mnemonic for an opcode shows three things---the operation performed, the type of the data, and how many operands. For example:

      MULW3
      ---^^
       | ||
       | |+----- how many operands (3)
       | |
       | +------ type of the data (integer words)
       |
       +-------- operation (multiply integer)

A table of mnemonics and their corresponding opcodes can be found in appendix A. When the assembler translates a mnemonic into an 8-bit opcode, it just looks up the symbol in a table and outputs the corresponding bits. For example, MULW3 corresponds to opcode A5. Other than looking it up in a table, there is no way to tell this.

You can only use the mnemonics in appendix A (and your machine language program can only use the opcodes they correspond to.)

The number of operands is omitted when there is only one opcode for a particular type of operation, so the number of operands it takes is clear.

A mnemonic usually uses one letter to show the type of the operands:

      letter      type of operand
      ------      ---------------
        B         byte     (1 byte )
        W         word     (2 bytes)
        L         longword (4 bytes)
        Q         quadword (8 bytes)
        O         octaword (16 bytes)
        P         packed decimal
        
        F         floating point (single precision)
        D         floating point (double precision)
        G         special floating point type
        H         special floating point type
        
        C         character string
        V         variable-length bit field
      

We will almost always only use B, W, L, P, and C. The several varieties of floating point types are needed for compatibility with other architectures.


QUESTION 5:

What operation do you suppose the mnemonic SUBB2 stands for?


ANSWERS:

  1. Subtract Binary, two operands.
  2. Subtract Bits, two operands.
  3. Subtract Bytes, two operands.
  4. Take two bytes from a Submarine sandwich.