EJEMPLO DE PROGRAMA EN LENGUAJE DE MÁQUINA | BAJO NIVEL | ASSEMBLER | ARQUITECTURA DE COMPUTADORAS
Understanding Machine Language and Instruction Cycles
Introduction to Machine Language
- The session focuses on machine language, providing examples of instruction formats and the functioning of instruction cycles discussed in previous videos.
- Processors are designed to recognize encoded instructions represented as bits, forming the basis of machine language.
Types of Instruction Sets
- Two main types of instruction sets are discussed: RISC (Reduced Instruction Set Computer) and CISC (Complex Instruction Set Computer).
- RISC features a reduced set of instructions, leading to more efficient, faster, and cost-effective machines.
- CISC includes a more complex set with various formats that can adapt to different software needs but adds complexity in coding and execution.
Classification of Machine Instructions
- Machine instructions can be classified into three broad categories:
- Data Transfer Instructions: Such as load and store operations that move data between CPU and main memory.
- Arithmetic and Logical Instructions: Including operations like addition (add), logical AND, OR, etc.
- Control Instructions: Such as branch or jump commands that manage program control flow.
Architecture Overview
- An example architecture for a 16-bit machine is presented, highlighting key components:
- Central Processing Unit (CPU) interacts with main memory organized into cells with specific addresses.
- Memory addresses range from
00toFF, representing total memory cells available.
Instruction Format
- The format for instructions consists of 16 bits or four hexadecimal digits:
- The first digit represents the operation code (opcode), while the remaining digits represent operands or specific data used in operations.
Understanding the Machine Cycle
- The machine cycle comprises three phases:
- Instruction Fetching: Retrieving an instruction from main memory using the program counter which indicates the address.
- Decoding: Identifying the opcode and operands within the fetched instruction.
Understanding the Instruction Cycle in a Processor
The Role of the Program Counter
- The program counter dictates the sequence of operations, continuously decoding and executing instructions until the machine halts.
Fetching Instructions
- The instruction cycle involves fetching data from main memory, where various instructions and data are stored in cells.
- For example, cell 0 contains the value 15 and cell 1 has 6; instructions are represented as four-digit hexadecimal values.
Decoding Instructions
- The processor retrieves instructions based on addresses provided by the program counter, which increments to fetch subsequent instructions.
- After fetching an instruction, it is decoded before execution. The program counter increases by 2 to point to the next instruction's address.
Understanding Operation Codes
- Each instruction's first digit represents the operation code (opcode), indicating what action will be executed by the CPU.
- In a given example, an opcode may instruct storing content from a register into a specific memory cell.
Example of Instruction Execution
- An example shows that if an opcode indicates storing data from register 5 into memory cell 7, this process illustrates how operands work within instructions.
- This format allows for variable registers and memory locations during low-level programming.
Practical Application of Instructions
- By interpreting low-level instruction sets, programmers can understand how to manipulate registers and memory effectively.
Memory Storage Constraints
- A single memory cell can only store half an instruction (one byte), while full instructions require two bytes or four digits in hexadecimal format.
Running Programs Step-by-Step
- To execute a program starting at address zero, each instruction must be fetched sequentially using the program counter until completion.
Conclusion of Example Program Flow