1 / 26

CS 215

CS 215. Introduction to Assembly Language and Computer Architecture. Course topics. Computer Organization Computer Components CPU, memory, I/O devices, bus Representing information Integers, real numbers, text characters, machine code Arithmetic operations Assembly Language

prisca
Download Presentation

CS 215

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 215 Introduction to Assembly Language and Computer Architecture

  2. Course topics • Computer Organization • Computer Components • CPU, memory, I/O devices, bus • Representing information • Integers, real numbers, text characters, machine code • Arithmetic operations • Assembly Language • Basic features • Translation (C  assembly language) • Data structures • Procedures • I/O Operations

  3. Course activities • Computer Organization • Representing information • Encode and decode various types of data • How is 3.14 represented by a computer? • What unsigned integer is represented by the byte 11001010? • Arithmetic operations • Demonstrate the (addition/subtraction/multiplication/division) of two (integers/real numbers) using one of the algorithms for hardware operations presented in class • Requires an understanding of the representations

  4. Course activities • Assembly Language • Translation (C++  assembly language) • Implement a C++ code fragment in assembly language • Procedures • Implement a C++ function in assembly language • Use activation records • Programmed I/O • Write code which manages I/O to a device • monitor, keyboard

  5. Focus: MIPS R2000 Assembly Language • The MIPS R2000 is an old CPU from SGI • Modern MIPS used in SGI workstations, Sony PS2 • All MIPS chips use nearly the same assembly language • MIPS assembly language is very similar to that of the PowerPC chip, the heart of the Apple Macintosh • Why MIPS R2000 • Simple, easily learned language • Straight-forward architecture • Freely available simulator: SPIM

  6. Why study assembly language? • Developing a more accurate model of computation is the main goal of this course • A software engineer who understands how a computer works will be able to: • design more efficient code • program for devices other than PCs • Better understand hardware, OS, libraries, network, source code, etc.

  7. What is a model? • A model is a partial representation of a system • incomplete • specific purpose • Multiple models for different purposes • Model of the city of Milwaukee for • MCTS bus driver • MMSD engineer • Bicyclist • Commercial airline pilot

  8. Level of detail • Eliminating distracting detail enables focus on aspects of interest, get higher level perspectives • street maps for navigation do not show buildings and topography • More detail is NOT necessarily better • A detailed schematic of a car engine would not help the average motorist troubleshoot a sputtering engine • A flow chart would be better • A city map that shows every alley is less useful to a visitor than one that shows just major roads

  9. Abstraction • Modeling is about abstraction: • building general, high-level concept pictures • Models often abstract away variation • Access to UWM computers requires authentication • The authentication abstraction filters out mechanism • login-password, fingerprint recognition, ID badge, etc. • Different abstractions, levels of abstraction depending on aspects of interest, degree of expertise

  10. Learning is model refinement • The primary purpose of modeling is to improve understanding • Observing differences between the model and reality shows us gaps in our understanding • This is how learning works, according to educational theory • Cognitive dissonance • Learn is updating our model to better predict reality

  11. Novice user’s model of computation • A computer is a machine that: • Can generate video and sound, like a TV • responds to input from a keyboard and a mouse • Unlike a TV • must be plugged into the Internet to work properly • Like a TV needs cable, or an antenna • This is a useful model for word-processing, email, web browsing, copying CD’s, etc. • Programming requires a more detailed model

  12. CS-201 model of computation • A computer is a machine that executes a C++ program, by • Executing each line of the program sequentially, subject to control structures and function calls • Allowing the program to receive text input from the keyboard, or a file • Allowing the program to produce text output to the monitor, or a file C++ Program Computer

  13. A more complex model of computation • A computer executes machine instructions, and can control a variety of input/output devices • Compiler • language definition • settings • implementation details • Operating system • resource allocation • device management • CPU • machine instructions • addressing modes C++ Program CPU Operating System Compiler

  14. Programming Language as Abstraction • A primitive is an elementary operation. • A primitive in a higher level of abstraction can correspond to a set of operations in a lower level of abstraction. For example, • Operators of Language A: {+, -, *, /} • Operators of Language B: {+, -} • Let 5*2 be a statement in Language A. What is its equivalent in Language B?

  15. Monadic vs. Dyadic • For the most part, the computer hardware is limited to executing monadic and dyadic operations • monadic - takes a single operand, e.g. taking the complement • dyadic - takes two operand, e.g. adding two values

  16. The assembly process • Ultimately, instructions written in a higher level abstraction must be expanded to the primitives the hardware understands directly, the machine language. • For example, high-level language to assembly language using a compiler; then from assembly language to machine language using an assembler

  17. Compilers vs. Assemblers • A compiler is a computer program that translates a high-level language, e.g. C++, into an intermediate-level language, e.g. assembly language. • An assembler is a computer program that translates an assembly language into machine language (string of binary digits).

  18. Computer Architecture • Defines what the computer’s instruction do and how they are specified • The set of instructions determine the computer’s capability • A computer’s machine language is determined by its manufacturer • The assembly language is also formally defined by the manufacturer

  19. SAL, MAL, TAL • SAL (Simple Abstract Language) • contains the notion of types similar to HLL and is based on MAL • MAL (MIPS Assembly Language) • more abstract and easier to use than TAL. The MIPS RISC assembler translates MAL into TAL, then TAL into MIPS RISC machine code • TAL (True Assembly Language) • exactly corresponds with hardware operations

  20. Computer Execution • A computer’s processor executes instructions. • The instructions specifies how variables are to be manipulated and stored in memory. • A variable in the machine language must be assigned a specific memory location. This process of assigning a memory location is called binding.

  21. Example A statement in a high-level language (HLL) A = B + C; An equivalent assembly language instruction may be add A, B, C • The mnemonic add stands for an operation code (opcode) and A, B, and C are the operands

  22. CPU and the Memory • The Central Processing Unit (CPU) • is responsible for instruction execution. • determines how the memory is to be modified. • The Main Memory • is a collection of cells and each cell is assigned a label • a cell can hold a value. • CPU stores a new variable value, fetches instructions, or loads a variable value.

  23. Instruction Types • There are three instruction types: Arithmetic, Logical, and Control • Arithmetic and logical instructions evaluate variables and assign new values to variables • Control instructions test or compare values of variables and make decisions about what instruction is going to be executed next.

  24. Fetch-Decode-Execute Cycle • A computer’s complete functionality is described by this mechanism. 1. instruction fetch 2. program counter (PC) update 3. instruction decode 4. operand load 5. operation execution 6. storage of results

  25. Example x1 = x2 + x3; x4 = x2 - x5; if(x4 != x1){ x1 = x1 + x5; } else Next part . . .

  26. Example part1: add x1,x2,x3 sub x4,x2,x5 beq x4,x1,part2 add x1,x1,x5 part2: . . .

More Related