Low Level Systems Notes Software Design & Development: Low Level operations and computer architecture & Contemporary developments
Contents Data Representation - Numbers Questions Data Representation – Text & Graphics Data Representation – Computer Architecture Data Representation – Development Environments & Translation Contents page with links to lesson topics
Data Representation - Numbers Computers can only use the numbers 1 and 0. Information in a computer is stored in groups of 1s and 0s called binary. A single 1 or 0 in a computer is called a binary digit or bit. As a single 1 or 0 by itself can only represent two states, bits are collected together into groups of eight. Eight bits make up a byte. All information on a computer is stored as bytes or groups of bytes. Integers can be represented in a byte using binary Memory locations on a computer store multiple bytes each
We are used to decimal numbers: we have units, 10s, 100s, 1000s etc 1000s 100s 10s units 5 4 3 0 These are called place values
In binary the place values go up by a factor of 2: Units, 2s, 4s, 8s, 16s etc 128s 64s 32s 16s 8s 4s 2s units 0 0 1 0 1 1 0 1
Binary to Decimal Conversion Step 1: Draw the place values 128 64 32 16 8 4 2 1 You only need to draw the conversion grid once. It appears multiple times here to show the steps you need to take
Step 2: Enter the number to convert In this example we will convert the binary value 0010 1101 128 64 32 16 8 4 2 1 0 0 1 0 1 1 0 1
Step 3: Add up the numbers with a 1 beneath them 128 64 32 16 8 4 2 1 0 0 1 0 1 1 0 1 32 + 8 + 4 + 1 = 45
Decimal to Binary Conversion Step 1: Draw the conversion grid and write the number to convert below it In this example we will convert 51 into binary 128 64 32 16 8 4 2 1 51 You only need to draw the conversion grid once. It appears multiple times here to show the steps you need to take
Step 2: Find the largest place value that is less than the number to convert, and write in a 1 In this example 32 is the first place value smaller than 51 128 64 32 16 8 4 2 1 0 0 1 51
Step 3: Subtract that value from the number to convert Step 3: Subtract that value from the number to convert. This is the new number to convert In this example we subtract 32 from 51 to get 19. We now have to convert this 19 to binary 128 64 32 16 8 4 2 1 0 0 1 51 – 32 = 19
Step 4: Repeat steps 1 to 3 128 64 32 16 8 4 2 1 0 0 1 1 51 – 32 = 19 16 is the first place value smaller than 19, so we write a 1 in the 16 column and subtract 16 from 19 to be left with 3 128 64 32 16 8 4 2 1 0 0 1 1 51 – 32 = 19 19 – 16 = 3
Step 5: Keep converting until you are left with 0 So 51 in binary is 0011 0011 128 64 32 16 8 4 2 1 0 0 1 1 0 0 1 1 51 – 32 = 19 19 – 16 = 3 3 – 2 = 1 1 – 1 = 0
Floating Point Representation The method used above can only store integers. Fractions and real numbers have to be stored using floating point representation Floating point representation is a method of representing real numbers in a computer. It can store numbers in a great range by splitting them up into a mantissa and an exponent. The mantissa represents the value of the stored number. The number of bits used in the mantissa affect how accurately the number is stored – more bits equals more accurate. The mantissa is multiplied by 2 raised to the power of the exponent. This means that the floating point number can store values in a far greater range than the mantissa itself. The exponent affects the range of values that can be stored – more bits equals a bigger range of numbers. .10110010 x 20101 exponent mantissa
Questions – Data Representation –Numbers Answer questions in full sentences! How are integers represented in a computer? Describe how floating point numbers are represented on a computer In a floating point number, explain the effect of changing the number of bits in the mantissa exponent Convert the following numbers from binary into decimal 0000 1101 0011 0101 1101 0101 Convert the following decimal numbers to binary 26 83 207
Data Representation - Text Text can be broken up into characters Letters Numeric characters Punctuation marks or other symbols In a computer, text is represented in a binary code. Each binary value represents a single text character The most simplest code used for storing text is ASCII
ASCII The American Standard Code for Information Interchange is a character set that represents all the letters, numeric characters and symbols used in English. ASCII can be represented in seven bits. The last bit of the byte is left as 0 as a check bit. Later variants used the eighth bit to enable ASCII to represent all Latin characters ASCII also includes a number of non-printable control characters. These were originally intended to give the computer instructions, such as make a noise or move the cursor
Character Binary Decimal Space 010 0000 32 ! 010 0001 33 ‘ 010 0010 34 011 0001 48 1 011 0010 49 2 011 0011 50 A 100 0001 65 B 100 0010 66 C 100 0011 67 a 110 0001 97 b 110 0010 98 c 110 0011 99
Data Representation - Graphics There are two different ways that graphics can be represented in a computer. Bitmap graphics are made up of many little dots called pixels. The colour of each individual pixel is stored on the computer in binary. Binary code representing Vector graphics are made up of lines, shapes and objects. The attributes that describe how the shapes appear are encoded in binary. Different shapes will have different attributes. A line might have the following attributes: Line start x & y Line end x & y Line thickness Line colour
Storage Requirements The amount of storage required to save a bitmap image behaves differently from the amount required to store a vector image The storage requirements of a vector graphic relate to the number of objects in the image. Each object and its attributes have to be stored. The more objects in the image, the larger the storage requirements will be Vector graphics are good for storing diagrams and similar images The storage requirements of a bitmap image relate to the number of pixels in the image, and how much space is required for each pixel The storage requirements of a given sized bitmap are constant, regardless of the complexity of the image. Bitmaps are good for storing photographs
Calculating the Storage Requirements of a bitmap The formula for calculating the storage requirements of a bitmap is: number of pixels x storage for one pixel or Length in pixels x height in pixels x storage for one pixel You will be expected to give your answer in a reasonable unit, so be prepared to convert between the different units of storage Example – the storage requirements of a 600 x 400 bit map that uses 24 bit true colour = 600 x 400 x 24 bits = 5,760,000 bits = 720,000 bytes = 703.125 kilobytes Divide by 8 to get the number of bytes Divide by 1024 to get the number of kilobytes Always write down the unit of storage at each step!
Questions – Text & Graphics Answer questions in full sentences! Describe how computers represent text using ASCII Describe how computers represent bitmap graphics Describe how computers represent vector graphics Calculate the storage requirements for the following text messages: Hello there! A flow chart diagram Calculate the storage requirements of the following bitmaps: 600 by 400pixels 8 bit bitmap image 1920 by 1080 pixels 3 byte bitmap image 400 by 300 pixels 256 colour image 4 by 3 inches at 200 dpi true colour image
Computer Architecture – The Processor The processor of a computer is the part of the computer that executes program instructions All processors have a clock speed, measured in gigahertz (gHz). The rate at which the processor executes instructions is related to the clock speed. A faster clock speed means instructions are executed faster.
Processor Structure The processor of a computer is made up of a number of sub units The control unit of a processor directs the operation of the computer. It controls the flow of data between the other processor sub units and the rest of the computer The arithmetic and logic unit of a processor performs calculations and comparisons. The registers of a processor are short term memory locations with a very fast access speed. Some registers have a dedicated purpose, such as the instruction register which holds the instruction currently being executed. Other registers are accessible to the program and can be used to store data for the ALU
Memory The main memory of a computer is a series of addressable storage locations Each memory location is uniform in size, holding the same amount of information as the computer’s data bus. The memory locations have a unique identifier – their address There are two types of computer memory ROM – Read Only Memory RAM – Random Access Memory ROM is used to store programs that the computer needs to run – the basic operating system for the computer. RAM is used to store other programs, as well as any data used by the programs being executed. Program instructions are loaded from memory to the registers on the processor when they are to be executed
Memory units A single bit can not represent much by itself so in a computer the smallest unit of information is a byte 8 bits = 1 byte The memory locations of a computer will typically be a number of bytes in size Because computers typically have millions of memory locations, we use a number of other units to describe the total memory available in a computer 1024 bytes = 1 kilobyte 1024 kilobytes = 1 megabyte 1024 megabytes = 1 gigabyte 1024 gigabytes = 1 terabyte
ROM vs RAM ROM : Persistent – the contents of ROM remain when the power is turned off Cannot be changed Typically only a small percentage of the computers memory Used for the basic operating system only RAM : Volatile – the contents of RAM are lost when the power is turned off Can be changed and overwritten Makes up the vast majority of the computers memory Used for any programs running on the computer and their data
Buses The buses of a computer connect the various internal component and allow information to be passed between them The data bus is used to read and write information from the registers to the main memory, and even permanent backing storage via an interface Data buses are connected to all the memory locations of a computer. They have a size, which will be the same as the size of each memory location The address bus is used to specify which memory location will be read or written to. Address buses also have a size. The more bits that an address bus can transfer, the more memory locations a computer can have
Interfaces Recall: The data bus transfers information between the processor and the memory Information has to also be transferred from input devices, to output devices and back and forth from backing storage devices. These all represent information differently, and are designed to be used with different types of computer An interface allows the transfer of information between the processor and memory and the input, output and backing storage parts of a computer A SATA interface
Interfaces have a number of tasks Data conversion – The computer may represent information differently from the device Speed conversion – The computer may run at a different speed from the device Buffering – As the computer and device may run at different speeds, the interface requires storage to temporarily hold information for the slower side of the interface Status Information – So the computer knows the status of the device: Is it working? Ready to accept more data?
Questions – Architecture Answer questions in full sentences! List the component parts of the CPU. Describe what they do How does the clock speed of a processor affect programs run on it Describe three differences between ROM and RAM: List and describe the buses in a computer Why do computers need an interface to connect devices? List and describe the tasks carried out by an interface
High Level Languages & Development Environments When you program a computer, you do not use the same instructions that the processor uses A High level language uses a grammar and syntax that is closer to natural languages like English than to the machine code understood by computers Most high level languages have one or more development environments. The development environment will provide assistance to the programmer, helping them debug and run their programs
Text Based Development Environments In a text based development environment, the programmer directly types the program using their keyboard Text based environments allow great flexibility, as any program can be typed in, but they require a greater level of programming knowledge and it is very easy to make syntax errors Text based development environments have existed for longer than graphical development environments IDLE is an example of a text based development environment. It helps the user by colouring keywords, comments and values differently, as well as highlighting lines where errors occur
Graphical Development Environments In a graphical development environment, the program assembles their program by using their mouse to drag graphical elements together Graphical development environments are useful for learner programmers as they do not need to know the syntax of the language. Graphical environments are also good for user interface development as the UI can be developed visually Graphical development environments are comparatively new Scratch is an example of a graphical development environment. As programs are made from blocks, it is very hard to make syntax errors, but the limited selection of blocks means it lacks flexibility
The need for translation The processor of a computer only understands instructions in its native machine code For a high level language program to be run on a computer, it needs to be translated from the high level language into machine code There are two methods of translating high level languages – using an interpreter or using a compiler
Interpreters An interpreter translates each line of HLL program code on at a time before executing it. The translated code is discarded after it is executed Interpreters are useful for debugging – when a run- time error occurs it can be linked directly to the currently translated line of HLL program code Interpreted programs run slowly: The program has to be translated each time it is run. Loops are particularly slow – the code inside the loop is translated again each time the loop is executed
Compilers A compiler translates a HLL program entirely into machine code. The code is not executed, instead a machine code program is created which can be run independently of the development environment Compiled code runs fast. Once it has been translated into an executable, it does not need to be translated again Because the HLL code is not used in the translated executable, the errors caused by bugs in the program are much more difficult to identify
Questions – Translation and development environments Answer questions in full sentences! What is a high level language? Explain why high level languages need to be translated Give one advantage and one disadvantage of using interpreters to translate code Give one advantage and one disadvantage of using compilers to translate code When creating software, when would you be likely to use an interpreter and when would you be likely to use a compiler? Give one advantage and one disadvantage of text based development environments Give one advantage and one disadvantage of graphical development environments