An instruction is a command given to the microprocessor to perform a given task.Note that an instruction set of a microprocessor is the limited number of instructions the microprocessor can execute.
I would love to write a bit about stack instructions
Stack instructions are those instructions that deals with the operation of the stack which is a section of read/write memory organized in a LIFO (Last In First Out) structure.
The stack is accessed by two instructions which are:
1. Push: This is a stack instruction that saves the content of the microprocessor registers on a stack of memory before a sub routine is executed. For Example: PUSH A places the data from A at the top of the stack.
2. Pop: This is a stack instruction that restores the value of the register after completion of the sub routine is executed. For Example: POP A places data from the top of the stack into A.
Miscellaneous ===> Note that where ever you see SPHL it means copy address from HL to SP (Stack Pointer).
There are six categories of computer instructions which are:
1. Data Transfer Instructions
2. Data Manipulation Instructions
3. Input/Output Instructions
4. Program Flow Control Instructions
5. Machine Control Instructions
6. Assembly Directives
Data Transfer Instructions: These are instructions that moves data between the various processor registers or between a processor register and a memory location. For Example: MOV A, B means move the contents of B register into register A.
Data Manipulation Instructions: These are instructions that perform arithmetic and logical operations on data which is either in a specified processor register or in a memory location.
Program Flow Control Instructions: These are instructions that include unconditional and conditional jump instructions, sub routine calls and return instructions. These instructions act on the program counter, These instructions makes programs and computers more flexible. For Example JMP Label 12 results in the microprocessor breaking its normal mode of sequential instruction execution and instead jump unconditionally to symbolic address Label 12 for the next instruction to be executed.
Unconditional Jump Instructions are those instructions when encountered in a system simply loads the program counter with the address which specifies the program location.
Conditional Jump Instructions are those instructions when encountered tests the flag registers for a certain condition and only if the condition exits does the jump occur.
Sub routine Jump or Call Instructions is a form of unconditional jump instruction which when encountered in a program pushes the content of the program counter and other programs into the stack before control is passed to the sub routine and on completion of the sub routine, control is returned to the main program and the saved program counters and registered contents have popped up the stack and placed back in the program counters and registers.
Input/Output Instructions: These are those instructions that are used to transfer data between the accumulator and a specified port. For Example: IN PORT and OUT PORT.
Machine Control Instructions: These are those instructions that has interrupt instructions and miscellaneous instructions. Example of Interrupt Signals are: DI => Disable Interrupt, EI => Enable Interrupt. Miscellaneous instructions include microprocessor instruction set such as NOP.
Assembler Directives: These are those instructions that control the assembler and not the machine (computer). Example END which means end the assembly program etc.
There are 3 types of instruction word sizes which are:
1. 1 Word (1 - byte) Instruction: In this instruction, the opcode and operands are included in one byte and require only one memory location. The operand or opcode are internal registers and are coded into instructions.
2. 2 Word (2 - byte) Instruction: In this instruction, the first byte specifies the opcode while the second byte specifies the operand. The source operand is a data byte and this instruction requires two memory locations.
3. 3 Word (3 - byte) Instruction: In this instruction, the first byte specifies the opcode while the other two bytes specifies the 16-bit address where the second is the lower order address while the first byte is the higher order address.
No comments:
Post a Comment