Arithmetic Operations
The ability to perform certain arithmetic operations and data manipulation is a necessary feature
of most microcontroller applications. Within the Holtek microcontroller instruction set are a range
of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out.
Care must be taken to ensure correct handling of carry and borrow data when results exceed 255
for addition and less than 0 for subtraction. The increment and decrement instructions INC, INCA,
DEC and DECA provide a simple means of increasing or decreasing by a value of one of the val-
ues in the destination specified.
Logical and Rotate Operations
The standard logical operations, such as AND, OR, XOR and CPL all have their own instruction
within the Holtek microcontroller instruction set. As with the case of most instructions involving
data manipulation, data must pass through the Accumulator which may involve additional pro-
gramming steps. In all logical data operations, the zero flag may be set if the result of the operation
is zero. Another form of logical data manipulation comes from the rotate instructions, such as RR,
RL, RRC and RLC which provide a simple means of rotating one bit right or left. Different rotate
instructions exist depending on program requirements. Rotate instructions are useful for serial
port programming applications where data can be rotated from an internal register into the carry
bit from where it can be examined and the necessary serial bit set high or low. Another application
where rotate data operations are used is to implement multiplication and division calculations.
Branches and Control Transfer
Program branching takes the form of either jumps to specified locations using the JMP instruction
or to a subroutine using the CALL instruction. They differ in the sense that in the case of a subrou-
tine call, the program must return to the instruction immediately when the subroutine has been car-
ried out. This is done by placing a return instruction RET in the subroutine which will cause the
program to jump back to the address right after the CALL instruction. In the case of a JMP instruc-
tion, the program simply jumps to the desired location. There is no requirement to jump back to the
original jumping off point as in the case of the CALL. One special and extremely useful set of
branch instructions are the conditional branches. Here a decision is first made regarding the condi-
tion of a certain Data Memory or individual bits. Depending upon the conditions, the program will
continue with the next instruction or skip over it and jump to the following instruction. These instruc-
tions are the key to decision making and branching within the program, perhaps determined by the
condition of certain input switches or by the condition of internal data bits.
Bit Operations
The ability to provide single bit operations on Data Memory is an extremely flexible feature of all
Holtek microcontrollers. This feature is especially useful for output port bit programming where in-
dividual bits or port pins can be directly set high or low using either the
[m].i² or
[m].i² in-
structions respectively. The feature removes the need for programmers to first read the 8-bit
output port, manipulate the input data to ensure that other bits are not changed and then output
the port with the correct new data. This read-modify-write process is taken care of automatically
when these bit operation instructions are used.
Home Index Bookmark Pages Text
Previous Next
Pages: Home Index