← Back to Book Detail

8085 Instruction Set: Part 2 (13/12) -- Introduction to Microcontrollers

Browse
108%

8085 Instruction Set: Part 2

8085 Instruction Set: Part 2 Branch Instructions Branch instructions in the 8085 microprocessor allow the program to change its execution sequence. These instructions are crucial for implementing decision-making and loop structures in assembly language programs. Types of Branch Instructions: - Unconditional Jump Instructions: - JMP: Unconditional jump to a specified address. - JC: Jump if carry flag is set. - JNC: Jump if carry flag is not set. - JZ: Jump if zero flag is set. - JNZ: Jump if zero flag is not set. - Conditional Jump Instructions: Opcode Description JC Jump if Carry flag is set JNC Jump if Carry flag is not set JZ Jump if Zero flag is set JNZ Jump if Zero flag is not set JP Jump if Sign flag is not set (positive) JM Jump if Sign flag is set (minus) JPE Jump if Parity flag is set (even parity) JPO Jump if Parity flag is not set (odd parity) - Call Instructions: - CALL: Unconditional call to a subroutine. - CC: Call if carry flag is set. - CNC: Call if carry flag is not set. - CZ: Call if zero flag is set. - CNZ: Call if zero flag is not set. - Return Instructions: - RET: Unconditional return from a subroutine. - RC: Return if carry flag is set. - RNC: Return if carry flag is not set. - RZ: Return if zero flag is set. - RNZ: Return if zero flag is not set. - Compare Instructions: - CMP: Compares a register/memory with the accumulator. - CPI: Compares immediate data with the accumulator. - Rotate Instructions: - RLC: Rotates the accumulator left through the carry bit. - RRC: Rotates the accumulator right through the carry bit. - RAL: Rotates the accumulator left without the carry bit. - RAR: Rotates the accumulator right without the carry bit. - Restart Instructions: - RST n: Calls one of eight subroutines located in the first 64 bytes of memory. 5. Stack, I/O, and Machine Control Instructions These instructions manage the stack, perform I/O operations, and control various aspects of the microprocessor’s operation.Stack Instructions: - PUSH rp: Push register pair onto stack. - POP rp: Pop top of stack to register pair. - XTHL: Exchange top of stack with HL. - SPHL: Move HL to stack pointer. I/O Instructions: - IN port: Input from I/O port to accumulator. - OUT port: Output accumulator to I/O port. Machine Control Instructions: - HLT: Halt the processor. - NOP: No operation (used for timing or to replace instructions). - DI: Disable interrupts. - EI: Enable interrupts. - RIM: Read interrupt mask. - SIM: Set interrupt mask. Example: Using Branch Instructions Here’s an example of how branch instructions can be used to create a simple loop: MVI C, 5 ; Initialize counter LOOP: ; Your loop body here DCR C ; Decrement counter JNZ LOOP ; Jump to LOOP if counter is not zero ; Continue with the rest of the program This code will execute the loop body 5 times before continuing with the rest of the program.Examples of Logical Instructions - ANA Instruction: ANA B : Performs a bitwise AND operation between the contents of register B and the accumul
← Previous Chapter Next Chapter →