MsgBox "My First Excel VBA Program"
MsgBox is an instruction which you can use to give some message, warning,error or to inform macro is executed successfully. It is a simple instruction. Place a command button on your worksheet and add the following code.
MsgBox "My First Excel VBA Program"
We can apply if statement by using the following method. This is how we generally define If statement.
if ( condition )
The part in the curly bracket can be replaced by assigning a label
krm : --------------------------------------------
Here condition can have three types :
We will see how to convert each condition in assembly language.
Let assume b=05H and if the condition is true then Program Counter should go to label krm. Value of a is in the accumulator.
For less than condition use following code
dio : JC krm
For equality condition use following code :
For greater than condition use following code
dio : JNC krm
Here we have considered that data with which we want to compare the value of b is in accumulator. You can take other registers also like R0,R1 etc. To know more about how to use CJNE instruction visit on below link.
VHDL (VHSIC Hardware Description Language) is a hardware description language used in electronic design automation to describe digital and mixed-signal systems such as field-programmable gate arrays and integrated circuits. VHDL can also be used as a general purpose parallel programming language.
The First instruction will copy the 50H in Accumulator. Second Instruction will copy 2CH in the Register B. Third instruction is to divide the data in Accumulator by the data in Register B. After Division Remainder is stored in B register while Quotient is saved in the Accumulator. Fourth and Fifth instructions are to move the Quotient and Remainder in the R0 and R1 register respectively.
MOVX moves a byte to or from External Memory into or from the Accumulator. If operand1 is @DPTR, the Accumulator is moved to the 16-bit External Memory address indicated by DPTR. This instruction uses both P0 (port 0) and P2 (port 2) to output the 16-bit address and data. If operand2 is DPTR then the byte is moved from External Memory into the Accumulator.
If operand1 is @R0 or @R1, the Accumulator is moved to the 8-bit External Memory address indicated by the specified Register. This instruction uses only P0 (port 0) to output the 8-bit address and data. P2 (port 2) is not affected. If operand2 is @R0 or @R1 then the byte is moved from External Memory into the Accumulator.
Syntax : MOVX operand1,operand2
Example : MOVX A,@R0
MOVC moves a byte from Code Memory into the Accumulator. The Code Memory address from which the byte will be moved is calculated by summing the value of the Accumulator with either DPTR or the Program Counter (PC). In the case of the Program Counter, PC is first incremented by 1 before being summed with the Accumulator.
Syntax : MOVC A,@A+register
Example : MOVC A,@A+DPTR
It will move the data in the Accumulator from the memory location whose address is indicated by A+DPTR.
MOV copies the value of operand2 into operand1. The value of operand2 is not affected. Both operand1 and operand2 must be in Internal RAM. No flags are affected unless the instruction is moving the value of a bit into the carry bit.
Syntax : MOV operand1,operand2
Example : MOV A,R0
It will move the data in R0 register into Accumulator. The data in R0 register remains unchanged.
This instructions swap or exchange the higher order bits (bit no. 4 to 7) of Accumulator with lower order bits ( bit no. 0 to 3) of Accumulator. This instruction is similar to executing RRA or RLA instruction 4 times.
Syntax : SWAP A
Example : SWAP A
SUBB subtract the value of operand from the value of the Accumulator, leaving the resulting value in the Accumulator. The value operand is not affected. If a borrow was required for bit 7, otherwise it is cleared. In other words, if the unsigned value being subtracted is greater than the Accumulator the Carry Flag is set. If a borrow was required for bit 3, otherwise it is cleared. In other words, the bit is set if the low nibble of the value being subtracted was greater than the low nibble of the Accumulator. If a borrow was required for bit 6 or for bit 7, but not both. In other words, the subtraction of two signed bytes resulted in a value outside the range of a signed byte (-128 to 127). Otherwise it is cleared.
Syntax : SUBB A,operand
Example : SUBB A,R0
In this the content in the register R0 will be subtracted from content in accumulator. The result will be stored in Accumulator.
This instruction exchanges the value of the Accumulator with the value contained in register.
Syntax : XCH A,register
Example : XCH A,R0
It exchanges the contents of accumulator and register R0.
XCHD exchanges bits 0-3 of the Accumulator with bits 0-3 of the Internal RAM address pointed to indirectly by R0 or R1. Bits 4-7 of each register are unaffected.
Syntax : XCHD A,[@R0 or @R1]
Example : XCHD A,@R1
It will exchange lower order bits of accumulator with lower bits of memory address specified by R1 register.
SETB instructions sets the particular bit indicated by bit_addr.
Syntax : SETB bit_addr
Example : SETB C
It sets the carry flag.
The RRC instruction rotates the eight bits in the accumulator and the one bit in the carry flag right one bit position. Bit 0 of the accumulator is rotated into the carry flag while the original value of the carry flag is rotated in to bit 7 of the accumulator. Bit 7 of the accumulator is rotated into bit 6, bit 6 into bit 5, and so on. No other flags are affected by this instruction.
Syntax : RRC A
Example : RRC A
Shifts the bits of the Accumulator to the right. The right-most bit (bit 0) of the Accumulator is loaded into bit 7.
Syntax : RR A
Example : RR A
The RLC instruction rotates the eight bits in the accumulator and the one bit in the carry flag left one bit position. Bit 7 of the accumulator is rotated into the carry flag while the original value of the carry flag is rotated into bit 0 of the accumulator. Bit 0 of the accumulator is rotated into bit 1, bit 1 into bit 2, and so on. No other flags are affected by this operation.
Syntax : RLC A
Example : RLC A
RL Shifts the bits of the Accumulator to the left. The left-most bit (bit 7) of the Accumulator is loaded into bit 0.
Syntax : RL
Example : RL A
RETI is used to return from an interrupt service routine. RETI first enables interrupts of equal and lower priorities to the interrupt that is terminating. Program execution continues at the address that is calculated by popping the topmost 2 bytes off the stack. The most-significant-byte is popped off the stack first, followed by the least-significant-byte.
Syntax : RETI
Example : RETI
The RET instruction pops the high-order and low-order bytes of the PC from the stack (and decrements the stack pointer by 2). Program execution resumes from the resulting address which is typically the instruction following an ACALL or LCALL instruction. No flags are affected by this instruction.
Syntax : RET
Example : RET
The PUSH instruction increments the stack pointer and stores the value of the specified byte operand at the internal RAM address indirectly referenced by the stack pointer. No flags are affected by this instruction.
Syntax : PUSH
Example : PUSH
POP "pops" the last value placed on the stack into the iram_addr specified. In other words, POP will load iram_addr with the value of the Internal RAM address pointed to by the current Stack Pointer. The stack pointer is then decremented by 1.
Syntax : POP
Example : POP
NOP, as it's name suggests, causes No Operation to take place for one machine cycle. NOP is generally used only for timing purposes. Absolutely no flags or registers are affected.
Syntax : NOP
Example : NOP
The MUL instruction multiplies the unsigned 8-bit integer in the accumulator and the unsigned 8-bit integer in the B register producing a 16-bit product. The low-order byte of the product is returned in the accumulator. The high-order byte of the product is returned in the B register. The OV flag is set if the product is greater than 255 (0FFh), otherwise it is cleared. The carry flag is always cleared.
Syntax : MUL AB
Example : MUL AB
It multiplies the data in Accumulator and B register. Lower order bytes of result is stored in accumulator and higher order bytes is stored in B register.
The DIV instruction divides the unsigned 8-bit integer in the accumulator by the unsigned 8-bit integer in register B. After the division, the quotient is stored in the accumulator and the remainder is stored in the B register. The carry and OV flags are cleared.
If the B register begins with a value of 00h the division operation is undefined, the values of the accumulator and B register are undefined after the division, and the OV flag will be set indicating a division-by-zero error.
Syntax : DIV AB
Example : DIV AB
It will divide the content of accumulator by data in B register and the quotient will be stored in Accumulator and remainder in B register.
INC increments the value of register by 1. If the initial value of register is 255 (0xFF Hex), incrementing the value will cause it to reset to 0.
Syntax : INC register
Example : INC A
It will increment the data in accumulator by 1.
DEC 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).
Syntax : DEC register
Example : DEC R0
It decrements the data in R0 by 1.