Thanks to @Joseinnewworld who just bought my #collection brutally, 13 #NFTs #Wow 😱! you are a whale🐳. Also, your chosen #NFT gift has been sent🤝 #eCash $XEC #CRYPTO #nftcollectors #NFTTrading #NFTCommuntiy #NFTMarketplace #BitcoinWhales pic.twitter.com/RzbnBt9r4W
— Gaexe (@gaexe_) February 2, 2025
Arithmetic Operation ADD
Arithmetic Operations ADD Assembly
ADD A,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 1 | 1 | ADD A,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Add Accumulator A with Rn where n = 0...7 and store the result in Accumulator A.
Example:
Add A,R7
Meaning: The contents of R7 will be added to accumulator A and the result is stored in Accumulator A.
ADD A,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|----------------|----|----|-----|-----|----|---|---|
| 1 | 2 | ADD A,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Add Accumulator A with the data at a specific memory address directly.
Example:
Add A,00H
Meaning: The contents of Accumulator A will be added to the contents of the Internal RAM memory at address 00H.
ADD A,@Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | |
|--------|--------------|-------------|----|----|-----|-----|----|---|
| 1 | 1 | ADD A,@Ri | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | P |
| | | X | X | | | | X | X |
Add Accumulator A with the data located at address Ri (pointed to by Ri) and the result is stored in Accumulator A. Ri is the Index Register which in MCS51 is either R0 or R1.
Example:
Add A,@R0
Meaning: The contents of Accumulator A will be added to the contents of the Internal RAM memory pointed to by R0. If R0 contains 05H then, the contents of the address 05H will be added to Accumulator A and the result is stored in Accumulator A.
ADD A,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | |
|--------|--------------|---------------|----|----|-----|-----|----|---|
| 1 | 2 | ADD A,#data | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | P |
| | | X | X | | | | X | X |
Add Accumulator A with a constant and the result is stored in accumulator A.
Example:
Add A,#05H
The contents of Accumulator A are added with the data 05H and the result is stored in Accumulator A.
ADDC A,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-------------|----|----|-----|-----|----|---|---|
| 1 | 1 | ADDC A,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Add Accumulator A with Rn where n = 0...7 and store the result in Accumulator A.
Example:
Addc A,R7
The contents of R7 will be added to accumulator A along with the carry flag and the result will be stored in accumulator A. If the carry flag is set, the result stored in accumulator A is A + R7 + 1.
ADDC A,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------------|----|----|-----|-----|----|---|---|
| 1 | 2 | ADDC A,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Add Accumulator A and carry flag with data at specified memory address directly.
Example:
Addc A,00H
The contents of Accumulator A will be added to the contents of the Internal RAM memory at address 00H along with the carry flag and the results are stored in Accumulator A. If the carry flag is set, the results stored in Accumulator A are A + the contents of address 00H + 1.
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 1 | ADDC A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Add Accumulator A along with the carry flag with the data at address Ri (pointed to by Ri) and the result is stored in Accumulator A. Ri is the Index Register which in MCS51 is either R0 or R1.
Example:
Add A,@R0
The contents of Accumulator A along with the carry flag will be added to the contents of the Internal RAM memory pointed to by R0. If R0 contains 05H then, the contents of the address 05H will be added to Accumulator A along with the carry flag and the result is stored in Accumulator A.
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|----------------|----|----|-----|-----|----|---|---|
| 1 | 2 | ADDC A,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Add Accumulator A along with the carry flag with a constant and the result is stored in accumulator A.
Example:
Addc A,#05H
The contents of Accumulator A along with the carry flag are added to the data 05H and the result is stored in Accumulator A. If the carry flag is set, the result in Accumulator A is A + 5H + 1.
SUBB Arithmetic Operation
SUBB A,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | SUBB A,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Perform data subtraction in Accumulator A with Rn (n = 0...7) and store the result in Accumulator A.
Example:
Subb A,R0
The data in accumulator A along with the carry flag is subtracted from the contents of R0 and the result is stored in Accumulator A.
SUBB A,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|---------------|----|----|-----|-----|----|---|---|
| 1 | 2 | SUBB A,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Perform a subtraction of the data in Accumulator A with the data in a specific memory that is directly pointed to.
Example:
Subb A,00H
The data in Accumulator A along with its carry flag is subtracted from the data at address 00H of Internal RAM and the result is stored in Accumulator A.
SUBB A,@Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|------------|----|----|-----|-----|----|---|---|
| 1 | 1 | SUBB A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Perform data reduction in Accumulator A along with the carry flag with the data pointed to by Ri (Register Index) where Ri can be R0 or R1.
Example:
SUBB A,@R0
The data in Accumulator A along with its carry flag is subtracted from the data pointed to by R0 and the result is stored in Accumulator A.
SUBB A,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | SUBB A,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | X | | X |
Perform data reduction in Accumulator A along with the carry flag with a constant and the result is stored in Accumulator A.
Example:
SUBB A,#05H
The data in Accumulator A along with the carry flag is subtracted from the data 05H and the result is stored in Accumulator A.
Arithmetic Operations INC
INC A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | INC A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Add the value of Accumulator A by 1 and the result is stored in Accumulator A.
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | INC Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Add the value of Rn (n= 0...7) by 1 and the result is stored in that Rn.
INC direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|------------|----|----|-----|-----|----|---|---|
| 1 | 2 | INC direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Add the data in Internal RAM whose address is pointed to directly with 1 and the result is stored at that address.
Example:
Inc 00H
The data at address 00H is added by 1 and the result is stored at address 00H.
INC @Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | INC @Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Add the data whose address is pointed to by Ri (Register Index) by 1 and store the result at that address.
Example:
Inc @R1
The data is at the address pointed to by R1 and the result is stored at that address, if R1 contains 10H then the data at address 10H is increased by 1 and stored back at address 10H.
INC DPTR
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 2 | 1 | INC DPTR | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Add 1 to the DPTR value and store the result in DPTR.
DEC Arithmetic Operations
DEC A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | DEC A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform a subtraction on the value of Accumulator A by 1 and the result is stored in Accumulator A.
DEC Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | DEC Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
DEC direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------|----|----|-----|-----|----|---|---|
| 1 | 2 | DEC direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform a subtraction on the data in the Internal RAM whose address is directly pointed to by 1 and the result is stored at that address.
Example:
Dec 00H
The data at address 00H is subtracted by 1 and the result is stored at address 00H.
DEC @Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | DEC @Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Perform a subtraction on the data whose address is pointed to by Ri (Register Index) by 1 and store the result at that address.
Example:
DEC @R1
The data at the address designated by R1 and the results are stored at that address, if R1 contains 10H then the data at address 10H is reduced by 1 and stored again at address 10H.
Arithmetic Operations MUL, DIV & DA
MUL AB
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 4 | 1 | MUL AB | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | X | | |
Mov A,#50H
Mov B,#0A0H
Mul AB
The result of multiplying 50H or 80 decimal with 0A0H or 160 decimal is 3200H or 12800, then the value stored in Accumulator A is 00H and in Register B is 32H. While the Overflow Flag will be set because the result of the multiplication is greater than 255 or (0FFH).
DIV AB
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 4 | 1 | DIV AB | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | X | | |
Perform division between Accumulator A and Register B, the result of the division will be stored in accumulator A and the remainder of the division will be stored in Register B. The Overflow and Carry flags will always be clear.
The Overflow Flag will be set if the contents of Register B are 00, which indicates that the division process is not possible because the result of dividing a number by 0 is infinite.
Example:
Mov A,#0FB
Mov B,#12H
Div AB
The result of this division is 0DH with a remainder of 11H, so 0DH will be stored in Accumulator A as the quotient and 11H will be stored in Register B as the remainder.
AND A
| iklus | Jumlah Byte | Instruksi | | | | | | | |
|-------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | DA A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | X | X | | | | | | |
Converting data in Accumulator A to BCD format. This instruction will convert an 8 bit data in Accumulator A in hexa form into 2 digits where the first digit in the upper nibble is bit 7...4 of Accumulator A and the second digit is the lower nibble is bit 3...0 of Accumulator A. Basically this instruction will add 6 if the low nibble is above 9 or the AC bit is set and add 6 if the high nibble is above 9 or the Carry bit is Set. This instruction is usually used after the ADD instruction.
Example 1:
Add A,#88H
DA A
The previous value of accumulator A was 99H, the result of adding 99H and 88H is 21H with the AC bit set and Carry set because the result of adding 9 and 8 in both the high and low nibbles is greater than 9. Because the AC bit is set and the carry bit is set, the result of adding the two nibbles is each added by 6 and produces 87H with the carry flag set.
Example 2:
Add A,#02H
DA A
The previous value of Accumulator A was 79H, the result of the addition with 02H is 7BH with the AC bit set because the result of the addition on the low nibble is greater than 9 and after passing the DA A instruction, 7BH will be added to 6H to become 81H.
In essence, if the conditions:
- Bit AC set, Bit Carry clear = Akumulator A ditambah 06H
- Bit AC clear, Bit Carry clear = Akumulator A ditambah 00H - Bit AC clear, Bit Carry set = Akumulator A ditambah 60H
- Bit AC set, Bit Carry set = Akumulator A ditambah 66H
The DA A instruction is not an instruction that converts hexadecimal numbers into decimal form easily, but this instruction functions to perform addition operations in BCD so that the result of adding 79H and 02H is not 7BH but 81H.
ANL Logic Operations
Performs AND operation between two variables and stores it in the destination variable. If the destination variable is an accumulator, then the other variable can use register (Rn), direct address, indirect or immediate data, if the destination variable is a direct address, then the other variable can use accumulator or immediate data.
ANL A,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | ANL A,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs AND operation between accumulator A and Rn (R0...R7) and the result is stored in accumulator A.
ANL A,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | ANL A,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an AND operation between accumulator A and the immediate address and the result is stored in accumulator A.
Example:
ANL A,05H
Accumulator A is ANDed with the data at address 05H and the result is stored in accumulator A.
ANL A,@Ri
| Siklus | Jumlah Byte | | Instruksi | | | | | | |
|--------|-------------|---|-----------|----|-----|-----|----|---|---|
| 1 | 1 | | ANL A,@Ri | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an AND operation between accumulator A and the data pointed to by the Index Register (R0 or R1) and the result is stored in accumulator A.
Example:
ANL A,@R0
Accumulator A is ANDed with the data pointed to by R0, for example R0 contains 50H, then accumulator A is ANDed with the data stored at address 50H and the result is stored in accumulator A.
ANL A,#data
| Siklus | Jumlah Byte | | Instruksi | | | | | | |
|--------|-------------|---|-------------|----|-----|-----|----|---|---|
| 1 | 2 | | ANL A,#data | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an AND operation between accumulator A and immediate data and stores the result in accumulator A.
ANL direct, A
| Siklus | Jumlah Byte | | Instruksi | | | | | | |
|--------|-------------|---|--------------|----|-----|-----|----|---|---|
| 1 | 2 | | ANL direct,A | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an AND operation between the direct address and accumulator A and stores the result at the direct address.
Example:
ANL 07H,A
The data at address 07H is ANDed with accumulator A and the result is stored again at address 07H.
ANL direct,#data
| Siklus | Kode Operasi | Instruksi | | | | | | | |
|--------|---------------|------------------|----|----|-----|-----|----|---|---|
| 2 | 3 | ANL direct,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an AND operation between the immediate address and the immediate data and the result is stored at the immediate address.
ORL Logic Operations
Performs an OR operation between two variables and stores it in the destination variable. If the destination variable is an accumulator, then the other variable can use a register (Rn), direct address, indirect address or immediate data, if the destination variable is a direct address, then the other variable can use an accumulator or immediate data.
ORL A,Rn
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | ORL A,Rn | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an OR operation between accumulator A and Rn (R0...R7) and the result is stored in accumulator A.
ORL A,direct
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | ORL A,direct | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an OR operation between accumulator A and the immediate address and the result is stored in accumulator A.
Example:
ORL A,05H
Accumulator A is ORed with the data at address 05H and the result is stored in accumulator A.
ORL A,@Ri
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-----------|----|----|-----|-----|----|---|---|
| 1 | 1 | ORL A,@Ri | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an OR operation between accumulator A and the data pointed to by the Index Register (R0 or R1) and the result is stored in accumulator A.
Example:
ORL A,@R0
Accumulator A is ORed with the data pointed to by R0, for example R0 contains 50H, then accumulator A is ORed with the data stored at address 50H and the result is stored in accumulator A.
ORL A,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|-------------|----|----|-----|-----|----|---|---|
| 1 | 2 | ORL A,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an OR operation between accumulator A and immediate data and the result is stored in accumulator A.
ORL direct,A
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|-------------|--------------|----|----|-----|-----|----|---|---|
| 1 | 2 | ORL direct,A | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an OR operation between the direct address and accumulator A and the result is stored at the direct address.
Example:
ORL 07H,A
The data at address 07H is ORed with accumulator A and the result is stored again at address 07H.
ORL direct,#data
| Siklus | Jumlah Byte | Instruksi | | | | | | | |
|--------|--------------|------------------|----|----|-----|-----|----|---|---|
| 2 | 3 | ORL direct,#data | | | | | | | |
| Flag | | C | AC | F0 | RS1 | RS0 | OV | | P |
| | | | | | | | | | |
Performs an OR operation between accumulator A and immediate data and the result is stored in accumulator A.