Monday, 11 November 2013

Binary and Code

Binary

Binary is a Base-2 number system, and is the lowest level language a computer can read. Binary is composed entirely of 1''s and 0's. Every number in Binary is a bit, every four is a nibble, and every eight is a byte. Binary is read from right to left, with each instance of the number 1 representing a number. For example:

8 4 2 1
0 1 0 0

This is the number 4, as there is a 1 in the 4 position.

Binary addition is best done vertically. To add two binary numbers, write them out, one above the other. From left to right, if there is a single 1 in a column, then there will be a 1 in the same column in the answer. If there is no 1, it will be 0 in the column. If there is two 1's, there will be 0 in the column, and the one will carry over to the next column. If there is 3 1's, (two in the columns and a carryover) the answer will be 1 and it will carry over. If a number ends up being repeatedly carried until the end of the byte, until there is nothing left to carry it to, an extra number is added on the left which will be 1. Here is a picture showing binary addition:



Hex

Hex is a Base-16 number system. The first number represents a multiple of 16, e.g. if the firsay
t number is 5, it means 5 * 16. The second number is added onto the first, so 52 would be: 16 * 5 + 2. Hex also uses letters, after going from 0 - 9, it goes from A - F, giving 16 usable numbers. Therefore, A = 10, B = 11 ... F = 15, so 9A would be: 9 * 16 + 10 = 154.



A Bin - Hex - Dec conversion table.
ASCII

ASCII stands for American Standard Code for Information Interchange, and is a set of 127 codes that are used to represent standard and commonly used characters in text, or a Character Set. There are 52 codes for al alphabetic symbols, upper and lower case, 10 codes for numeric symbols (0 - 9), 33 codes for punctuation, space, and other symbols, and 32 for non-printable control codes. As there are 127 codes, and 01111111 = 127, the entire ASCII Character Set is only 7 bits.

When 8-bit computers became more common, ASCII was updated to use 8-bits, adding an extra 128 characters. The Unicode system uses 32 bits (4 bytes) and allows more than 4 billion values.




Instruction Set




An instruction set is all the instructions a CPU can execute, in a form more readable by us. Instructions include things such as Arithmetic (addition, subtraction, etc); logic and logic gates (and, or, not); data instructions, such as move, store, load, save, etc; and control flow instructions like goto, call and return.

Instruction Sets are different depending on the processor, however most AMD and Intel 32-bit processors will have extremely similar instruction sets, with many of the same instructions to avoid certain programs having incompatibilities on some processors. ARM processors will usually have a completely different instruction set as they are more focused on smaller devices such as phones, tablets, portable games consoles and more.

An example of there being major differences between instructions sets was in the competition between 64-bit architectures for CPU's. Intel's Itanium CPU's were competing with AMD's x86-64, and both worked very differently. AMD opted to use 32-bit instruction sets with 64-bit instructions added in, while Intel went only with 64-bit instructions. Ultimately, AMD won and Intel switched to their 64-bit architecture, as it still supported x86 instructions, but added x64 ones, however Intel still introduced a few differences.

Data Sizes

Bit = 1 unit
Nibble = 4 units
Byte = 8 units
Kilobyte = kB = 1024 bits
Megabyte = MB = 1024 kilobytes
Gigabyte = GB = 1024 megabytes
Terabyte = 1024 Terabytes

Images - I love penis

Images are represented with binary numbers. The Metadata located at the start of the image files gives information such as the resolution, colour depth, width and height. Without this, the image might appear as just a string of 1's and 0's with no shape. Colour Depth is the number of colours that can be displayed in the image. For example, a colour depth of 1 bit can represent 2 colours, 1 and 0, often used to show black and white. A depth of 2 bits allows 4 colours and so on. This is how a bitmap image is stored. A vector image is stored as a formulae and won't lose quality when being resized, as it recalculates all the points, lines and curves of the image, instead of enlarging each pixel like with bitmap.




Sound

Sound is an analogue format. T store it on a computer we need to convert it into a digital format. To do this we measure the frequency/loudness at regular intervals. These are called samples. The bit rate is the number of bits sampled in a given time. Sound files are often quite large, this means we have to compress them into a format like MP3, which is compressed using an algorithm that removes unnecessary sounds.



Development Software

To develop software, a variety of tools can be used. An Editor is the most necessary, it's like a text editor that doesn't save formatting. Some editors will have extra features such as "Pretty Printing", which indents colour codes things in your code like loops, variables and functions for easy identification. Editors will often add line numbers to the side of the editor, so you can easily pinpoint exactly where a problem is during debugging. Editors with expanded features that are often more focused towards one language are called IDE's, or Integrated Development Environments.

Sublime Text, a popular code/text editor
Compilers

Compilers convert high-level source code (high-level being programming languages designed to read more like English, like C++ or Java) into machine code that can then be run by the CPU. Compilers are available for practically every language, and often come integrated into more feature-rich editors (Such as Microsoft Visual Studio and Eclipse).


Code::Blocks, a C/C++ editor that includes several different compilers to use.


Interpreters

Interpreters also translate high-level code into machine code, however they do it a line at a time, executing the code as it comes. This makes them useful for debugging as they spot errors immediately. The downside to this is that the interpreter has to be on the users machine when the program is run, which in turn uses up more RAM and means that the program can only be run if you have the correct interpreter.

Assemblers

Assembly Language is a way to write low-level programs without using Binary Bit Patterns. Assembly language, along with machine code are both low-level and allow the programmer to control the CPU's operations directly. Assembly Language is specific to the processor and will vary by manufacturer, for example, Intel uses a completely different assembly language to Samsung. Each assembly instruction translates to one machine instruction, and they have to be translated into machine code before they can be run. This is what the assembler is used for.

Linkers

Programs are often made from different sub-programs, and are often made by different people using different tools. A Linker is a piece of software that merges these applications together into a finished program.

Monday, 23 September 2013

Hardware

The CPU, or the 'Central Processing Unit', is the main component of a computer system. It is responsible for making calculations and controlling the system. There are two parts of the CPU, the ALU, or 'Arithmetic and Logic Unit', which is responsible for mathematics and logical operations, and the Control Unit, which executes instructions of programs stored in the RAM by using electrical signals. The CPU uses a system called Fetch-Decode-Execute, where the CPU fetches an instruction from it's memory, works out what the instruction requires, then carries out that action.

The CPU needs two things in order to function: the RAM, or 'Random Access Memory', which is where programs are stored once they have been loaded, and the Cache Memory, which is used to store data that is waiting to be processed. The Cache Memory is very fast and is located very close to the CPU in order to reduce the time it takes the data to travel.

The RAM and the Cache are known as Primary Storage, while the Hard Drive and other storage devices such as Flash Memory Drives, are known as secondary storage, and are designed to hold data while the computer is turned off.

An in depth look at the history of a CPU, as well as how it functions: HowStuffWorks: How Microprocessors Work

--------

Binary Logic

AND Gate:

 
'AND' Gates will have an output set to 0, unless both inputs are equal to 1.

OR Gate:
 
'OR' Gates will always output 1 so long as at least 1 input is set to 1.
 
 
NOT Gate:
 
 
'NOT' Gates will always output the opposite of the input.
 
AND/NOT Gate:
'AND/NOT' Gates will always output 1 unless both inputs are equal to 1. This is because the NOT gate reverses the output of the AND gate.
--------

 
Binary is a Base-2 Numeral System made up entirely of 1's and 0's. These two numbers correspond to "On" and "Off" respectively. A document published by John von Neumann in 1945 stated that all data and instructions for a modern computer should be stored in binary. Binary is used to manipulate transistors in the computer, to give instructions to the processor.

--------
Memory

ROM - Read Only Memory - Used to store the firmware that checks for errors upon turning on a computer, then handing control over to the operating system. The ROM can be found on the motherboard.

RAM - Random Access Memory - Allows the access of data in a random order, and stores programs that are currently in use. The most widely used form of RAM today is DRAM, which isn't technically random access, but still stores programs being used.

Cache - Stores data that is about to be used, or has just been used, to allow the CPU  to access it quickly. Is located near the CPU to allow for faster access.

Flash - Flash Memory is a type of storage that is re-writeable, and is useful for transferring data around very quickly. Solid State Drives and USB Drives take advantage of this technology.

--------

RAM, or Random Access Memory, is the primary form of computer memory. Programs that are currently in use are stored in the RAM, including the Operating System. RAM is volatile, and must be constantly powered or the data will be lost. Therefore, it isn't a good way of storing data in the long term, so a hard drive is used instead.



Data is transferred to the RAM from the Secondary Storage, usually a hard drive, and from there it is transferred to the cache memory. The Cache Memory is located near the CPU for quick transfer speeds and stores data that is about to be used, or that has just been used. From here, the data is sent to the CPU, which performs the task the data requires.

--------

Input, Output and Specialist Needs

Input  devices allow the user to control an output device, such as a computer. For example, a mouse allows you to move a cursor on screen, allowing for easy navigation around a computer. An Output device, such as a computer monitor, displays the result of an input device, for example, a computer printer outputs a picture or text that was created on the input device (a computer).



Some users may have specific needs for an input or output device. For example, for a person who has limited movement in their body, the Eye-typer was invented. This allows the user to input data by blinking, and the eye-typer detects the blink and sends that information to the computer. Another, more commonly used specialist input is voice control, which is commonly used in mobile phones, and allows users to speak commands into the phone instead of navigating around a touch screen.

Another example of an input device is a game controller. Valve is attempting to change the way this particular device works with their unusual controller which uses two touch pads instead of the more standard analogue sticks, to give a more "keyboard and mouse" type feel to those playing games on a big screen.




--------

Secondary Storage is used to store data when the computer is turned off. The most common form of secondary storage is a hard drive, or more specifically, a magnetic hard drive. These are commonly used as they are cheap, reliable, it has a high capacity of storage, and are easy to manufacture in large amounts. A standard magnetic drive can cost as little as £0.027 per GB.



Recently, flash memory is beginning to become a more common form of large capacity secondary storage. Solid State Drives (SSDs) can be bought for as little as £0.33 per GB and have a much faster read/write speed than a magnetic drive. They also have no moving parts, so are far more reliable and less likely to break and corrupt your data. Unfortunately, the price still isn't low enough for them to fully replace magnetic drives, but eventually the price might go low enough that this will be possible.



Optical Discs such as a CD, DVD or Blu-Ray are still in common use today. Dual-Layer Blu-Ray discs can hold up to 50GB, and are constantly getting cheaper which allows them to still be used, even though some people think discs are a dated technology.

Thursday, 5 September 2013

What is a Computer System?

A system is a collection of parts that work together for a common purpose.  A computer system works on processing data and producing information. Computers require software, such as an OS (Operating System), in order to be of any use. 

Examples of Computer Systems:
  • Networks
  • Game consoles
  • Mobile phones
  • TV remote
  • Digital watch
  • Electronic Instruments
Washing Machines before using a Computer System:

Washing clothes was originally done by hand, in either a tub or bucket of water, or in a lake or river. Eventually, manually powered machines were made for washing clothes, such as a wringer, which let you squeeze water out of clothes without having to do it yourself. Electric Washing Machines were first advertised in 1904, and were controlled by a separate engine, or an electromechanical timer.

An example of Input, Process, and Output with a Washing Machine:

Input: Setting the timer, speed, temperature, etc - Process: Motors to spin the washing, timer counts down - Output: Clean clothes :)

An example of Input, Process, Output with a computer keyboard:

Input: Key is pressed down - Process: Key press is registered with the computer, does some magical processing trickery - Output: The letter/key is displayed on screen.

--------

Reliability is making sure that the system won't break during use. Due to several factors, computer system failures can be catastrophic, and are often the main cause of plain crashes. If a bank has a broken IT system, then peoples credit car details could be at risk.

--------

An Embedded System  is a system programmed to have many different functions. For example, the system that controls a washing machine, or a car engine. Cars use many of these systems to ensure safety and make driving a more pleasurable experience.

--------

Why is Reliability Important?

Computer systems need reliability to avoid accidents. For example, if a computer in a hospital were to fail due to a power cut, peoples lives could be lost. To avoid this, these systems have a way of keeping power temporarily in the few seconds it takes the hospitals generators to turn on.

On airplanes, reliability has been the cause of many crashes. On a flight in the Mulhouse-Habsheim Air Show, the pilot insisted that the altimeter read 100 feet above the runway, when it actually was 30. This lead to the death of three people. Computer Systems of this importance need a lot more testing and backup systems before use.

--------

Regulations

There are a number of regulations in place to ensure data is both secure, and correct. If data is lost or stolen, then people can obtain valuable information such as credit card information, passwords, and even information about a persons identity which can be used to impersonate and steal from them. 

The Computer Misuse Act became law in 1990, and makes it illegal to gain unauthorised access to computer material; unauthorised access with the intent of committing a crime; unauthorised modification of data and computer material, and making, supplying or obtaining anything that could be used in computer misuse offences.

The Copyright, Designs and Patents Act makes it illegal to copy software, images, video and a variety of other media.

--------

The Kernel is the central part of the Operating System  and remains loaded in memory while the computer is on. The Kernel is responsible for memory, disk and hardware management, as well as communicating between hardware and software. An example of a popular Kernel is the Linux Kernel, which is used in many Operating Systems, the most popular of which is Ubuntu.