Machine and Assembly Language Programming
Total Page:16
File Type:pdf, Size:1020Kb
COURSE TITLE: FOUNDATIONS OF SEQUENTIAL PROGRAM CODE: CSC 206 COURSE PLAN Week 1 -2: Basic Machine architecture Week 3: Machine language, assembly language and assemblers, low/high level languages (Machine-level implementation of high-level language) Week 4: Variables, memory allocation (Variables and data representation) Week 5: Control structures Week 6: Procedures and procedure calls Week 7: Scopes, closures (scopes and nesting, closures and objects) Week 8: Regular languages, scanning (Architecture of a compiler. Syntax vs. semantics. Introduction to formal languages. Regular languages, regular expressions and finite state machines) Week 9: Context-free languages, parsing (Context-free grammars, derivations, derivation trees, ambiguous grammars. Parsing algorithms.) Week 10: Context-sensitive (semantic) analysis - Parse trees, name resolution, type- checking Week 11: Code generation Week 12: Memory management (Implications of stack versus heap allocation. Dynamic Memory Allocation. Automatic Garbage Collection) EVALUATION CRITERIA Evaluation is strictly based on how well the student will perform in class activities, class attendance, and other activities. Performance will be monitored throughout the semester. Following are the tools used to measure the competency level of the candidate: Class quizzes. Normally conducted at the end of each unit. Class test: normally conducted at the end of two units Home Assignments Projects (if any) Examination: at the end of course DISCLAIMER The contents of this document are intended for leaning purposes at the undergraduate level. The materials are from different sources including the internet and the contributors do not in any way claim authorship or ownership of them. BASIC MACHINE ARCHITECTURE What is a computer? A computer is a machine (hardware) usually electronic that is capable of executing a sequence of instructions from a stored program (software) A micro-processor based computer is called a microcomputer. Major components of a computer: 1- Microprocessor (CPU) 2- Memory (RAM and/or ROM) 3- input/output devices 4- Clock. (Controls all devices) Block Diagram of a Typical Machine A microprocessor contains the following main components: ALU Carries out the arithmetic functions of the computer. Also it performs the logical functions. Control Unit Is the “brain” of the computer. It determines which function to be done on data, decodes instructions, and controls the flow of the program Register File These are high speed storage locations. Hold internal data that the processor currently using while executing programs. Two kinds of registers exist: 1- Special purpose registers Used by CPU. Most importantly are the program counter (PC), and the processor status register. 2- General purpose registers Used by programmers MEMORY Memory refers to the computer hardware integrated circuits that store information for immediate use in a computer; it is synonymous with the term "primary storage". Computer memory operates at a high speed, for example random-access memory (RAM), as a distinction from storage that provides slow-to-access information but offers higher capacities. If needed, contents of the computer memory can be transferred to secondary storage, through a memory management technique called "virtual memory". An archaic synonym for memory is storage. What does computer memory look like? Below is an example picture of a 512 MB DIMM computer memory module. This memory module connects to the memory slot on a computer motherboard. How is memory used When a program such as your Internet browser is open, it is loaded from your hard drive and placed into RAM, which allows that program to communicate with the processor at higher speeds. Anything you save to your computer, such as a picture or video, is sent to your hard drive for storage. Why is memory important or needed for a computer? All of devices on a computer do not operate at the same speed and computer memory gives your computer a place to quickly access data. If the CPU had to wait for a secondary storage device like a hard disk drive the computer would be much slower. Main Memory (Primary storage) A linear list of memory cells. Each cell holds a data word. A word could be a byte, 2 bytes, 4 bytes ..... address 0 bp-1 ...................b0 1 . 2 . n-3 . n-2 . n-1 . memory unit of n cells All memories share two organizational features:- 1) Each information unit is the same size. 2) An information unit has a numbered address associated with it by which it can be uniquely referenced. A memory cell is characterized by two things:- 1) An address 2) Content Layers of memory: 1. Registers (1 clock cycle): the fastest possible access (usually 1 CPU cycle). A few thousand bytes in size 2. Primary Cache: ~1 nano-second cache primary Secondary Cache: 10 nano-seconds 3. fast RAM: 70 nanoseconds or less 4. fast disk: 10 milliseconds (10,000,000 nanoseconds) 5. CD/DVD: 160 milliseconds (160,000,000 nanoseconds) Memory Acronyms you should know: 1. ROM - Read Only Memory ROM is memory that is "hard coded" from the manufacturer and never changes, such as the instruction to "boot" up your computer. A ROM chip is a non-volatile storage medium, which means it does not require a constant source of power to retain the information stored on it. A good example of ROM is the computer BIOS, a PROM chip that stores the programming needed to begin the initial computer start up process. ROM-type storage is still used and continues to be improved upon for better performance and storage capacity. 2. RAM - Random Access Memory Ram is the core memory you buy for any machine. It is often sold (today) in .5, 1, 2 and 4 GIG boards. Random Access Memory (RAM), is a volatile memory (it loses any information it is holding when the power is turned off) that stores information on an integrated circuit used by the operating system, software, and hardware. The basic memory cell on many computers including holds one byte (8 bits). Such machines are called byte-addressable. Other machines have larger storage units. Components of the computer are connected by Buses. A bus in the simplest form is a set of wires that used to carry information in the form of electrical signals between CPU and memory and CPU and I/O There are 3 buses in the system - Data Bus - Address Bus - Control (signal) Bus Computer Architecture Computer architecture, is the internal structure of a digital computer, encompassing the design and layout of its instruction set and storage registers. The architecture of a computer is chosen with regard to the types of programs that will be run on it (business, scientific, general-purpose, etc.). The architecture of a computer system is the user-visible interface: The structure and operation of the system as seen by the programmer. It includes - The instruction set the computer can obey - The ways in which the instructions can specify the locations of data to be processed - The type and representation of data - The format in which the instructions are stored in memory History The first documented computer architecture was in the correspondence between Charles Babbage and Ada Lovelace, describing the analytical engine. When building the computer Z1 in 1936, Konrad Zuse described in two patent applications for his future projects that machine instructions could be stored in the same storage used for data, i.e. the stored-program concept. The term “architecture” in computer literature can be traced to the work of Lyle R. Johnson, Frederick P. Brooks, Jr., and Mohammad Usman Khan, all members of the Machine Organization department in IBM’s main research center in 1959. Johnson had the opportunity to write a proprietary research communication about the Stretch, an IBM- developed supercomputer for Los Alamos National Laboratory (at the time known as Los Alamos Scientific Laboratory). To describe the level of detail for discussing the luxuriously embellished computer, he noted that his description of formats, instruction types, hardware parameters, and speed enhancements were at the level of “system architecture”. Advantages of a Microprocessor Low Cost Microprocessors are available at low cost due to integrated circuit technology. Which will reduce the cost of a computer system. High Speed Microprocessor chips can work at very high speed due to the technology involved in it. It is capable of executing millions of instructions per second. Small Size Due to very large scale and ultra large scale integration technology, a microprocessor is fabricated in a very less footprint. This will reduce the size of the entire computer system. Versatile Microprocessors are very versatile, the same chip can be used for a number of applications by simply changing the program (instructions stored in the memory). Low Power Consumption Microprocessors are usually manufactured using metal oxide semiconductor technology, in which MOSFETs (Metal Oxide Semiconductor Field Effect Transistors) are working in saturation and cut off modes. So the power consumption is very low compared to others. Less Heat Generation Compared to vacuum tube devices, semiconductor devices won’t emit that much heat. Reliable Microprocessors are very reliable, failure rate is very less as semiconductor technology is used. Portable Devices or computer system made with microprocessors can be made portable due to the small size and low power consumption. Clock Also called clock rate, the speed at which a microprocessor executes instructions. ... The CPU requires a fixed number of clock ticks (or clock cycles) to execute each instruction. The faster the clock, the more instructions the CPU can execute per second. Clock speeds are expressed in megahertz (MHz) or gigahertz ((GHz). The clock in a microprocessor serves to coordinate the operations of the different parts of a microprocessor. Computer architecture, like other architecture, is the art of determining the needs of the user of a structure and then designing to meet those needs as effectively as possible within economic and technological constraints.