120 likes | 278 Vues
This document explores the design and operation of a hypothetical machine designed for educational purposes in computer science. It details the structure, including components such as the ALU, control unit, and various registers. The document provides an overview of machine language instructions, including opcodes for loading, storing, arithmetic, and control flow operations. Example machine language programs are provided, illustrating how high-level constructs translate to machine language, emphasizing the core concepts of instruction execution and micro-operations in a simplified computing environment.
E N D
Computer Science 101 Computer Systems Organization Machine Language Examples Entire machine
Hypothetical Lab Machine Memory ALU Control PC(12) IR(16) MAR(12) MDR(16) 16 +1 R(16) ALU GT EQ LT
Hypothetical Machine Instructions • Opcode Operation Meaning 0000 Load X Con(X)R 0001 Store X RCon(X) 0010 Clear X 0Con(X) 0011 Add X R+Con(X)R 0100 Increment X Con(X)+1 Con(X) 0101 Subtract X R-Con(X) R 0110 Decrement X Con(X)-1 Con(X)
Hypothetical Machine Instructions • Opcode Operation Meaning 0111 Compare X If Con(X) > R CC: 100,etc. 1000 Jump X X PC 1001 JumpGT X If GT=1, X PC 1010 JumpEQ X If EQ=1, X PC 1011 JumpLT X If LT=1, X PC 1100 JumpNE X If EQ=0, X PC
Hypothetical Machine Instructions • Opcode Operation Meaning 1101 In X Input valueCon(X) 1110 Out X Con(X)Output value 1111 Halt Stop execution
0011000000000110 Add 6 0001000000000111 Store 7 1111000000000000 Halt 0000000000101100 0000000000101100 0000000000001011 0000000000110111 0000000000110111 0000000000000101 Load 5 Machine Language: Con(5)+Con(6) Con(7) Python: c = a + b 0: 0000000000000101 1: 0011000000000110 2: 0001000000000111 3: 1111000000000000 4: 0000001000001010 5: 0000000000101100 6: 0000000000001011 7: 0000001111111111 1111000011110000 R:
Fetch Phase PC MAR Fetch MDR IR PC+1 PC Decode IRop ALU MUX Memory ALU Control PC(12) IR(16) MAR(12) MDR(16) 16 +1 R(16) ALU Micro Steps: Fetch and Decode Phases
Load X IRadd MAR Fetch MDR R Store X IRadd MAR R MDR Store Memory ALU Control PC(12) IR(16) MAR(12) MDR(16) 16 +1 R(16) ALU Micro Steps: Execution of Load and Store
Add X IRadd MAR Fetch MDR ALU R ALU Add ALU R Jump X IRadd PC Memory ALU Control PC(12) IR(16) MAR(12) MDR(16) 16 +1 R(16) ALU Micro Steps: Execution of Add and Jump
Compare X IRadd MAR Fetch MDR ALU R ALU Subtract (set CC) JumpGT If GT=1 IRadd PC Memory ALU Control PC(12) IR(16) MAR(12) MDR(16) 16 +1 R(16) ALU Micro Steps: Execution of Compare and JumpGT