Syntax : CPL operand
Example : CPL A
It will complement the data in Accumulator. If the data is 0 then the result will be 255.
- Instruction
- Opcode
- Bytes
- Flags
- CPL A
- 0xF4
- 1
- None
- CPL C
- 0xB3
- 1
- C
- CPL bit_addr
- 0xB2
- 2
- None
KRM Schools |
|
CPL complements operand, leaving the result in operand. If operand is a single bit then the state of the bit will be reversed. If operand is the Accumulator then all the bits in the Accumulator will be reversed. Syntax : CPL operand Example : CPL A It will complement the data in Accumulator. If the data is 0 then the result will be 255.
0 Comments
DJNZ decrements the value of register by 1. If the initial value of register is 0, decrementing the value will cause it to reset to 255 (0xFF Hex). If the new value of register is not 0 the program will branch to the address indicated by addr. If the new value of register is 0 program flow continues with the instruction following the DJNZ instruction. Syntax : DJNZ register,addr Example : DJNZ R0,#40H It decrements the data in R0 by 1. After this If R0 is not 0 then it will jump to krm otherwise program continues by next instructions.
CJNE compares the value of operand1 and operand2 and branches to the indicated relative address if operand1 and operand2 are not equal. If the two operands are equal program flow continues with the instruction following the CJNE instruction. Syntax : CJNE operand1,operand2,addr Example : CJNE R1,#50H,krm It will compare if the data in R1 is equal to 50H or not. If they both are not equal then PC will jump to the kr. If data in R1 is less than 50H then carry flag will be set. If it is greater than 50H then carry flag will be cleared.
XRL does a bitwise "EXCLUSIVE OR" operation between operand1 and operand2, leaving the resulting value in operand1. The value of operand2 is not affected. A logical "EXCLUSIVE OR" compares the bits of each operand and sets the corresponding bit in the resulting byte if the bit was set in either (but not both) of the original operands, otherwise the bit is cleared. Syntax : XRL operand1,operand2 Example : XRL A,R0 It will perform the exor operation between the data in accumulator and register R0 and stores the result in accumulator.
ORL does a bitwise "OR" operation between operand1 and operand2, leaving the resulting value in operand1. The value of operand2 is not affected. A logical "OR" compares the bits of each operand and sets the corresponding bit in the resulting byte if the bit was set in either of the original operands, otherwise the resulting bit is cleared. Syntax : ORL operand1,operand2 Example : ORL A,R0 It will perform the OR operation between the data of accumulator and register R0
ANL does a bitwise "AND" operation between operand1 and operand2, leaving the resulting value in operand1. The value of operand2 is not affected. A logical "AND" compares the bits of each operand and sets the corresponding bit in the resulting byte only if the bit was set in both of the original operands, otherwise the resulting bit is cleared. Syntax : ANL operand1,operand2 Example : ANL A,R0 It will perform the and operation between accumulator and R0. The result is stored in the accumulator.
JB branches to the address indicated by addr if the bit indicated by the bit_addr is set otherwise program execution continues with the next instruction. Syntax : JB bit_addr,addr Example : JB P1.3,krm MOV A,R0 It will jump to krm if the P1.3 is set otherwise it will perform the next instruction MOV A,R0
JBC branches to the address indicated by addr if the the bit indicated by bit_addr is set. Before jumping to the addr it clears that bit. If the bit is not set then program execution continues with the next instruction. Syntax : JBC bit_addr,addr Example : JBC P1.3,krm MOV A,R0 It will jump to krm if the P1.3 is set otherwise it will perform the next instruction MOV A,R0.
JC branches to the address indicated by addr if the carry flag is set otherwise program execution continues with the next instruction. Syntax : JC addr Example : JC krm MOV A,R0 It will jump to krm if the carry flag is set otherwise it will perform the next instruction MOV A,R0
JMP jumps unconditionally to the address represented by the sum of the value of DPTR and the value of the Accumulator. No flags are affected. Syntax : JMP addr Example : JMP @A+DPTR It will jump to the address indicated by the sum of the data in accumulator and DPTR.
JNB branches to the address indicated by addr if bit indicated in the instruction is not set or it is 0 otherwise program execution continues with the next instruction. Syntax : JNB bit_addr,addr Example : JNB P1.3,krm MOV A,R0 It will jump to krm if the pin no.3 of PORT 1 is not set otherwise it will perform the next instruction MOV A,R0.
JNC branches to the address indicated by addr if the value of the carry flag is not 0. If the value of the Carry Flag is zero program execution continues with the next instruction. Syntax : JNC addr Example : JNC krm MOV A,R0 It will jump to krm if the value of the carry flag is not 0 otherwise it will perform the next instruction MOV A,R0
JNZ branches to the address indicated by addr if the value in the accumulator is not 0. If the value of the Accumulator is zero then program execution continues with the next instruction. Syntax : JNZ addr Example : JNZ krm MOV A,R0 It will jump to krm if the value in the accumulator is not 0 otherwise it will perform the next instruction MOV A,R0
JZ branches to the address indicated by addr if the value in the accumulator is 0. If the value of the Accumulator is non-zero program execution continues with the next instruction. Syntax : JZ addr Example : JZ krm MOV A,R0 It will jump to krm if the value in the accumulator is 0 otherwise it will perform the next instruction MOV A,R0
LCALL calls a program subroutine. LCALL increments the program counter by 3 (to point to the instruction following LCALL) and pushes that value onto the stack (low byte first, high byte second). The Program Counter is then set to the 16-bit value which follows the LCALL opcode, causing program execution to continue at that address. Syntax : LCALL addr Example : LCALL school It will call the subroutine school in the program.
LJMP jumps unconditionally to the specified addr. It is generally used for long jump in the program. Syntax : LJMP addr Example : LJMP krm It will jump to the routine krm in the program.
SJMP jumps unconditionally to the address specified addr. addr must be within -128 or +127 bytes of the instruction that follows the SJMP instruction. It is generally used for short jump in the program. Syntax : SJMP addr Example : SJMP weebly It will jump the PC to the weebly routine in the program.
AJMP unconditionally jumps to the indicated code address. The new value for the Program Counter is calculated by replacing the least-significant-byte of the Program Counter with the second byte of the AJMP instruction, and replacing bits 0-2 of the most-significant-byte of the Program Counter with 3 bits that indicate the page of the byte following the AJMP instruction. Bits 3-7 of the most-significant-byte of the Program Counter remain unchanged. Since only 11 bits of the Program Counter are affected by AJMP, jumps may only be made to code located within the same 2k block as the first byte that follows AJMP. Syntax : AJMP code address Example : AJMP weebly It will jump to routine weebly in the program
ADDC adds the value operand to the value of the Accumulator and Carry flag, leaving the resulting value in the Accumulator. The value operand is not affected. ADDC adds the value of operand as well as the value of the Carry flag. If the addition of the Accumulator, operand and the Carry flag treated as signed values results in a value that is out of the range of a signed byte (-128 through +127) the Overflow flag is set. Otherwise, the Overflow flag is cleared. If the unsigned summed value of the low nibble of the Accumulator, operand and the Carry flag exceeds 15 the Auxillary Carry flag is set. Otherwise, the Auxillary Carry flag is cleared. If the unsigned summed value of the Accumulator, operand and the Carry flag exceeds 255 Carry is set. Otherwise, the Carry bit is cleared. Syntax : ADDC A,operand Example : ADDC A,#20 => It will add 20 to the value in the accumulator and the carry flag and store the result in the accumulator ADDC A,20h => It will add the value at location 20h with the value in the accumulator and the carry flag and store the result in the accumulator ADDC A,@R0 => It will add the value at the location indicated by R0 regsiter with the value in the accumulator and the carry flag and store the result in the accumulator ADDC A,R5 => It will add the value in the register R5 with the value in the accumulator and the carry flag and store the result in the accumulator
ADD adds the value operand to the value of the Accumulator, leaving the resulting value in the Accumulator. The value operand is not affected. ADD function identically. ADD does not add the Carry flag to the result. If the unsigned summed value of the Accumulator, operand exceeds 255 Carry is set. Otherwise, the Carry bit is cleared. If the unsigned summed value of the low nibble of the Accumulator, operand exceeds 15 the Auxillary Carry flag is set. Otherwise, the Auxillary Carry flag is cleared. If the addition of the Accumulator, operand treated as signed values results in a value that is out of the range of a signed byte (-128 through +127) the Overflow flag is set. Otherwise, the Overflow flag is cleared. Syntax : ADD A,operand Example : ADD A,#20 => It will add 20 to the value in the accumulator and store the result in the accumulator ADD A,20h => It will add the value at location 20h with the value in the accumulator and store the result in the accumulator ADD A,@R0 => It will add the value at the location indicated by R0 regsiter with the value in the accumulator and store the result in the accumulator ADD A,R5 => It will add the value in the register R5 with the value in the accumulator and store the result in the accumulator
ACALL unconditionally calls a subroutine at the indicated code address. ACALL pushes the address of the instruction that follows ACALL onto the stack, least-significant-byte first, most-significant-byte second. The Program Counter is then updated so that program execution continues at the indicated address. The new value for the Program Counter is calculated by replacing the least-significant-byte of the Program Counter with the second byte of the ACALL instruction, and replacing bits 0-2 of the most-significant-byte of the Program Counter with 3 bits that indicate the page. Bits 3-7 of the most-significant-byte of the Program Counter remain unchaged. Since only 11 bits of the Program Counter are affected by ACALL, calls may only be made to routines located within the same 2k block as the first byte that follows ACALL. Syntax : ACALL code address Eample : ACALL weebly This instruction will call routine weebly. Operation : PC = PC + 2 SP = SP + 1 (SP) = PC7-0 SP = SP + 1 (SP) = PC15-8 PC10-0 = A10-0
Program : MOV A,#50H MOV R0,#10H ADD A,R0 Accumulator Content :
CLR clears (sets to 0) all the bit(s) of the indicated register. If the register is a bit (including the carry bit), only the specified bit is affected. Clearing the Accumulator sets the Accumulator's value to 0. Syntax : CLR register Example : CLR A This instruction will clear all the contents of the accumulator.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |