Skip to main content

Posts

Program to calculate the sum of the series of numbers

Statement : Find the sum of the series of numbers. The length of the series is given in the memory location 2000H and the series itself begins from memory location 2001H.  A). If the sum is an 8-bit number, store the sum at memory location 2005H.  B). If the sum is a 16-bit number, store the sum at memory locations 2005H and 2006H. A).   EXAMPLE : (2000H) = 04H (2001H) = 30H (2002H) = 15H (2003H) = 13H (2004H) = 33H Result = 30H + 15H + 13H + 33H = 8BH Therefore, (2005H) = 8BH FLOW CHART : PROGRAM :               LDA 2000H          ; Get the length of the series               MOV C, A            ; Initialise counter               SUB A                  ; Make Sum = 0               LXI H,...

Machine Control Instructions (Part-II) - EI, DI, NOP, HLT

EI: This instruction is used to set the interrupt enable flip flop so that all maskable interrupts are enabled. After an interrupt is acknowledged, the interrupt enable flip flop is reset. This instruction is used to re-enable the interrupts. OPERATION : IE (FF) = 1 No flags are affected. It is a one byte instruction. Implied addressing mode is used. DI: This instruction is used to reset the interrupt enable flip flop so that all maskable interrupts are disabled. This instruction cannot disable TRAP since TRAP is a non-maskable interrupt. OPERATION : IE (FF) = 0 No flags are affected. It is a one byte instruction. Implied addressing mode is used. NOP: This instruction shows that no operation is performed. OPERATION : PC = PC + 1 No flags are affected. It is a one byte instruction. Implied addressing mode is used. HLT: This instruction is used to halt the processor. The processor can be restarted by a valid interrupt or by applying a RESE...

Machine Control Instructions (Part-I) - RIM and SIM

RIM: RIM stands for Read Interrupt Mask. This instruction is used to copy the status of the interrupts into the accumulator. This instruction is also used to read the serial data through the SID (Serial Input Data) pin. No flags are affected. It is a one byte instruction. Implied addressing mode is used. Example: If after execution of RIM instruction, A = 0100 1011 = 4BH It shows that RST 7.5 is pending, RST5.5 and RST 6.5 are masked, interrupt enable flip flop is set and SID is zero. SIM: SIM stands for Serial Interrupt Mask. This instruction is used to mask the interrupts as desired. The command byte which is used to mask the interrupts is loaded into the accumulator. This instruction is also used to send the serial data through the SOD (Serial Output Data) pin. No flags are affected. It is a one byte instruction. Implied addressing mode is used. Example: If we want to mask RST 7.5 and RST 6.5 and unmask RST 5.5, then accumulator sh...

Input/Output Instructions

IN 8-bit addr: This instruction is used to copy the data from the port into the accumulator. The address of the port is given in the instruction.   OPERATION : A = (8-bit addr) No flags are affected. It is a two byte instruction. Direct addressing mode is used. Example: If port address = 20H, (20H) = 08H, then IN 20H ; This instruction will copy the data stored at port address 20H i.e. 08H into the accumulator. OUT 8-bit addr: This instruction is used to copy the contents of the accumulator to the output port. The address of the port is given in the instruction. OPERATION : (8-bit addr) = A No flags are affected. It is a two byte instruction. Direct addressing mode is used. Example: If A = 08H, then OUT 20H ; This instruction will copy the contents of the accumulator i.e. 08H to the port whose address is 20H.

Stack Operations Instructions (Part-II) - SPHL and XTHL

SPHL: This instruction copies the contents of HL register pair to the stack pointer (SP). It means that the stack pointer will now point to the memory location whose address was given in the HL register pair. No flags are affected. It is a one byte instruction. Register addressing mode is used. Example: If HL = 2030H, then SPHL ; This instruction will copy 2030H into SP. So SP will point to the memory location 2030H. XTHL: This instruction exchanges the contents of the memory location pointed by stack pointer with the contents of the L register and the contents of the next memory location with the contents of H register. This instruction does not alter the contents of the stack pointer. No flags are affected. It is a one byte instruction. Register Indirect addressing mode is used. Example: If HL = 5601H, SP = 2000H, (2000H) = 30H and (2001H) = 20H, then XTHL ; This instruction will exchange the contents of the memory location 2000H i.e. 3...

Stack Operations Instructions (Part-I) - PUSH and POP

WHAT IS A STACK : The stack is a part of read/write memory which is used for the purpose of storing information temporarily. When the information is written on the stack, the operation is called PUSH . When the information is read from the stack, the operation is called POP . The stack is operated with the help of special memory pointer register called stack pointer (SP) . Stack pointer (SP) gives the address of the memory location where the information is to written or to be read. PUSH Rp: This instruction is used to write 16-bit data on the stack. It decrements stack pointer by one. Then the contents of higher order register of Rp are copied to the memory location pointed by stack pointer. Then stack pointer is again decremented by one. The contents of lower order register of Rp are copied to the memory location pointed by stack pointer. Rp can by BC, DE, HL or PSW. NOTE: PSW stands for program status word. It has accumulator (A register) as higher order...

Branching Group Instructions (Part-IV) - PCHL and RST n

PCHL: This instruction loads the contents of HL register pair into the program counter (PC). Thus the program control is transferred to the address given in HL register pair. No flags are affected. It is a one byte instruction. Register addressing mode is used. Example: If HL = 4000H PCHL ; This instruction will load PC with 4000H and program control is transferred at 4000H. RST n: This instruction transfers the program control to the specific memory location. It is like a CALL instruction but in this instruction, the program control is transferred to a fixed address. These fixed addresses are called vector addresses. The processor calculates these vector addresses by multiplying RST number i.e. n by 8. Just like CALL instruction, before transferring the program control to the vector address, it saves the current contents of program counter on the stack. No flags are affected. It is a one byte instruction. Register indirect addressing mode is use...

Branching Group Instructions (Part-III) - Return and Conditional return

RET: This instruction transfers the program control from subroutine or subprogram to the main program. It pops the address of the instruction next to CALL instruction in the main program from the stack and loads program counter with this address. Then stack pointer is incremented by two. No flags are affected. It is a one byte instruction. Register indirect addressing mode is used because the return address is available in the memory location pointed by stack pointer. Example: If SP = 2000H RET ; This instruction will load program counter with 3000H and will transfer program control to 3000H. Before execution: After execution: Rcond: When the condition is true, this instruction transfers the program control from subprogram or subroutine to the main program. It pops the address of the instruction next to CALL instruction from the stack and loads program counter with this address. Then stack pointer is incremented by two. When the condition is fal...

Branching Group Instructions (Part-II) - Call and Conditional call

CALL addr: The CALL instruction is used to transfer the program control to a subprogram or subroutine. NOTE: A subroutine is a group of instructions which performs a particular task and is executed a number of times. Rather than writing this repeated part again and again, the programmer writes this part only once. It is written separately. The processor executes this part by transferring program control from main program to the subroutine program. After completion of execution of subroutine, the program control is back to the main program. Subroutine Program The CALL instruction transfers the program control to the address given in the instruction. The current contents of program counter (PC) are copied into the stack. NOTE: Stack is a part of read/write memory which is used for storing temporary results and addresses. Then this instruction decrements stack pointer (SP) by two. No flags are affected. It is a three byte instruction. Immediate add...

Questions and Answers of 8085 Microprocessor (Part-II)

What are the different advances in semiconductor technology ? SSI - Small Scale Integration (10 transistors/chip) MSI - Medium Scale Integration (10 to 100 transistors/chip) LSI - Large Scale Integration (100 to 10,000 transistors/chip) VLSI - Very Large Scale Integration (10,000 to 10^6 transistors/chip) ULSI - Ultra Large Scale Integration (10^6 to 10^7 transistors/chip) GSI - Giga Scale Integration (more than 10^7 transistors/chip) What are the various functions of ALU ? The various functions performed by ALU are: Addition Subtraction AND  OR EX-OR Complement Shift right Shift left Increment  Decrement What is the function of READY signal ? READY signal is used for synchronization of slower peripherals with the microprocessor. It senses whether the peripheral is ready or not to transfer the data. If the peripheral is not ready, the processor waits. Why AD0 - AD7 lines are multiplexed ? The data bus (D0 - D7) and the lower half...

Questions and Answers of 8085 Microprocessor (Part-I)

What is a microprocessor ? A microprocessor is a multipurpose, programmable, clock driven register and ALU based electronic device. It reads binary instructions from memory, accepts binary data as input, processes data and provides result as output. What are the various registers in 8085 ? 8085 has 8-bit accumulator (A), six 8-bit general purpose registers B, C, D, E, H and L, temporary data register, W and Z registers, flag register, instruction register, 16-bit program counter (PC) and 16-bit stack pointer (SP). What are the various flags in a flag register ? Flag register is an 8-bit register in which five of the bits carry significant information in form of flags. They are S (Sign flag), Z (Zero flag), AC (Auxiliary Carry flag), P (Parity flag) and CY (Carry flag). What is the function of accumulator ? Accumulator is an 8-bit register which is used in arithmetic, logic, load, store and input/output operations. It is also used to store the result of a...

Branching Group Instructions (Part-I) - Jump and Conditional jump

JMP addr: This instruction loads the program counter with the address given in the instruction. Then the program execution continues from this location. No flags are affected. It is a three byte instruction. Immediate addressing mode is used since the operand is given in the instruction itself. Example: JMP 5600H ; This instruction will load PC with 5600H and processor will fetch next instruction from 5600H. JMP C240H ; This instruction will load PC with C240H and processor will fetch next instruction from C240H. Jcond addr: If the condition is true or satisfied, then this instruction causes a jump to an address given in the instruction. If the condition is false or not satisfied, then this instruction just check and proceed further to execute the next instruction after it. If condition is true, PC = addr and if condition is false, PC = PC + 3. No flags are affected. Flags are only checked. It is a three byte instruction. Immediate addressing mode is used...

Logical Group Instructions (Part-VI) - RLC, RRC, RAL, RAR

RLC: This instruction rotates the contents of accumulator to the left by one bit. It will shift B0 to B1, B1 to B2,............B7 to B0 as well as to carry flag . Only CY flag is modified. It is a one byte instruction. Implied addressing mode is used. Before execution: After execution: Example: If A = 0101 0111 = 57H and CY = 1 RLC ; Now A = 10101110 = AEH and CY = 0. RRC: This instruction rotates the contents of accumulator to the right by one bit. It will shift B7 to B6, B6 to B5,............B0 to B7 as well as to carry flag. Only CY flag is modified. It is a one byte instruction. Implied addressing mode is used. Before execution: After execution: Example: If A = 1001 1010 = 9AH and CY = 1 RLC ; Now A = 0100 1101 = 4DH and CY = 0. RAL: This instruction rotates the contents of accumulator to the left by one bit along with the carry . It will shift B0 to B1, B1 to B2,............B7 to CY and CY to B0 . Only CY flag is modifi...

Logical Group Instructions (Part-V) - CMA, CMC, STC

CMA: This instruction complements the contents of the accumulator. The result is stored in the accumulator. Only CY flag is modified. It is a one byte instruction. Implied addressing mode is used. Example: If A= 1000 1000 = 88H CMA ; This instruction will complement each bit A= 0111 0111 = 77H. CMC: This instruction complements the carry flag. If CY = 1 then this instruction will make CY = 0. Only CY flag is modified. It is a one byte instruction. Implied addressing mode is used. Example: If CY=1 CMC ; This instruction complements the CY flag CY=0. STC: This instruction sets the carry flag. This will make CY=1. Only CY flag is modified. It is a one byte instruction. Implied addressing mode is used. Example: STC ; This instruction will set CY flag CY=1.

Logical Group Instructions (Part-IV) - CMP and CPI

CMP R: This instruction compares the contents of the specified register with the contents of the accumulator. This comparison is performed by subtracting the contents of the specified register from the contents of the accumulator. Register R can be any 8-bit general purpose register like A, B, C, D, E, H and L. If A=R, then CY=0 and Z=1. If A>R, then CY=0 and Z=0. If A<R, then CY=1 and Z=0. S, AC and P are modified to reflect the status of subtraction. Z and CY are used to indicate the result of comparison. It is a one byte instruction. Register addressing mode is used. Example: If A = 12H and B = 14H  CMP B ; This instruction will compare the contents of A and B and since A<B, carry flag will set. CMP M: This instruction compares the contents of the memory location pointed by HL register pair with the contents of the accumulator. This comparison is performed by subtracting the contents of the memory location from the contents of the accumulator. ...

Logical Group Instructions (Part-III) - XRA and XRI

XRA R:  This instruction logically EX-OR the contents of the specified register with the contents of the accumulator. Register R can be any 8-bit general purpose register like A, B, C, D, E, H and L. The result is stored in the accumulator. S (Sign flag), Z (Zero flag), P (Parity flag) are modified. CY (Carry flag) and AC (Auxiliary Carry flag) are reset. It is a one byte instruction. Register addressing mode is used. Example: If A = 1010 1011 = ABH and D = 0001 0010 = 12H XRA D ; This instruction will logically EX-OR the contents of A (ABH) with the contents of D (12H) and the result (B9H) is stored in A. XRA M: This instruction logically EX-OR the contents of the memory location pointed by HL register pair with the contents of the accumulator. The result is stored in the accumulator. S (Sign flag), Z (Zero flag), P (Parity flag) are modified. CY (Carry flag) and AC (Auxiliary Carry flag) are reset. It is a one byte instruction. Register indirect addr...

Logical Group Instructions (Part-II) - ORA and ORI

ORA R:  This instruction logically OR the contents of the specified register with the contents of the accumulator. Register R can be any 8-bit general purpose register like A, B, C, D, E, H and L. The result is stored in the accumulator. S (Sign flag), Z (Zero flag), P (Parity flag) are modified. CY (Carry flag) and AC (Auxiliary Carry flag) are reset. It is a one byte instruction. Register addressing mode is used. Example: If A = 1010 1011 = ABH and L = 1000 0111 =87H ORA L ; This instruction will logically OR  the contents of A (ABH) with the contents of L (87H) and the result (AFH) is stored in A. ORA M: This instruction logically OR the contents of the memory location pointed by HL register pair with the contents of the accumulator. The result is stored in the accumulator. S (Sign flag), Z (Zero flag), P (Parity flag) are modified. CY (Carry flag) and AC (Auxiliary Carry flag) are reset. It is a one byte instruction. Register indirect addressing...

Logical Group Instructions (Part-I) - ANA and ANI

ANA R:  This instruction logically AND the contents of the specified register with the contents of the accumulator. Register R can be any 8-bit general purpose register like A, B, C, D, E, H and L. The result is stored in the accumulator. S (Sign flag), Z (Zero flag), P (Parity flag) are modified. CY (Carry flag) is reset and AC (Auxiliary Carry flag) is set. It is a one byte instruction. Register addressing mode is used. Example: If A = 0101 1001 = 59H and B = 0000 0011 = 03H ANA B ; This instruction will logically AND the contents of A (59H) with the contents of B (03H) and the result (01H) is stored in A. ANA M: This instruction logically AND the contents of the memory location pointed by HL register pair with the contents of the accumulator. The result is stored in the accumulator. S (Sign flag), Z (Zero flag), P (Parity flag) are modified. CY (Carry flag) is reset and AC (Auxiliary Carry flag) is set. It is a one byte instruction. Register indirect a...

Arithmetic Group Instructions (Part-VI)

DCR R: This instruction decrements the contents of specified register by 1. The result is stored in the same register. Register R can be any general purpose register like A, B, C, D, E, H and L. All flags are modified except carry flag. It is a one byte instruction. Register addressing mode is used. Example: If H = 20H DCR H ; This instruction decrements the contents of H (20H) by one and the result (1FH) is stored in H. DCR M: This instruction decrements the contents of the memory location pointed by HL register pair by 1. The result is stored in the same memory location. All flags are modified except carry flag. It is a one byte instruction. Register indirect addressing mode is used. Example: If HL = 2000H, (2000H) = 20H DCR M ; This instruction decrements the contents of location 2000H i.e. 20H by one and the result (1FH) is stored in location 2000H. DCX Rp: This instruction decrements the contents of the specified register pair by 1. The resul...

Arithmetic Group Instructions (Part-V)

INR R: This instruction increments the contents of specified register by 1. The result is stored in the same register. Register R can be any general purpose register like A, B, C, D, E, H and L. All flags are modified except carry flag. It is a one byte instruction. Register addressing mode is used. Example: If B = 50H INR B ; This instruction increments the contents of B (50H) by one and the result (51H) is stored in B. INR M: This instruction increments the contents of the memory location pointed by HL register pair by 1. The result is stored in the same memory location. All flags are modified except carry flag. It is a one byte instruction. Register indirect addressing mode is used. Example: If HL = 1000H and (1000H) = 20H INR M ; This instruction increments the contents of location 1000H i.e. 20H by one and the result (21H) is stored in location 1000H. INX Rp: This instruction increments the contents of the specified register pair by 1. The res...