Home ยป Microprocessors ยป Programming Microprocessors ยป Basic Microprocessor Instructions

Basic Microprocessor Instructions

Microprocessors perform various basic operations that include data transfer instructions, arithmetic instructions, logic instructions, control transfer instructions and machine control operations. This set of commands (instructions set) used to control the functions of a microprocessor is specific to a given microprocessor. In this article, we look at examples of these instructions focusing on Intel 8085 microprocessor.

Basic Microprocessor Instructions

Data Transfer Instructions

Data transfer instructions transfer data from one location designated as the source location to another location designated as the destination. The data transfer could take place from one register to another, from one memory location to another memory location, from a memory location to a register or from a register to a memory location, and so forth. In other words, they are referred to as data movement operations as the contents of the source are not transferred but are copied into the destination register, without modifying the contents of the source. Also note that, these operations do not affect the flags.

Data transfer operations of 8085 microprocessor are of three types, namely MOVE, LOAD and STORE.

Table 1.0 Data Transfer Operations

Data transfer instructionsDescriptions
MOV destination, sourceCopy data from the source to the destination location.
LDA addressCopy the data byte at the memory location specified by the 16-bit address of the accumulator.
STA addressCopy the data from the accumulator to the memory location specified by the 16-bit address.

Arithmetic Instructions

Arithmetic instructions performed by microprocessors include addition, subtraction, multiplication, division, comparison, negation, increment and decrement. A number of 8-bit microprocessors donโ€™t support multiplication and division operations. These operations are supported by the 16-bit and 32-bit microprocessors. The arithmetic operations supported by the 8085 microprocessor are: addition, subtraction, increment and decrement operations. Examples of 8085 microprocessor instructions are as indicated in the table below:

Table 1.1 Arithmetic Instructions

Arithmetic InstructionDescriptions
ADD RAdds the contents of the register to the accumulator.
ADI d8Adds the 8-bit data to the accumulator. The d8 stands for any 8-bit or 1-byte data.
SUB RSubtracts the contents of the register from the accumulator.
SUI d8Subtracts 8-bit data from the contents of the accumulator.
INR RIncrements the contents of the register.
DCR RDecrements the contents of the register.

Logic Instructions

Microprocessors can perform all the logic functions of hard-wired logic. The basic operations performed by all microprocessors are: AND, OR, NOT, and EXCLUSIVE-OR. Other logic operations include: shift and rotate operations. All these operations are performed on a bit-for-bit basis on bytes or words. For example, 11111111 AND 10111010 equals 10111010, and 11111111 OR 10111010 equals 11111111. Some microprocessors also perform bit-level instructions such as set bit, clear bit and complement bit operations. It is important to note that, logic operations always clear the carry and overflow flags, while the other flags change to reflect that condition of the result.

The basic shift operations are the shift left and shift right operations. In the shift left operation, also referred to as the arithmetic shift left, all bits are shifted one position to the left, with the rightmost bit set to 0 and the leftmost bit transferred to the carry position in the status register. In the shift right operation, also referred to as logic shift right, all bits are shifted one bit position to the right, with the leftmost bit set to 0 and the rightmost bit transferred to the carry position in the status register. If in the shift right operation the leftmost bit is left unchanged, it is called arithmetic shift right. In a rotate operation, the bits are circulated back into the register. Carry may or may not be included. As an example, in a rotate left with carry included, the rightmost bit goes to the carry position and the carry bit takes the position of the leftmost bit.

Examples 8085 microprocessor logic instructions are given in the table below:

Table 1.2 Logic Instructions

Logic InstructionsDescriptions
ANA R/MLogically AND the contents of the register/memory with the contents of the accumulator.
ANI d8Logically AND the 8-bit data (d8) with the contents of the accumulator.
ORI d8Logically OR the 8-bit data (d8) with the contents of the accumulator.
XRA R/MLogically EXCLUSIVE-OR the 8-bit data with the contents of the register memory with the contents of the accumulator.
CMAComplement the contents of the accumulator.
RLCRotate each bit in the accumulator to the left position.
RRCRotate each bit in the accumulator to the right position.

Transfer Control or Branch or Program Control Instructions

Microprocessors execute machine codes from one memory location to the next, i.e. they execute instructions is a sequential manner. Branch instructions change the flow of the program either unconditionally or under certain test conditions. Branch instructions include โ€˜jumpโ€™, โ€˜callโ€™, and โ€˜interruptโ€™.

โ€˜Jumpโ€™ instructions are of two types, namely, โ€˜unconditional jumpโ€™ instructions and โ€˜conditional jumpโ€™ instructions. If the microprocessor is so instructed as to load a new address in the program counter and start executing instructions at that address, it is referred to as unconditional jump. In the case of a conditional jump, the program counter is loaded with a new instruction address only if and when certain conditions are determined by the microprocessor after reading the appropriate status register bits. โ€˜Callโ€™ instructions transfer the flow of the program to a subroutine. The โ€˜callโ€™ instruction differs from the โ€˜jumpโ€™ instruction as โ€˜callโ€™ saves a return address (the address of the program counter plus one) on the stack. The โ€˜returnโ€™ instruction returns the control to the instruction whose address was stored in the stack when the โ€˜callโ€™ instruction was encountered. โ€˜Interruptโ€™ is hardware-generated call (externally driven from a hardware signal) or a software-generated call (internally derived from the execution of an instruction or by some internal event).

Examples of 8085 microprocessor transfer control instructions are as shown in the table below:

Table 1.3 Transfer Control Instructions

Transfer Control InstructionsDescriptions
JMP 16-bit addressChange the program sequence to the location specified by the 16-bit address.
JZ 16-bit addressChange the program sequence to the location specified by the 16-bit address if a zero flag is set.
JC 16-bit addressChange the program sequence to the location specified by the 16-bit address if a carry flag is set.
CALL 16-bit addressChange the program sequence to the location of the subroutine specified by the 16-bit address.
RETReturn to the calling program.

Machine Control Instructions

Machine control instructions include HALT and NOP instructions. Machine control instructions that are performed by the 8085 microprocessor include:

Table 1.4 Machine Control Instructions

Machine Control InstructionsDescriptions
HLTStop processing and wait.
NOPNo operation.
Please follow us and share:

Comments

5 responses to “Basic Microprocessor Instructions”

  1. […] Basic Microprocessor Instructions […]

Leave a Reply

Currently trending: