Hexadecimal Learning objectives • use binary in computer registers for a given application such as in robotics, digital instruments and counting systems • represent numbers stored in registers and main memory as hexadecimal • identify current uses of hexadecimal numbers in computing, such as defining colours in Hypertext Markup Language (HTML), Media Access Control (MAC) addresses, assembly languages and machine code, debugging Registers - in computer registers such as robotics A register is a small piece of memory built into the CPU of a computer system where values and instructions are temporarily held. They are not part of primary memory or secondary storage. Although they are small in capacity, registers have an extremely fast read and write rate, meaning data can be written to and read from a register much quicker than from primary memory or secondary storage. Therefore computer systems use registers to hold values and instructions for processing, to increase the speed at which they can be processed. If these values and instructions were processed straight from primary memory, processing would be much slower. Processor registers - in computer registers such as robotics There are different types of register, such as processor registers and hardware registers. Processor registers, for example the program counter (PC), the accumulator and the memory address register (MAR), are used to process data. These registers are part of the CPU and can be written to and read from extremely quickly. The fast speed of access makes registers very suitable for situations where small amounts of data need to be accessed quickly, such as performing calculations. Hardware registers - in computer registers such as robotics Hardware registers are specific to different types of hardware and are used to convey a signal. Consider a robot arm that has various motors to perform different operations, for example, raise the arm, open the grip and close the grip. Each motor works via a signal, 1 for on, 0 for off. A register is used for each motor to convey the signal. Use of binary task - in computer registers such as robotics A computer register is group of bits. When computers or microprocessors are used to control devices such as robots, registers are used as part of the control system. The example describes how registers can be used in controlling a simple device. A robot vacuum cleaner has three wheels A,B and C. A rotates on a spindle to allow for directional changes as well as forward and backwards. B and C are fixed to provide only forward or backward movement and have a electric motor attached. Use of binary - in computer registers An 8 bit register is used to control the movement of the robot vacuum cleaner:
If the register contains 1 0 1 0 1 0 1 0 this means:
• motor B is ON • motor C is ON • and both motors are turning to produce FORWARDS motion • Effectively the vacuum cleaner is moving forwards Hexadecimal number - identify current uses of hexadecimal system numbers Hexadecimal is another number system that is used. Computers do not actually process hexadecimal, they convert it into binary before processing it. Programmers work with hexadecimal as it is easier for humans to read than binary. This is because it is a much shorter way of representing a byte of data, as reading and understanding lots of binary 1s and 0s can be difficult. In the same way, programs that are written in hexadecimal are easier to debug than those written in binary. Computers convert hexadecimal data into binary before processing it. Hexadecimal number - identify current uses of hexadecimal system numbers Identify current uses of hexadecimal numbers in computing by producing a one page report on one of the topics below: • Defining colours in Hypertext Markup Language (HTML) • Media Access Control (MAC) addresses • Assembly languages and machine code • Debugging
Write a report explaining the current uses of hexadecimal number
systems from the list above HTML - identify current uses of hexadecimal numbers HTML is used as a notation for colour in HTML. Hex colour notations are normally six digits and each hex notation represents a different colour, for example #FFAA33 is orange and #000000 is black. In the hex code #FFAA33 the first two digits are the red component, the second two the green component and the last two the blue component. All three together create the colour orange.
When representing colours the values
change to represent different colours, using the three primary colours: Red, Green and Blue known as: RGB MAC addresses - identify current uses of hexadecimal numbers Media Access Control (MAC) addresses are 12-digit hexadecimal numbers that uniquely identify each different device in a network. This address is assigned by the device's manufacturer and can not be changed. MAC addresses are 12-digit (48-bit) hexadecimal numbers. They are usually written in one of the following formats: MM:MM:MM:SS:SS:SS MM-MM-MM-SS-SS-SS where the 6 digits are the identity number of the manufacturer of the device and the second half is the id number for the specific device.
Remember that each hexadecimal number is 4 bits
equivalent, so 4 x 12 = 48 bits. Assembly and machine - identify current uses of hexadecimal code numbers Computer memory can be referred to directly using machine code or assembly code. This can have many advantages to program developers or when carrying out troubleshooting. Machine code and assembly are low- level languages that directly access the memory chips in the computer. Using hexadecimal makes it much easier, faster and less error prone to write code compared to binary. Using true machine code (which uses binary) is very cumbersome and it takes a long time to key in the values. It is also very easy to mistype the digits in a ‘sea of 1s and 0s’. Here is a simple example: • STO FFA4 (assembly code) • A5E4 FFA4 (machine code using hexadecimal values) • 1010 0101 1110 0100 1111 1111 1010 0100 (machine code using binary) Memory dumps and - identify current uses of hexadecimal Debugging numbers Hexadecimal is often used when developing new software or when trying to trace errors in programs. The contents of part of the computer memory can hold the key to help solve many problems. When the memory contents are output to a printer or monitor, this is known as a MEMORY DUMP. A program developer can look at each of the hexadecimal codes and determine where the error lies. The value on the far left shows the memory location so that it is possible to find out exactly where in memory the fault occurs. This is more manageable using hexadecimal rather than using binary. Review and revise • use binary in computer registers for a given application such as in robotics, digital instruments and counting systems • represent numbers stored in registers and main memory as hexadecimal • identify current uses of hexadecimal numbers in computing, such as defining colours in Hypertext Markup Language (HTML), Media Access Control (MAC) addresses, assembly languages and machine code, debugging