- MUL AB
Multiplies the unsigned 8-bit integer in the accumulator and the unsigned 8-bit integer in the B register producing a 16-bit product.
A<--The low-order byte of the product
B<--The high-order byte of the product
OV flag is set if the product is greater than 255 (0FFh), otherwise it is cleared.
The carry flag is always cleared.
Similarly there is DIV AB in which quotient is stored in A and remainder in B register - DA A
Decimal adjust Accumulator. This deals with BCD. The DA instruction adjusts the eight-bit value in the Accumulator resulting from the earlier addition of two variablesIf Accumulator bits 3-0 are greater than 9 or if the AC flag is 1, 06 is added to the Accumulator, producing the proper BCD digit in the low-order nibble.
If the carry flag is now set, or if the four high-order bits now exceed 9 these high-order bits are incremented by six, producing the proper BCD digit in the high-order nibble.
DJNZ
DJNZ instruction decrements the byte indicated by the first operand and, if the resulting value is not zero, branches to the address specified in the second operand.
DJNZ R2, Label-> means Decrement R2 and if R2 is not equal to zero jump to the address location indicated by LabelLCALL
LCALL (3byte instruction) instruction calls a subroutine located at the specified address.First byte is the opcode and the second and third bytes are used for the address of the target subroutine. Therefore, LCALL can be used to call subroutines located anywhere within the 64K-byte address space of the 8051.
ACALL is another instruction which works similar to LCALL, the difference is that it is a 2 byte instruction. The target address of the subroutine must be within 2K bytes because only 11 bits of the 2 bytes are used for the address.What an LCALL op actually does
LCALL PC = PC + 3 SP = SP + 1 (SP) = PC[7-0] SP = SP + 1 (SP) = PC[15-8] PC = addr16- PUSH and POP
PUSH instruction increments the stack pointer (by default SP is 07H) and stores the value of the specified byte operand at the internal RAM address referenced by the stack pointer.
POP on the other hand reads a byte from the address indirectly referenced by the SP register. The value read is stored at the specified address and the stack pointer is decremented.
So PUSH writes to stack and POP reads from stack. - XCHD
Exchanges the low-order nibble of the accumulator with the low-order nibble of the specified RAM location
XCHD A,@R5---means swap lower order bits(0-3) of register 5 and Accumulator.
XCH is a similar instruction which swaps the byte value of the specified operand - RETI
This will end an ISR. On execution the program control returns to the instruction immediately after the point at which the interrupt was detected. If there is another pending interrupt when the RETI instruction is executed, one instruction at the return address is executed before the pending interrupt is processed. - RLC
Rotate left 8 bits in the accumulator through carry (both A and CY are rotated). Similar instruction include RRC, RR, RL. - SWAP
SWAP instruction exchanges the low-order and high-order nibbles within the accumulator - CJNE
The Compare and jump if not equal instruction compares the first two operands and branches to the specified destination if their values are not equal. If the values are the same, execution continues with the next instruction.
Besides these there bit manipulation instructions like SETB, JB, JNB which are also important. Also take note of SJMP, CPL.
Thursday, April 29
TOP TEN INSTRUCTIONS OF 8051 FOR COMPETITIVE EXAMS
This list includes some of the instructions of 8051 which you should not miss out while preparing for any kind of exams
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment