Loading in 2 Seconds...
Loading in 2 Seconds...
Computer SystemsIntroduction to Computer Architecture and Assembly LanguagePart I
Computer Architecture Many different definitions Interface between hardware and the lowest level of software Assembly language programmer’s view of the processor
Assembly Language A low-level, human-readable representation of the binary code executed by a computer A language that controls the primitive operations on binary data Basic operations include data movement, addition, subtraction, comparison, shifting and branching
Why Assembly Language? • All digital computers execute a low-level machine code. • Assembly language is a symbolic representation of machine code. • Foundation for the understanding of computer systems. • Fast, directly dealing with hardware, etc.
Objectives of Study Assembly Language • To study fundamental components of assembly languages from the perspective of how software features are supported by hardware • To develop assembly language programs • To write programs to control hardware • To understand essential mechanisms in computer system such as interrupts and exceptions • To study basics of computer architecture and operating system
Assembly language is machine-dependent! • Intel Inc., Pentium. • Motorola Inc., 68xxx. • Digital Inc., PDP-11. • TMS320, Z8, MCS96, etc.
Computer Architecture- Languages Applications HHL Complier Assembly Language Assembler Machine Language High Level Language Low Level language Hardware 68000 Assembly Language C, JAVA Word, Excel
The relation between assembly language and other computer science subjects The understanding of the assembly language lays the foundation for studying programming languages, complier, operating system, & computer architecture.
Address Address Address Bus Memory Central Processor Unit (CPU) Instruction Data Data bus Data Data Von Neumann Machine(Stored Program Computer) • The common memory system stores both the instructions and the data
4 27 9 6 14 32 Memory Address transferred from CPU Address 0000 0001 • Array of cells storing data (data/instructions), each cell has an unique address • Address port, data port, control signals • Read cycle: data at the specified memory address is placed on the data bus • Write cycle: data on the data bus is written into the specified memory location 0002 Read Write Data Data transferred between CPU and memory
Central Processor Unit (CPU) • Responsible for reading instructions from the memory and executing them • Address bus: used by CPU to provide memory address of instruction or data to the memory • Data bus: used by CPU/memory to transfer data between them
Basic von Neumann Machine Instruction Format • An instruction consists of “operation code” field and the “operand address” field • Could have more or less addresses, later … • Operation code (op-code): defines what the instruction does • Operand address (address): where the operand is located Operand address Operation Code
Von Neumann machinein Pseudo code Von Neumann machine operates in a two-phase mode, fetch/execute cycles. Module Von_Neumann I := 0 Repeat Fetch an instruction from memory location I I := I + 1 Execute the instruction Forever END Von_Neumann
Pseudo code for execution Module Execute the instruction Decode the instruction IF instruction requires data, THEN Fetch the data from the memory END_IF Perform operation defined by instruction IF instruction requires data to be saved, THEN Save the data in memory END_IF End Execute the instruction
Memory Read Read Read CPU C := A+B Instruction 5 A 6 B Write 11 C Information Flow between CPU and Memory
CPU Components • Arithmetic and logic unit (ALU): calculation • Control unit (CU): interprets the instruction Memory CPU Address Address Address bus Instruction Instruction : Data : Registers Control bus CU ALU Data bus Data Data
CPU Components • Registers: temporary storage • Program counter (PC): holds the address of the next instruction to be executed • Instruction register (IR): holds instruction • Data registers: hold data • Address registers: hold addresses • Condition code register (CCR): flag bits • Updated to reflect operation result • Used to change flow of program • MAR, MBR, PSW, etc. (later)
Typical VirtualMemory Layout(A Process’s View) Memory Operating System Code • Process: program in execution • Operating System: resource manager of computer system • Code: program • Data: static data • Heap: dynamic data • Stack: subroutine calls Data Heap Stack