Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Unit-1 What is a Computer? Computer is an electronic device that accepts input, store, retrieve and process the data. You can use a computer to type documents, send email, and surf the Internet. You can also use it to handle spreadsheets, accounting, database management, presentations, games and more. A computer is composed of hardware and software, and can exist in a variety of sizes and configurations The term hardware refers to the physical components of your computer such as the system unit, mouse, keyboard, monitor etc. The software is the set of instructions that make the computer work. Software is held either on your computer’s hard disk, CD-ROM, DVD or on a diskette (floppy disk) and is loaded (i.e. copied) from the disk into the computers RAM (Random Access Memory), as and when required. 1. With a neat schematic block diagram of a digital computer describe its functional units. Input Unit: Input unit is used to input some sort of data into the computer. Computers accept coded information through input units, which read data. It converts the data into a suitable form that can be understood by the Computer. The converted data is stored in the form of 0’s and 1’s and then sent to Central processing unit The user can also interact with other devices such as CPU, MU and output unit Examples: A keyboard is an input device that inputs characters. Many other kinds of input devices are available, including joysticks, trackballs, and mouse, which can be used as pointing device. Touch screens are often used as graphic input devices in conjunction with displays. Microphones can be used to capture audio input which is then sampled and converted into digital codes for storage and. processing. Cameras and scanners are used as to get digital images. Unit-1 Output unit: Its main function is to send processed results to the outside world that is used to display the processed results. Accepts the result or data from memory which are in the form of 0’s and 1’s. Output the results or data to a form which is suitable for human understanding. Examples : Video terminals and graphic displays. The most familiar example of such a device is a printer. Printers employ mechanical impact heads, ink-jet streams, or photocopying techniques, as in laser printers, to perform the printing. Monitors, Speakers, Headphones and projectors are also some of the output devices. Storage devices such as hard disk, floppy disk, flash drives are also used for input as well as output. Central Processing Unit; The central processing unit (CPU) of a computer is a hardware device that executes all the instructions of a computer program. It performs basic arithmetical, logical, and input/output operations of a computer system. This is the unit through which the computer processes all the data accepted through the input unit. It consists of two functional units: 1. Arithmetic and Logic Unit (ALU) 2. Control Unit (CU) 1. Arithmetic and Logic Unit (ALU);o An ALU consists of electronic circuitry which performs calculations with basic arithmetic operations such as addition (+), subtraction (-), multiplication (*), division (/). o It also consists of logic circuitry which performs logic operations like true or false, yes or no. 2. Control Unit (CU):o The control unit is a component of a computer's central processing unit (CPU) which directs operation of the processor. o It controls communication and co-ordination between input/output devices. o It reads and interprets instructions and determines the sequence for processing the data. o It performs the tasks of fetching, decoding, managing execution and, finally, storing results o The control unit is the circuitry that controls the flow of data through the processor, and coordinates the activities of the other units within it. Memory Unit (MU):The Term Computer Memory is defined as one or more sets of chips that store Data/program instructions, either temporarily or permanently. Two types of memory units: 1. Primary Memory or Main Memory 2. Secondary Memory 1. Main Memory / Primary Memory unit: RAM(Random Access Memory) RAM or Random Access Memory is the central storage unit in a computer system. It is the place in a computer where the operating system, application programs and the data in current use are kept temporarily Unit-1 so that they can be accessed by the computer’s processor. The more RAM a computer has, the more data a computer can manipulate. Random access memory, also called the Read/Write memory, is the temporary memory of a computer. It is said to be ‘volatile’ since its contents are accessible only as long as the computer is on. The contents of RAM are cleared once the computer is turned off. ROM(Read-only Memory) ROM or Read Only Memory is a special type of memory which can only be read and contents of which are not lost even when the computer is switched off. So it is said to be ‘Non volatile’ memory. It typically contains manufacturer’s instructions. Among other things, ROM also stores an initial program called the ‘bootstrap loader’ whose function is to start the computer software operating, once the power is turned on. Read-only memories can be manufacturer-programmed or user-programmed. While manufacturerprogrammed ROMs have data burnt into the circuitry, user-programmed ROMs can have the user load and then store read-only programs. PROM or Programmable ROM is the name given to such ROMs. Information once stored on the ROM or PROM chip cannot be altered. However, another type of memory called EPROM (Erasable PROM) allows a user to erase the information stored on the chip and reprogram it with new information. EEPROM (Electrically EPROM) and UVEPROM (Ultra Violet EPROM) are two types of EPROM’s. CPU Registers A register is a very small amount of very fast memory that is built into the CPU. All data must be represented in a register before it can be processed. For example, if two numbers are to be multiplied, both numbers must be in registers, and the result is also placed in a register. A processor often contains several kinds of registers such as data registers: can hold numeric values such as integer and, floating-point values, as well as characters, small bit arrays and other data. address registers : hold addresses and are used by instructions that indirectly access primary memory. instruction register : holding the instruction currently being executed. Constant registers hold read-only values such as zero, one, or pi. AND SO ON… Cache memory: It’s a high speed memory and is placed between CPU and main memory. The data and instructions stored in it are accessed at a higher speed Users cannot access this memory It stores data and instructions that are currently to be executed. 2. Secondary Memory: It is the permanent memory which stores large amount of data and instructions permanently. It’s also called back up memory or auxiliary memory. Unit-1 It is connected to CPU and is made of magnetic material. It is much cheaper than the main storage. Secondary memory is a non volatile memory. Non volatile memory: The memory that retains its contents permanently even after the computer is turned off. They hold the data permanently. E.g. Floppy disc, hard disc, CD. 2. Discrete Components of a Computer The term computer is used to describe a device made up of electronic and electro mechanical components Motherboard: A motherboard is one of the most essential parts of a computer system. It holds together many of the crucial components of a computer, including the central processing unit (CPU), memory and connectors for input and output devices. The base of a motherboard consists of a very firm sheet of nonconductive material, typically some sort of rigid plastic. Thin layers of copper or aluminum foil, referred to as traces, are printed onto this sheet. These traces are very narrow and form the circuits between the various components. In addition to circuits, a motherboard contains a number of sockets and slots to connect the other components. FIG: MOTHERBOARD PROCESSOR: A processor is the logic circuitry that responds to and processes the basic instructions that drives a computer. The processor reads the commands from the memory and then executes them. It performs basic arithmetical, logical, and input/output operations of a computer system. The processor is one of the most expensive parts of the computers and is also one of the smallest parts. MEMORY DEVICES: Unit-1 Memory: Is used to store programs and data during execution. RAM: Primary memory is often called as RAM (Random Access Memory). It holds all the programs and data the processor is using at a given time. RAM is volatile because its contents are erased when power is switched off. ROM: The other type of system memory is ROM (Read only Memory) which is permanent because it contents are not erased even when power is switched off. It is usually used to load an operating system. HARD DISK; A hard disk drive (HDD)is a data storage device used for storing and retrieving digital data information using rapidly rotating disks(platter) coated with magnetic material. An HDD retains its data even when powered off. Data is read in a random-access manner, meaning individual blocks of data can be stored or retrieved in any order rather than sequentially. An HDD consists of one or more rigid ("hard") rapidly rotating disks (platters) with magnetic heads arranged on a moving actuator arm to read and write data to the surfaces. CD-ROM : CD-ROM stands for compact disk read only memory. It consists of small disks similar to the gramophone records to hold digital information. As the name applies they are read only medium. With the advancement in technology writable CD’s are also available. KEYBOARD: The keyboard is the main input device for most computers. It is used to input text or enter commands into the PC. Nowadays keyboards with additional features are available like multimedia keyboard, wireless keyboard. MOUSE: With the invention of graphical user interface mouse is used to input information into the computer. Users simply point and click to enter information. The main advantage of mouse over keyboard is simplicity. And there are many operations that are much easier to perform with a mouse then a keyboard. MONITOR: The monitor is the specialized high-resolution screen similar to a television. The video card sends the contents of its video memory to the monitor at a rate of 60 or more time per second. The actual display screen is made up of red, green and blue dots that are illuminated by electron beam from behind. The video card DAC chip controls the movement of the electron beam, which then controls what dots are turned on and how bright they are, which then determines the picture you see on the screen. POWER SUPPLY: SMPS (Switch Mode Power Supply): The power supply supplies power to every single part in the PC. The main function of the power supply is to convert the 230 V AC into 3.3 V, 5 V and 12 V DC power that the system requires for the operations. In addition to supplying power to run the system, the power supply also ensures that the system does not run unless the power supplied is sufficient to operate the system properly. The power supply completes internal Unit-1 checks and tests before allowing the system to start. If the tests are successful, the power supply sends a special signal to the motherboard called Power_Good. If this signal is not present continuously, the computer does not run. Therefore, when the AC voltage dips and the power supply becomes stressed or overheated, the Power_Good signal goes down and forces a system reset or complete shutdown. BIOS: BIOS stands for Basic input and Output system. BIOS is a chip located on all motherboards that contain instructions and setup for how your system should boot and how it operates. The four main functions of BIOS POST - Test the computer hardware and make sure no errors exist before loading the operating system. Bootstrap Loader: A Boot loader is the first program (stored in ROM) which executes (before the main program) whenever a system is initialized. It is used to bootstrap a computer. The term boot is used to describe the process taken by the computer when turned on that loads the operating system and prepares the system for use. BIOS drivers - Low level drivers that give the computer basic operational control over your computer's hardware. BIOS or CMOS Setup - Configuration program that allows you to configure hardware settings including system settings such as computer passwords, time, and date. CMOS battery: CMOS (complementary metal-oxide-semiconductor) is the term usually used to describe the small amount of memory on a computer motherboard that stores the BIOS settings. It stores information such as the system time and date and the system hardware settings for your computer. The standard lifetime of a CMOS battery is around 10 Years. Peripheral Devices: Any external device, which is not necessary to perform the basic operation of computer, is called as peripherals. They provide additional computing capabilities. For ex: Printers, Modems, and Speakers etc. MODEM: Modem (Modulator and Demodulator) is typically used to send digital data over a phone line. The sending modem converts digital data into analog data, which can be transmitted over telephone lines, and the receiving modem converts the analog data back into digital form. This is used to connect to Internet. PRINTER: It is a device that must be connected to a computer which allows a user to print items on paper, such as letters and pictures. It can also work with digital cameras to print directly without the use of a computer. Unit-1 Different types of printers are 1) Laser 2) Inkjet 3) Dot-Matrix. 3. Computer Networks: What is Network? A network consists of two or more computers that are linked (connected) together in order to share resources (such as printers and CDs), exchange files, or allow electronic communications. The computers on a network may be linked through cables, telephone lines, radio waves, Satellites, or infrared light beams. Networking Components: Network Interface Card (NIC): A network interface card (NIC) is a circuit board or card that is installed in a computer so that it can be connected to a network. Each computer in a network has a special expansion card, called a network interface card (NIC). The NIC prepares (formats) and sends data, receives data, and controls data flow between the computer and the network. On the transmit side, the NIC passes frames of data on to the physical layer, which transmits the data to the physical link. On the receiver's side, the NIC processes bits received from the physical layer and processes the message based on its contents. Hub: Hub is a device that splits a network connection into multiple computers. It is like a distribution center. When a computer request information from a network or a specific computer, it sends the request to the hub through a cable. The hub will receive the request and transmit it to the entire network (every computer in the network including the originating computer). Most of the computers on the network will ignore the request. The computer that the request is being sent to will accept the data packet and send out a reply packet. The reply packet will then be sent to every computer by the hub. One problem with hubs is that they often cause collisions between packets. As a result, data is lost in transmission and must be re-sent. Unit-1 SWITCH: A switch is a small hardware device that joins multiple computers together within one local area network (LAN). A switch is a telecommunication device that receives a message from any device connected to it and then transmits the message only to the device for which the message was meant ( It don’t broadcast the received message to entire network). This makes the switch a more intelligent device than a hub (which receives a message and then transmits it to all the other devices on its network). Switches appear nearly identical to hubs, but a switch generally contains more intelligence (and a slightly higher price tag) than a hub. Unlike hubs, network switches are capable of inspecting data packets as they are received, determining the source and destination device of each packet, and forwarding them appropriately. Unlike hubs, switches can limit the traffic to and from each port so that each device connected to the switch has a sufficient amount of bandwidth. You can think of a switch as a "smart hub." Switches are more advanced than hubs and less capable than routers. ROUTER : A router is a device that joins two different networks together. A router is a device that forwards data packets between computer networks A router is connected to two or more data lines from different networks. When a data packet comes in one of the lines, the router reads the address information in the packet to determine its ultimate destination. Then, using information in its routing table, it directs the packet to the next network on its journey. Routers perform the "traffic directing" functions on the Internet. A data packet is typically forwarded from one router to another through the networks that constitute the internetwork until it reaches its destination. MODEM : A modem, short for modulator/demodulator, is a device that converts the digital signals generated by a computer into analog signals that can travel over conventional phone lines. The modem at the receiving end converts the analog signal back into a digital form that the computer can understand. This is used to connect the Internet. Unit-1 A modem is a device that allows you to connect to your Internet service provider and browse the Internet. Because modems only provide one IP address each, the best way to use a high-speed modem is to share its services among computers. ETHERNET CABLE : To set up a wired network, Ethernet cables are needed that allow the transmission of data from one networked device to another. Category 5 (Cat 5) cable is one of the most common types of Ethernet cable. When connecting computers to a network, one end of the Cat 5 cable is plugged into the computer’s NIC and the other is plugged into the hub, switch, or router. REPEATERS : A repeater is a network device that is used to regenerate signals (strength) that are weakened or distorted by transmission over long distances and through areas with high levels of electromagnetic interference (EMI). The purpose of a repeater is to extend the LAN segment beyond its physical limits (e.g. Ethernet is 500m for 10Base5). It is a simple hardware device that moves all packets from one local area network segment to another. The main purpose of a repeater is to extend the length of the network transmission medium beyond the normal maximum cable lengths. Unlike bridges and switches, repeaters do not have physical addresses on the network. BRIDGES: A bridge is used to join two network segments together; it allows computers on either segment to access resources on the other. They can also be used to divide large networks into smaller segments. Bridges have all the features of repeaters, but can have more nodes, and since the network is divided, there is fewer computers competing for resources on each segment thus improving network performance. Unit-1 Bridges can also connect networks that run at different speeds, different topologies, or different protocols. But they cannot, join an Ethernet segment with a Token Ring segment, because these use different networking standards. Bridges operate at both the Physical Layer and the MAC sublayer of the Data Link layer. Bridges read the MAC header of each frame to determine on which side of the bridge the destination device is located, the bridge then repeats the transmission to the segment where the device is located. WAPs (Wireless Access Point): A wireless network adapter card with a transceiver sometimes called an access point, broadcasts and receives signals to and from the surrounding computers and passes back and forth between the wireless computers and the cabled network. Access points act as wireless hubs to link multiple wireless NICs into a single subnet. Access points also have at least one fixed Ethernet port to allow the wireless network to be bridged to a traditional wired Ethernet network. Different Types of Networks: Depending upon the geographical area covered by a network, it is classified as: o o o o Local Area Network (LAN) Metropolitan Area Network (MAN) Wide Area Network (WAN) Personal Area Network (PAN) Local Area Network (LAN): A LAN is a network that is used for communicating among computer devices, usually within an office building or home. LAN’s enable the sharing of resources such as files or hardware devices that may be needed by multiple users. Is limited in size, typically spanning a few hundred meters, and not more than a mile. Is fast, with speeds from 10 Mbps to 10 Gbps. Requires little wiring, typically a single cable connecting to each device. Has lower cost compared to MAN’s or WAN’s LAN’s can be either wired or wireless. Twisted pair, coaxial or fibre optic cable can be used in wired LAN’s. Every LAN uses a protocol – a set of rules that governs how packets are configured and transmitted. Unit-1 Nodes in a LAN are linked together with a certain topology. These topologies include: Bus Ring Star LANs are capable of very high transmission rates (100s Mb/s to G b/s). Advantages of LAN Workstations can share peripheral devices like printers. This is cheaper than buying a printer for every workstation. User can save their work centrally on the network’s file server. This means that they can retrieve their work from any workstation on the network. They don’t need to go back to the same workstation all the time. Users can communicate with each other and transfer data between workstations very easily. One copy of each application package such as a word processor, spreadsheet etc. can be loaded onto the file and shared by all users. When a new version comes out, it only has to be loaded onto the server instead of onto every workstation. Disadvantages of LAN Special security measures are needed to stop users from using programs and data that they should not have access to; Networks are difficult to set up and need to be maintained by skilled technicians. If the file server develops a serious fault, all the users are affected, rather than just one user in the case of a stand-alone machine. Metropolitan Area Network (MAN): A metropolitan area network (MAN) is a large computer network that usually spans a city or a large campus. A MAN is optimized for a larger geographical area than a LAN, ranging from several blocks of buildings to entire cities. A MAN might be owned and operated by a single organization, but it usually will be used by many individuals and organizations. A MAN often acts as a high speed network to allow sharing of regional resources. A MAN typically covers an area of between 5 and 50 km diameter. Examples of MAN: Telephone company network that provides a high speed DSL to customers and cable TV network. Advantages of MANs The biggest advantage of MANs is the bandwidth (potential speed) of the connecting links. This means that Unit-1 resources (such as databases and files) shared on the network can be accessed extremely quickly. Disadvantages of MANs The key disadvantage of MANs is the cost of the cutting-edge technology employed. Also, this equipment generally has to be installed for the first time, as the copper traditionally used for the phone network is generally considered to be too slow to be annexed for this purpose. Wide Area Network (WAN): WAN covers a large geographic area such as country, continent or even whole of the world. A WAN is two or more LANs connected together. The LANs can be many miles apart. To cover great distances, WANs may transmit data over leased high-speed phone lines or wireless links such as satellites. Multiple LANs can be connected together using devices such as bridges, routers, which enable them to share data. The world's most popular WAN is the Internet. Advantages of WAN: Messages can be sent very quickly to anyone else on the network. These messages can have pictures, sounds, or data included with them (called attachments). Expensive things (such as printers or phone lines to the internet) can be shared by all the computers on the network without having to buy a different peripheral for each computer. Everyone on the network can use the same data. This avoids problems where some users may have older information than others. Share information/files over a larger area Unit-1 Disadvantages of WAN Setting up a network can be an expensive and complicated experience. The bigger the network the more expensive it is. Security is a real issue when many different people have the ability to use information from other computers. Protection against hackers and viruses adds more complexity and expense. Once set up, maintaining a network is a full-time job which requires network supervisors and technicians to be employed. Information may not meet local needs or interests. Vulnerable to hackers or other outside threats Personal Area Network (PAN): o A PAN is a network that is used for communicating among computers and computer devices (including telephones) in close proximity of around a few meters within a room. Generally cover a range of less than 10 meters (about 30 feet). o It can be used for communicating between the devices themselves, or for connecting to a larger network such as the internet. o PAN’s can be wired or wireless. USB and FireWire technologies often link together a wired PAN, while wireless PANs typically use Bluetooth or sometimes infrared connections. Bluetooth PANs are also sometimes called piconets. o A personal area network (PAN) is a computer network used for communication among computer devices, including telephones and personal digital assistants, in proximity to an Individual’s body. o These networks are used to transfer files including email and calendar appointments, digital photos and music. 4. Number Systems: Human beings use decimal (base 10). Computers use binary (base 2) number system, as they are made from binary digital components (known as transistors) operating in two states - on and off. In computing, we also use hexadecimal (base 16) or octal (base 8) number systems, as a compact form for represent binary numbers. 1. Decimal (Base 10) Number System Decimal number system has ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, called digits. It uses positional notation. That is, the least-significant digit (right-most digit) is of the order of 10^0 (units or ones), the second right-most digit is of the order of 10^1 (tens), the third right-most digit is of the order of 10^2 (hundreds), and so on. For example, (735)10 = 7×102 + 3×101 + 5×100 Unit-1 We shall denote a decimal number with an optional suffix D if ambiguity arises. 2. Binary (Base 2) Number System Binary number system has two symbols: 0 and 1, called bits. It is also a positional notation, for example, (10110)2 = 1×24 + 0×23 + 1×22 + 1×21 + 0×20 We shall denote a binary number with a suffix B. Some programming languages denote binary numbers with prefix 0b (e.g., 0b1001000), or prefix b with the bits quoted (e.g., b'10001111'). A binary digit is called a bit. Eight bits is called a byte (why 8-bit unit? Probably because 8=23). 3. Hexadecimal (Base 16) Number System Hexadecimal number system uses 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F, called hex digits. It is a positional notation, for example, (A3EH)16 = 10×16^2 + 3×16^1 + 14×16^0 We shall denote a hexadecimal number (in short, hex) with a suffix H. Some programming languages denote hex numbers with prefix 0x (e.g., 0x1A3C5F), or prefix x with hex digit quoted (e.g., x'C3A4D98B'). Each hexadecimal digit is also called a hex digit. Most programming languages accept lowercase 'a' to 'f' as well as uppercase 'A' to 'F'. 4. Conversion from Hexadecimal to Binary Replace each hex digit by the 4 equivalent bits, for examples, A3C5H = 1010 0011 1100 0101B 102AH = 0001 0000 0010 1010B 5. Conversion from Binary to Hexadecimal Starting from the right-most bit (least-significant bit), replace each group of 4 bits by the equivalent hex digit (pad the left-most bits with zero if necessary), for examples, 1001001010B = 0010 0100 1010B = 24AH 10001011001011B = 0010 0010 1100 1011B = 22CBH It is important to note that hexadecimal number provides a compact form or shorthand for representing binary bits. 6. Conversion from Base r to Decimal (Base 10) Given a n-digit base r number: (dn-1 dn-2 dn-3 ... d3 d2 d1 d0) (base r), the decimal equivalent is given by: Unit-1 dn-1 × r(n-1) + dn-2 × r(n-2) + ... + d1 × r1 + d0 × r0 7. Conversion from Decimal (Base 10) to Base r Use repeated division/remainder. For example, To convert 261D to hexadecimal: 261/16 quotient=16 remainder=5 16/16 quotient=1 remainder=0 1/16 quotient=0 remainder=1 (quotient=0 stop) Hence, 261D = 105H 8. Exercises (Number Systems Conversion) 1. Convert the following decimal numbers into binary and hexadecimal numbers: 1. 108 2. 4848 3. 9000 2. Convert the following binary numbers into hexadecimal and decimal numbers: 1. 1000011000 2. 10000000 3. 101010101010 3. Convert the following hexadecimal numbers into binary and decimal numbers: 1. ABCDE 2. 1234 3. 80F 4. [TODO] more INTRODUCTION ON BINARY: Bits: The smallest "unit" of data on a binary computer is a single bit. Since a single bit is capable of representing only two different values (typically zero or one) you may get the impression that there are a very small number of items you can represent with a single bit. Not true! There are an infinite number of items you can represent with a single bit. Nibbles: A nibble is a collection of four bits. It wouldn't be a particularly interesting data structure except for two items: BCD (binary coded decimal) numbers and hexadecimal numbers. It takes four bits to represent a single BCD or hexadecimal digit. With a nibble, we can represent up to 16 distinct values. In the case of hexadecimal numbers, the values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F are represented with four bits. BCD uses ten different digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) and requires four bits. In fact, any sixteen distinct values can be represented with a nibble, but hexadecimal and BCD digits are the primary items we can represent with a single nibble. Unit-1 Bytes: A byte consists of eight bits and is the smallest addressable datum (data item) on the 80x86 microprocessor. Main memory and I/O addresses on the 80x86 are all byte addresses. This means that the smallest item that can be individually accessed by an 80x86 programs is an eight-bit value. Bit 0 is the low order bit or least significant bit; Bit 7 is the high order bit or most significant bit of the byte. Note that a byte also contains exactly two nibbles: Bits 0…..3 comprise the low order nibble, bits 4….7 form the high order nibble. Since a byte contains exactly two nibbles, byte values require two hexadecimal digits. Since a byte contains eight bits, it can represent 28, or 256, different values. Generally, we'll use a byte to represent numeric values in the range 0...255, signed numbers in the range -128...+127 (see "Signed and Unsigned Numbers" ), ASCII/IBM character codes, and other special data types requiring no more than 256 different values. Many data types have fewer than 256 items so eight bits is usually sufficient. Words: A word is a group of 16 bits. We'll number the bits in a word starting from zero on up to fifteen. The bit numbering appears below: Like the byte, bit 0 is the low order bit and bit 15 is the high order bit. When referencing the other bits in a word use their bit position number. Notice that a word contains exactly two bytes. Bits 0 through 7 form the low order byte, bits 8 through 15 form the high order byte: With 16 bits, you can represent 216 (65,536) different values. These could be the values in the range 0…..65,535 (or, as is usually the case, -32,768..+32,767) or any other data type with no more than 65,536 values. The three major uses for words are integer values, offsets, and segment values. Unit-1 Words can represent integer values in the range 0…...65,535 or -32,768……32,767. Unsigned numeric values are represented by the binary value corresponding to the bits in the word. Signed numeric values use the two's complement form for numeric values. Segment values, which are always 16 bits long, constitute the paragraph address of a code, data, extra, or stack segment in memory. Double Words: A double word is exactly what its name implies, a pair of words. Therefore, a double word quantity is 32 bits long as shown below: Naturally, this double word can be divided into a high order word and a low order word, or four different bytes, or eight different nibbles. Double words can represent all kinds of different things. First and foremost on the list is a segmented address. Another common item represented with a double word is a 32-bit integer value (which allows unsigned numbers in the range 0……...4,294,967,295 or signed numbers in the range 2,147,483,648……...2,147,483,647). 32-bit floating point values also fit into a double word. Most of the time, we'll use double words to hold segmented addresses 5. BINARY REPRESENTATION ON INTEGERS: Integers are whole numbers or fixed-point numbers with the radix point fixed after the leastsignificant bit. They are contrast to real numbers or floating-point numbers, where the position of the radix point varies. It is important to take note that integers and floating-point numbers are treated differently in computers. They have different representation and are processed differently (e.g., floating-point numbers are processed in a so-called floating-point processor). Floating-point numbers will be discussed later. Computers use a fixed number of bits to represent an integer. The commonly-used bit-lengths for integers are 8-bit, 16-bit, 32-bit or 64-bit. There are two representation schemes for integers: 1. Unsigned Integers: can represent zero and positive integers. 2. Signed Integers: can represent zero, positive and negative integers. Three representation schemes had been proposed for signed integers: 1. Sign-Magnitude representation 2. 1's Complement representation 3. 2's Complement representation 1. Unsigned Integers : Unsigned integers can represent zero and positive integers, but not negative integers. The value of an unsigned integer is interpreted as "the magnitude of its underlying binary pattern". Range: An unsigned integer containing n bits can have a value between 0 and 2n – 1. Example 1: Unit-1 Suppose that n=8 and the binary pattern is 0100 0001B, the value of this unsigned integer is 1×20 + 1×26 = 65D. Example 2: Suppose that n=16 and the binary pattern is 0001 0000 0000 1000B, the value of this unsigned integer is 1×23 + 1×212 = 4104D. An n-bit pattern can represent 2n distinct integers. An n-bit unsigned integer can represent integers from 0 to (2n)-1, as tabulated below: N(number of bits) 8 16 32 64 Minimum value 0 0 0 0 Maximum value (28)-1 (=255) (216)-1 (=65,535) (232)-1 (=4,294,967,295) (9+ digits) (264)-1 (=18,446,744,073,709,551,615) (19+ digits) 2. Signed Integers: Signed integers can represent zero, positive integers, as well as negative integers. Three representation schemes are available for signed integers: 1. Sign-Magnitude representation 2. 1's Complement representation 3. 2's Complement representation In all the above three schemes, the most-significant bit (msb) is called the sign bit. The sign bit is used to represent the sign of the integer - with 0 for positive integers and 1 for negative integers. The magnitude of the integer, however, is interpreted differently in different schemes. 2.1. Signed Integers in “Sign-Magnitude Representation” : In sign-magnitude representation: The most-significant bit (msb) is the sign bit, with value of 0 representing positive integer and 1 representing negative integer. The remaining n-1 bits represent the magnitude (absolute value) of the integer. The absolute value of the integer is interpreted as "the magnitude of the (n-1)-bit binary pattern". The largest and smallest signed integer that can be represented by using Signed Magnitude method of N bits is –(2(N – 1) – 1) to 2(N – 1) –1 Sign Magnitude Representation for 3 bit pattern: Binary data Decimal Value 000 +0 001 +1 010 +2 Unit-1 011 +3 100 -0 101 -1 110 -2 111 -3 The drawbacks of sign-magnitude representation are: 1. There are two representations (0000 0000B and 1000 0000B) for the number zero, which could lead to inefficiency and confusion. 2. Positive and negative integers need to be processed separately. Example 1: Suppose that n=8 and the binary representation is 0100 0001B. Sign bit is 0 ⇒ positive Absolute value is 100 0001B = 65D Hence, the integer is +65D Example 2: Suppose that n=8 and the binary representation is 1000 0001B. Sign bit is 1 ⇒ negative Absolute value is 000 0001B = 1D Hence, the integer is -1D 2.2. Signed Integers in 1's Complement Representation : In 1's complement representation: Again, the most significant bit (msb) is the sign bit, with value of 0 representing positive integers and 1 representing negative integers. The remaining n-1 bits represents the magnitude of the integer, as follows: 1. For positive integers, the absolute value of the integer is equal to "the magnitude of the (n-1)bit binary pattern". 2. For negative integers, the absolute value of the integer is equal to "the magnitude of the complement (inverse) of the (n-1)-bit binary pattern" (hence called 1's complement). The largest and smallest signed integer that can be represented by using Signed Magnitude method of N bits is –2(N – 1) – 1 to 2(N – 1) –1 1’s Complenent Representation for 3 bit pattern: Binary data Decimal Value 000 +0 001 +1 010 +2 Unit-1 011 +3 100 -3 101 -2 110 -1 111 -0 Again, the drawbacks are: 1. There are two representations (0000 0000B and 1111 1111B) for zero. 2. The positive integers and negative integers need to be processed separately. Example 1: Suppose that n=8 and the binary representation 0 100 0001B. Sign bit is 0 ⇒ positive Absolute value is 100 0001B = 65D Hence, the integer is +65D Example 2: Suppose that n=8 and the binary representation 1 000 0001B. Sign bit is 1 ⇒ negative Absolute value is the complement of 000 0001B, i.e., 111 1110B = 126D Hence, the integer is -126D 2.3 Signed Integers in 2's Complement Representation : In 2's complement representation: Again, the most significant bit (msb) is the sign bit, with value of 0 representing positive integers and 1 representing negative integers. The remaining n-1 bits represents the magnitude of the integer, as follows: o For positive integers, the absolute value of the integer is equal to "the magnitude of the (n-1)bit binary pattern". o For negative integers, the absolute value of the integer is equal to "the magnitude of the complement of the (n-1)-bit binary pattern plus one" (hence called 2's complement). If a signed integer has n bits, it can contain a number between - 2n - 1 and + (2n - 1 - 1). Advantage over Sign-Magnitude representation and 1's Complement representation are 1. There is only one representation for the number zero in 2's complement, instead of two representations in sign-magnitude and 1's complement. 2. Positive and negative integers can be treated together in addition and subtraction. Subtraction can be carried out using the "addition logic". 2’s Complenent Representation for 3 bit pattern: Binary data Decimal Value 000 0 Unit-1 001 +1 010 +2 011 +3 100 -4 101 -3 110 -2 111 -1 Example 1: Suppose that n=8 and the binary representation 0 100 0001B. Sign bit is 0 ⇒ positive Absolute value is 100 0001B = 65D Hence, the integer is +65D Example 2: Suppose that n=8 and the binary representation 1 000 0001B. Sign bit is 1 ⇒ negative Absolute value is the complement of 000 0001B plus 1, i.e., 111 1110B + 1B = 127D Hence, the integer is -127D EXAMPLES: Example 1: Addition of Two Positive Integers: Suppose that n=8, 65D + 5D = 70D 65D → 0100 0001 5D → 0000 0101 ( +) -------------0100 0110 → 70D (OK) Example 2: Subtraction is treated as Addition of a Positive and a Negative Integers: Suppose that n=8, 5D - 5D = 65D + (-5D) = 60D 65D → 0100 0001 -5D → 1111 1011 (+) -------------0011 1100 → 60D (discard carry - OK) Example 3: Addition of Two Negative Integers: Suppose that n=8, -65D - 5D = (-65D) + (5D) = -70D -65D → -5D → 1011 1111 1111 1011 (+) -------------1011 1010 → -70D (discard carry - OK) Unit-1 Because of the fixed precision (i.e., fixed number of bits), an n-bit 2's complement signed integer has a certain range. For example, for n=8, the range of 2's complement signed integers is -128 to +127. During addition (and subtraction), it is important to check whether the result exceeds this range, in other words, whether overflow or underflow has occurred. Example 4: Overflow: Suppose that n=8, 127D + 2D = 129D (overflow - beyond the range) 127D → 0111 1111 2D → 0000 0010 (+ ------------1000 0001 → -127D (wrong) Example 5: Underflow: Suppose that n=8, -125D - 5D = -130D (underflow - below the range) -125D → -5D → 1000 0011 1111 1011 (+ --------------0111 1110 → +126D (wrong) The following diagram explains how the 2's complement works. By re-arranging the number line, values from -128 to +127 are represented contiguously by ignoring the carry bit. Binary Arithmetic Binary Addition 0 0 1 1 + + + + 0 1 0 1 = = = = 0 1 1 0, and carry 1 to the next more significant bit For example, 00011010 + 00001100 = 00100110 0 + 0 0 0 1 0 0 1 1 0 1 1 0 1 1 0 0 0 carries = 26(base 10) = 12(base 10) -----------------------------------0 0 1 0 0 1 1 0 = 38(base 10) 0 + 0 1 0 0 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 0 carries = 19(base 10) = 62(base 10) 00010011 + 00111110 = 01010001 ----------------------------------0 1 0 1 0 0 0 1 = 81(base 10) Note: The rules of binary addition (without carries) are the same as the truths of the XOR gate. Unit-1 Rules of Binary Subtraction 0 0 1 1 - 0 1 0 1 = = = = 0 1, 1 0 and borrow 1 from the next more significant bit For example, 00100101 - 00010001 = 00010100 0 - 0 0 1 10 0 1 0 0 0 0 1 0 0 0 borrows = 37(base 10) = 17(base 10) 1 1 ----------------------------------0 0 0 1 0 1 0 0 = 20(base 10) 0 0 0 10 1 1 0 1 1 0 10 0 1 1 1 1 0 borrows = 51(base 10) = 22(base 10) 00110011 - 00010110 = 00011101 0 - 0 ----------------------------------0 0 0 1 0 × 0 0 0 1 1 0 1 = 29(base 10) Binary Multiplication 0 0 1 1 x x x x 0 1 0 1 = = = = 0 0 0 1, and no carry or borrow bits For example, 00101001 × 00000110 = 11110110 1 0 0 0 1 0 0 1 0 1 1 0 = = 41(base 10) 6(base 10) -------- --------------------------------0 0 0 0 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 -----------------------------------------0 0 00010111 × 00000011 = 01000101 1 1 1 1 0 1 1 0 = 246(base 10) 0 × 0 0 0 0 0 1 0 0 0 1 0 1 1 1 1 = = 23(base 10) 3(base 10) ----------------------------------0 0 0 1 0 0 1 0 1 1 1 0 1 0 1 1 1 1 carries 1 1 1 ------------------------------------- Unit-1 0 0 1 0 0 0 1 0 1 = 69(base 10) Note: The rules of binary multiplication are the same as the truths of the AND gate. Binary Division Binary division is the repeated process of subtraction, just as in decimal division. For example, 00101010 ÷ 00000110 = 00000111 1 1 1 = 7 -------------------------------1 1 0 ) 0 0 1 10 1 0 1 1 0 - = = 42(base 10) 6(base 10) -----------------1 1 borrows 0 1 - 10 1 1 0 ------------------ 1 1 1 1 0 0 --------------------0 Binary Number System System Digits: 0 and 1 Bit (short for binary digit): A single binary digit LSB (least significant bit): The rightmost bit MSB (most significant bit): The leftmost bit Upper Byte (or nybble): The right-hand byte (or nybble) of a pair Lower Byte (or nybble): The left-hand byte (or nybble) of a pair Binary Equivalents 1 Nibble (or nibble) = 4 bits 1 Byte = 2 nibbles = 8 bits 1 Kilobyte (KB) = 1024 bytes 1 Megabyte (MB) = 1024 kilobytes = 1,048,576 bytes 1 Gigabyte (GB ) =1024 megabytes = 1,073,741,824 bytes Logical Operations on Bits There are four main logical operations we'll need to perform on hexadecimal and binary numbers: AND, OR, XOR (exclusive-or), and NOT. The logical AND operation is a dyadic operation (meaning it accepts exactly two operands). These operands are single binary (base 2) bits. The AND operation is: 0 and 0 = 0 0 and 1 = 0 1 and 0 = 0 1 and 1 = 1 Unit-1 A compact way to represent the logical AND operation is with a truth table. A truth table takes the following form: AND Truth Table AND 0 1 0 0 0 1 0 1 The logical AND operation is, "If the first operand is one and the second operand is one, the result is one; otherwise the result is zero." The logical OR operation is also a dyadic operation. Its definition is: 0 or 0 = 0 0 or 1 = 1 1 or 0 = 1 1 or 1 = 1 The truth table for the OR operation takes the following form: OR Truth Table OR 0 1 0 0 1 1 1 1 Colloquially, the logical OR operation is, "If the first operand or the second operand (or both) is one, the result is one; otherwise the result is zero." This is also known as the inclusive-OR operation. The logical XOR (exclusive-or) operation is also a dyadic operation. It is defined as follows: 0 xor 0 = 0 0 xor 1 = 1 1 xor 0 = 1 1 xor 1 = 0 The truth table for the XOR operation takes the following form: XOR Truth Table XOR 0 1 0 0 1 1 1 0 In English, the logical XOR operation is, "If the first operand or the second operand, but not both, is one, the result is one; otherwise the result is zero." Note that the exclusive-or operation is closer to the English meaning of the word "or" than is the logical OR operation. If the first operand contains a zero, then the result is exactly the value of the second operand. This feature lets you selectively invert bits in a bit string. The logical NOT operation is a monadic operation (meaning it accepts only one operand). It is: NOT 0 = 1 Unit-1 NOT 1 = 0 The truth table for the NOT operation takes the following form: NOT Truth Table NOT 0 1 1 0 Generations of Computer languages: Programming languages are used to write application programs which are used by end users. Each computer programming language has its own distinctive grammars and syntax and its own manner of expressing ideas. The development of programming languages has improved considerably with the ease and ability of programmers to write powerful applications programs that can solve any task in the world today. The concept of generation of programming languages is closely connected to the advances in technology that brought about computer generations. Programming languages fall in to three broad categories (Five Generations): 1. Machine languages ( 1st -generation ) 2. Assembly languages (2nd -generation ) 3. Higher-level languages ( 3rd , 4th , 5th - generation) First-generation programming language – Binary The first generation computer language was machine language, all machines used machine code which consists of 0s and 1s. This is the lowest level of programming language. The machine language is the only language that the computer understands. Machine language is a language which is interpreted and executed directly by the computer. Machine language is highly efficient and allows direct control of each operation; however programmers had to write computer programs using 0 and 1. The main advantage of programming in 1GL is that the code can run very fast and very efficiently, precisely because the instructions are executed directly by the CPU. One of the main disadvantages of programming in a low level language is that it is difficult to learn and it is very difficult to fix the errors. Introduced in the 1940s Instructions/Data entered directly in binary Memory must be manually moved around Unit-1 Programs were difficult to write and debug Programming process was tedious Programs were error prone Examples: Architecture specific binary delivered on Switches, Patch Panels and/or Tape. Second-generation programming language (2GL) – Assembly The second generation of programming language includes assembly language. Assembly languages are symbolic programming languages that use symbolic notation to represent machine language instructions. Assembly language developed in the mid 1950s. It is used symbolic codes also known as mnemonic codes that are easy to remember abbreviations rather than numbers (binary). Examples of mnemonic codes include ADD for addition, SUB for subtraction, MUL for multiplication, CMP for compare e.t.c. Programs written in assembly language need a translator often known as assembler to convert them into machine language. This is because computer will understand only the language of 1s & 0s and will not understand mnemonics like ADD , SUB e.t.c. Example: Addition of two numbers in assembly language MOV AX, 4 (stores the value 4 in the AX register of CPU) MOV BX, 6 (stores the value 6 in the BX register of CPU) ADD (Add the contents of AX and BX register. Store the result in AX register.) AX, BX Introduced in the mid 1950s Written by a programmer in an intermediate instruction language which is later compiled into binary instructions Specific to platform architecture Designed to support logical structure, debugging Defined by three language elements: Opcodes (CPU Instructions), Data Sections (Variable Definitions) and Directive (Macros) Examples: Almost every CPU architecture has a companion assembly language. Most commonly in use today are RISC, CISC and x86 as that is what our embedded systems and desktop computers use. Third-generation programming language (3GL) – Modern The third generation of programming languages (3GL) is a refinement of the second generation programming language. The third generation was introduced to make the languages more programmer friendly. Unit-1 In these languages, the program statements are not closely related to the internal characteristics of computer and is therefore often referred to as high level language. 3GL made programming easier, efficient, and less prone to errors. Programs were written in English like manner, making them more convenient to use and given the programmer more time to address a client problems. A translator is needed to translate the instructions written in high level language into a machine level language. Such translators are commonly known as compilers and interpreters. Introduced in the early 1960s. Designed around ease of use for the programmer Driven by desire for reduction in bugs, increases in code reuse Based on natural language Often designed with in mind Examples: 3rd generation languages include the following C, C++, C#, Java, Basic, FORTRAN, COBOL. Fourth-generation programming language – Application Specific 4GL, or "report generator language" is an "application specific" language, one with built-in knowledge of an application domain. (in the way that SQL has built-in knowledge of the relational database domain.) The term was invented by Jim Martin to refer to non-procedural high level languages built around database systems. Fourth generation languages are close to natural language and were built with the concept that certain applications could be generalized by adding limited programming ability to them. A fourth generation language is designed with making problems in a specific domain simple to implement. This has the advantage of greatly reducing development time cost. At the same time there is the disadvantage of increasing developer learning cost. Introduced in the 1970s. Driven by the need to enhance developer productivity Closer to the domain Some examples: SQL, SAS, MATLAB’s GUIDE, ColdFusion, CSS Fifth-generation programming language – Constraint Oriented Many researchers speak of 5GL languages as constraint systems. The programmer inputs a set of logical constraints, with no specified algorithm, and the AI-based compiler builds the program based on these constraints. These languages used for artificial intelligence and neural networks. Unit-1 Introduced in the 1990s Constraint-based instead of algorithmic Used for AI Research, Proof solving, Not in common use Some examples: Prolog, Mercury