Navi

Latest Posts

Number base convertion ( Tutorial )


Decimal To binary
Question 1: Convert 112 from decimal to binary.

112 = 64 + 32 + 16 = 1×26 + 1×25 + 1×24 + 0×23 + 0×22 + 0×21 + 0×20 = 11100002

Question 2: Convert 25673 from decimal to binary.


25673 = 16384 + 8192 + 1024 + 64 + 8 + 1 = 1×214 + 1×213 + 0×212 + 0×211 + 1×210 + 0×29 + 0×28 + 0×27 + 1×26 + 0×25 + 0×24 + 1×23 + 0×22 + 0×21 + 1×20 = 1100100010010012

Question 3: Convert 555 from decimal to binary.

555 = 512 + 32 + 8 + 2 + 1 = 1×29 + 0×28 + 0×27 + 0×26 + 1×25 + 0×24 + 1×23 + 0×22 + 1×21 + 1×20 = 10001010112

Question 4: Convert 100 from decimal to binary.

100 = 64 + 32 + 4 = 1×26 + 1×25 + 0×24 + 0×23 + 1×22 + 0×21 + 0×20 = 11001002

Question 5: Convert 12999 from decimal to binary.

12999 = 8192 + 1024 + 64 + 8 + 1 = 1×213 + 1×212 + 0×211 + 0×210 + 1×29 + 0×28 + 1×27 + 1×26 + 0×25 + 0×24 + 0×23 + 1×22 + 1×21 + 1×20 = 110010110001112


Decimal To Octal 

Question 1: Convert 128 to octal form.

Solution:
Given decimal number is 128
Start the division process
8 | 128
8 | 16 -- 0
8 | 2 -- 0
8 | 0 --2

Correct answer is The equivalent octal number for 128 is 2008

Question 2: Convert 58 to octal form
Solution:
Given decimal number is 58
Start the division process
8 | 58
8 | 7 -- 2
8 | 0 --7

Correct answer is the equivalent octal number for 58 is 728

Question 3: Convert 451 to octal form

Solution:
Given decimal number is 451
Start the division process
8 | 451
8 | 56 -- 3
8 | 7 -- 0
8 | 0 -- 7

Correct answer is the equivalent octal number for 128 is 7038

Question 4: Convert 4 to octal form?

Solution:
Given decimal number is 4
Since 4 is less than 7

Correct answer is the equivalent octal number for 4 is 48

Question 5: Convert 287 to octal form.

Solution:
Given decimal number is 287
Start the division process
8 | 287
8 | 35 -- 7
8 | 4 -- 3
8 | 0 --4

Correct answer is the equivalent octal number for 287 is 4378


Decimal To Hexadecimal

Question 1: Convert 56 from decimal to hexadecimal.

5610 = 1×25 + 1×24 + 1×23 + 0×22 + 0×21 + 0×20 = 1110002 = 0011 10002 = 38H

Question 2: Convert 273 from decimal to hexadecimal.

27310 = 1×28 + 0×27 + 0×26 + 0×25 + 1×24 + 0×23 + 0×22 + 0×21 + 1×20 = 1000100012 = 0001 0001 00012 = 111H

Question 3: Convert 105 from decimal to hexadecimal.

10510 = 1×26 + 1×25 + 0×24 + 1×23 + 0×22 + 0×21 + 1×20 = 11010012 = 0110 10012 = 69H

Question 4: Convert 158 from decimal to hexadecimal.

15810 = 1×27 + 0×26 + 0×25 + 1×24 + 1×23 + 1×22 + 1×21 + 0×20 = 100111102 = 1001 11102 = 9EH

Question 5: Convert 171 from decimal to hexadecimal.

17110 = 1×27 + 0×26 + 1×25 + 0×24 + 1×23 + 0×22 + 1×21 + 1×20 = 101010112 = 1010 10112 = ABH



Binary To  Decimal

Convert the following binary numbers to decimal:
a) 101110
b) 1110101

Solution:
Binary numbers: base (radix) = 2
a) 1*25 + 0*2 + 1*23 + 1*2 + 1*2 + 0*20 = 32 + 0 + 8 + 4 + 2 + 0 = 46
b) 1*26+1*25+1*24+0*23+1*22+0*21+1*2= 64 + 32 + 16 + 0 + 4 + 0 + 1 = 117




Convert the binary numbers into decimal numbers
1. 11
2. 101
3. 1111
4. 110111011
5. 1111100011110011

Solution:
1. 11 = 1*21 + 1*20 = 2 + 1 = 3
2. 101 = 1*22 + 0*21 + 1*20 = 4 + 1 = 5
3. 1111 = 1*23 + 1*22 + 1*21 + 1*20 = 8 + 4 + 2 + 1 = 15
4. 110111011 = 1*28 + 1*27 + 0*26 + 1*25 + 1*24 + 1*23 + 0*22 + 1*21 + 1*20 = 256 + 128 + 32 + 16 + 8 + 2 + 1 = 443
5. 1111100011110011 = 1*215 + 1*214 + 1*213 + 1*212 + 1*211 + 0*210 + 0*29 + 0*28 + 1*27 + 1*26 + 1*25 + 1*24 + 0*23 + 0*22 + 1*21 + 1*20
= 32768 + 16384 + 8192 + 4096 + 2048 + 128 + 64 + 32 + 16 + 2 + 1 = 63731




Binary to Octal



Convert the binary number 10101012 to octal

Solution:
Given binary number is 10101012
First we convert given binary to decimal

10101012 = (1 * 26) + (0 * 25 ) + (1 * 24) + (0 * 23) + (1 * 22) + (0 * 21) + (1 * 20)
= 64 + 0 + 16 + 0 + 4 + 0 + 1
= 64 + 21
= 85  (Decimal form)

Now we will convert this decimal to octal form
8 | 85
-------
8 | 10 -- 5
-------
8 | 1 -- 2
-------
8 | 0 --1

Correct answer is equivalent octal form is 1258



Binary to Hexadecimal

Question 1: Convert 10010001 from unsigned binary to hexadecimal.

10012 = 910 and 00012 = 110.
100100012 = 9110

Question 2: Convert 101010 from unsigned binary to hexadecimal.

102 = 210 and 10102 = A10.
1010102 = 2A10

Question 3: Convert 100110101 from unsigned binary to hexadecimal.

12 = 110, 00112 = 310 and 01012 = 510.
1001101012 = 13510

Question 4: Convert 1010101001 from unsigned binary to hexadecimal.

102 = 210, 10102 = A10 and 10012 = 910.
10101010012 = 2A910

Question 5: Convert 1100111 from unsigned binary to hexadecimal.

1102 = 610 and 01112 = 710.
11001112 = 6710


Octal To Binary

Question 1: Convert 418 to a binary number.

Solution:

Given number is 418
418 = (4 * 81) + (1 * 80)
= 4 * 8 + 1 * 1
= 32+1
= 33(Decimal number)

Now convert this decimal number to a binary number.

2 | 33
2 | 16 -- 1
2 | 8  -- 0
2 | 4  --0
2 | 2  -- 0
      1 -- 0

The binary number is 1000012

Question 2: Convert 278 to a binary number.

Solution:

Given number is 278
278 = (2 * 81) + (7 * 80)
= 2 * 8 + 7 * 1
= 16 + 7
= 23(Decimal number)

Now convert this decimal number to a binary number.

2 | 23
2 | 11 -- 1
2 | 5   -- 1
2 | 2   --1
2 | 1   -- 0
2 | 0   -- 1

The binary number is 101112

Question 3: Convert 108 to a binary number.
Solution:

Given number is 108
108 = (1 * 81) + (0 * 80)
= 1 * 8 + 0 * 1
= 8 + 0
= 8(Decimal number)

Now convert this decimal number to a binary number.

2 | 8 -- 0
2 | 4 --0
2 | 2 -- 0
     1

The binary number is 10002



Octal To Decimal


Question 1: Convert 57468 to decimal number

Solution:
The given number is 57468

57468 = (5 * 8^3)+ (7 * 8^2) + (4 * 8^1) + (6 * 8^0)
=5 * 512 + 7 * 64 + 4 * 8 + 6 * 1
= 2560+448+32+6
= 3046

The equivalent decimal number for 57468 is 3046

Question 2: Convert 2018 to decimal number

Solution:
The given number is 2018

2018 = (2 * 8^2) + (0 * 8^1) + (1 * 8^0)
= 2 * 64 + 0 * 8 + 1 * 1
= 128+0+1
= 129

The equivalent decimal number for 2018 is 129


Question 3: Convert 548 to decimal number

Solution:

The given number is 548
548 = (5 * 8^1) + (4 * 8^0)
=5 * 8 + 4 * 1
= 40 + 4
= 44

The equivalent decimal number for 548 is 44



Question 4: Convert 108 to decimal number

Solution:
The given number is 108

108 = (1 * 8^1) + (0 * 8^0)
= 1 * 8 + 0 * 1
= 8+0
= 8

The equivalent decimal number for 108 is 8



Octal To Hexadecimal

Question 1: Convert 10028 to hexadecimal

Solution:
The given number is 10028

10028 = (1 * 83)+ (0 * 82) + (0 * 81) + (2 * 80)
=1 * 512 + 0 * 64 + 0 * 8 + 2 * 1
= 512 + 0 + 0+ 2
= 514(decimal number)

Now we convert the above decimal to hexadecimal

16 | 514
16 | 32   --2
        2 -- 0

The hexadecimal number is 202

Question 2: Convert 1008 to hexadecimal

Solution:
The given number is 1008

10028 = (1 * 82) + (0 * 81) + (0 * 80)
= 1 * 64 + 0 * 8 + 0 * 1
= 64 + 0 + 0
= 64(decimal number)

Now we convert the above decimal to hexadecimal

16 | 64
16 | 4   --0
16 | 0   -- 4

The hexadecimal number is 40

Question 3: Convert 158 to hexadecimal

Solution:
The given number is 158

158 =(1 * 81) + (5 * 80)
= 1 * 8 + 5 * 1
= 8 + 5
= 13(decimal number)

Now we convert the above decimal to hexadecimal
13 is less than 16 so the equivalent hexadecimal number is D
The hexadecimal number is D

158 = D16


Hexadecimal To Decimal

Question 1: Convert 35 from hexadecimal to decimal.

3×16 + 5 = 53.

Question 2: Convert 1AA from hexadecimal to decimal.

1×16^2 + 10×16 + 10 = 426.

Question 3: Convert 12 from hexadecimal to decimal.

1×16 + 2 = 18.

Question 4: Convert 4B from hexadecimal to decimal.

4×16 + B = 75.

Question 5: Convert 89 from hexadecimal to decimal.

8×16 + 9 = 137.


Hexadecimal To Octal



Example: Convert the Hexadecimal (B 5 A)16 to its octal equivalent
Hex to Octal Conversion

The equivalent octal number is (5 5 3 2)8



Octal To Hexadecimal

Example: Convert octal number (7 5 2)8 to its equivalent hex number
Octal to Hex Conversion

The hex number equivalent is (1 D 9)8



Conversion Table
Decimal
Binary
Octal
Hexadecimal
0
0000
0
0
1
0001
1
1
2
0010
2
2
3
0011
3
3
4
0100
4
4
5
0101
5
5
6
0110
6
6
7
0111
7
7
8
1000
10
8
9
1001
11
9
10
1010
12
A
11
1011
13
B
12
1100
14
C
13
1101
15
D
14
1110
16
E
15
1111
17
F















































Chapter 7 (Calculation part)

Equal stages have non-pipelining and pipelining.



n=number of instruction
k=stage
t=delay/cycle time


Total time of 

Non pipelining


formula of Non-pipelining(To)=n*k*t


Pipelining

formula of pipelining(Tk)=(k+(n-1))*t




Speedup
=To/Tk



Throughput of

Non-pipelining=n/(To)
Pipelining=n/(Tk)



Example:
Calculate what is the total processing time, throughput and speedup of 100 instructions that have a 4 equal stages of delays(cycle time) of 2s each if the instructions are
Pipelined
Non-pipelined

In this question,n(instruction of number)=100
k(stage)=4
t(cycle/delay time)=2sec


In
Total time of
Pipelined=(Tk)

=(Tk)=(k+(n-1))*t
=(4+(100-1))*t
=103*2s
=206s

Non-pipelined=(To)
=(n*k*t)
=(100*4*2s)
=800s

Speedup=(To/Tk)
=800/206
=3.883(after rounding)

Throughput of
pipelining=n/(Tk)
=100/206s
=0.485 ins/sec (instruction/second)

non-pipelining=n/(To)
=100/800s
=0.125ins/sec (instruction/second)

Unequal stage have non-pipelining and pipelining.
n=number of instruction
k=stage
t=cycle/delay time


Given FOUR instructions where each instruction has SIX stages (FI, DI, EI,
FO, ME and WO) with delays of 3, 2, 4, 2, 3 and 2. Calculate the speedup and throughput for
pipeline and non-pipeline.

n(number of instruction)=4
k(stage)=6

Total-time of
non-pipelining(To)=n*
=4*(4+4+4+4+4+2) *(take the maximum of time and the last one take the original of the time)
(why we take 4 five times and 2 one times?because the stage is 6,only the last stage use original time and other use maximum)

=4*22
=88s

Pipelining=

=(4+4+4+4+4+2)+(4-1)*4
=22+(3*4)
=22+12
=34s

Speedup
=To/Tk
=88/34
=2.588times

Throughput
Non-pipelining
=n/To
=4/88s
=0.045ins
Pipelining
=n/Tk
=4/34
=0.118ins

Number Bases

  • Binary [Base 2]
  • Octal [Base 8]
  • Decimal [Base 10]
  • Hexadecimal [Base 16]

The Decimal Number System
The Base 10 number system uses the digits : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

The Decimal Number System (denary representation) uses base 10. It includes the digits from 0 through 9. The weighted values for each position is as follows:




Therefore Radix = 10
Decimal value of the number depending on the position of each digit in the sequence:
Sequence: dn-1, .... d2, d1, d0
Value: dn-1-rn-1 + .... d2.r2 + + d0.r0 d1.r1
Examples of Decimal Numbers:
4785 = 4 x 103 + 7 x 102 + 8 x 101 + 5 x 100
         = 4 x 1000 + 7 x 100 + 8 x 10 + 5 x 1 
         = 4000 + 700 + 80 + 5.

Decimal number
Reduce power by 1 each time moving to the right point radix. Examples of Decimal Numbers
0543 = 0 x 100 + 5 x 10-1 + 4 x 10-2 + 3 x 10-3
          = 0 x 1/1 + 5 x 1/10 + 4 x 1/100 + 3 x 1/1000 = 0 + 5 x 0.1 + 4 x 0:01 + 3 x 0,001 
          = 0 + 0.5 +0.04 + 0,003.


The Binary Number System

1. In the computer, the data is encoded in electrical signals. Binary coding is commonly used for:
2. Computer or electronic device circuit can mewakilikan two conditions state (bistable device).
3. Binary coding in accordance with Boolean algebra.


Problem with Binaries number
1. Difficult to read or easy to make mistakes.
2. Binaries elusive man.
3. Example: When henyak state memory address.

  • To specify the address of a variable. If there is a 64KB memory area.
  • Therefore, there are 64 x 1024 memory cell (location)
  • 65,536 locations with addresses from 0 to 65.535.
  • If the binary, from = 0 to 00000000 00000000 11111111 11111111 = 65,535.

4.    This makes it difficult for programmers who want to specify the address of a variable.

Solution:

1. Use decimal numbers.
2. Use a bit more space.
3. Readable.
4. Programming but sometimes want to know certain bits in a 'bit location'.
5. example:

  • Do MSD for 289 510 is on OR off?.
  • What is 4 Left-Most bit to 289 510
  • To know, we have to change the whole number of decimal to binary. Difficult!


6.   Use the number system "to describe a group of digits bits".

  • Example: 3-bit or 4-bit.



       Although 910 = 10012, the number 9 is not necessarily represented by 1001 only the    
       computer, this might be represented by a number (still a combination of 0 & 1) are    
       longer. To get: -


  • Pleasure manipulate numbers. If the numbers are marked, all arithmetic operations can be produced by mixing only.
  • Density and efficiency. A little bit more, more compact, shorter circuit, faster.
  • Accuracy. many bits, to be exact.
  • Compromise with density. Therefore, the need to use different formats for different data types.
  • Data communication standard. data should be compatible with various devices that carry it.



The Octal Number System

1. Alphabet consisting of octal numbers 0, 1, 2, 3, 4, 5, 6, 7
2. Therefore, Radix = 8
3. Each octal digits can be represented by 3 bits
4. Converting a binary number to octal
5. Collect in compilation 3 bits (beginning with radix point)
6. Example: 11001001110111102

001
100
100
111
011
110
1
4
4
7
3
6

by the 11001001110111102 = 1447368 Is the MSB of 21 578? 28 = 25 178 0102 by the MSB is 0 What is 4 Left-Most bit of 25 178? 18 = 0012 and 78 = 1112 So, the Left-Most Bit 4 is 25 178 1111.


 The Hexadecimal number system

Ø  Alphabet consisting of hexadecimal numbers 0, 1, 2, 3, 4, 5, 6, 7.8, 9, A, B, C, D, E, F
Ø  Therefore, Radix = 16
Ø  Each digit HEX can be represented by 4 bits
Ø  Converting binary to Hex.
Ø  Collect in assembly 4 bits (start from point radix)
Ø  Example: 11001001110111102


1100
1001
1101
1110
C
9
D
E

Ø  Therefore, 11001001110111102 = C9DE16
Ø  Hex numbers in accordance with memory storage unit.
Ø  A cell = 1 byte = 2 groups of 4 bits (nibble) = 2 digit Hex
Ø  Therefore, the address for the memory size of 256 bytes can be represented from     00 to FF.



Introduction to Data Representation


Arithmetic Logic Unit
  • everything else in the computer is there to serviice this unit
  • Handles Integers.
  • Does the calculations.
  • may handle floaing point numbers.

 Data Types 
  • epresented in binary-coded form
  • only have 0&1 to represent everything
  • can be classified to these categories:        

  1. Numbers used in arithmetic computation
  2. Letters of the alphabet used in data processing
  3. Other discrete symbols used for specific purpose                    

Alphanumeric Representation
An alphanumeric character set is a set of elements that includes the 10 decimal digits, the 26 letters of the alphabet and a number of special character such as $, +, and =.

1. The standard alphanumeric binary code : ASCII (American Standard Code for Information          Interchange)
  • uses seven bits to code 128 characters.
  • codes must be in binary because registers can only hold binary information.



2. Another alphanumeric code used in IBM equipment, EBCDIC (Extended BCD Interchange Code) that used 8 bits for each character.
  • BCD (Binary Coded Decimal) represents each individual digit of a decimal number as a group of binary bits; the other formats would convert an entire decimal value to its equivalent binary value. *In the 8421 Binary Coded Decimal (BCD) representation each decimal digit is converted to its 4-bit pure binary equivalent. 



INPUT/OUTPUT TECHNIQUES


There are 3 type of I/O techniques:
i)   Programmed
ii)  Interrupt driven
iii) Direct Memory Access (DMA)


i) Programmed I/O; here, data is exchanged between the processor and the I/O module. The CPU has direct control over the I/O. programmed I/o wastes CPU time.

Programmed I/O detail:
o  CPU requests I/O operation
o  I/O module performs operation
o  I/O module sets status bits
o  CPU checks status bits periodically
o  I/O module does not inform CPU directly
o  I/O module does not interrupt CPU
o  CPU may wait or come back later.

With programmed I/O, lots of CPU time is wasted in polling because processors are faster than I/O devices. This results into CPU inefficient usage. This means that the programmed I/O is suitable for lower performance.



ii) Interrupt Driven I/O;
o  This overcomes CPU waiting
o  There is no repeated CPU checking of devices
o  I/O module interrupts when ready
Interrupt driven I/O basic operation
This is the order in which the interrupt driven i/O carries out its commands step by step.
·       CPU issues read command
·       I/O module gets data from peripherals while CPU does some other work.
·       I/O module interrupts CPU
·       CPU requests data
·       I/O module transfers data
Viewpoint:
v Issue read command
v Do other work
v Check for interrupt at the end of each instruction cycle
v If interrupted




I/O Commands
There are four types of I/O commands that an I/O module may receive when it is addressed by a processor. They include the following;
ü Control. This is used to activate a peripheral and tell it what to do. Instructions like stop, rewind, forward, etc.
ü Test. This is used to try out various conditions associated with an I/O module and its peripherals.
ü Read. This enables the I/O to obtain an item of data from the peripheral and place it in an internal buffer
ü Write. This enables the I/O to take an item of data from the data bus and subsequently transmit that data item to the peripheral

Interrupt I/O is more efficient than programmed I/O because it needs less waiting as compared to programmed I/O. however, interrupt I/O still consumes more processor time because data transfer from memory to I/O module to memory must pass through the processor.
Problems Faced by programmed I/O and Interrupt Driven I/O :
a.   The I/O transfer rate is limited by the speed with which the processor can test and service a device.
b.   The processor is tied up in managing an I/O transfer. A number of instructions must be executed for each I/O transfer.

iii) Direct Memory Access(DMA)
With direct memory access, large amounts of data can be transferred between memory and the peripherals which greatly improves CPU performance.
DMA OPERATIONS.
vCPU tells DMA controller
§  Read/write
§  Device address
§  Starting address of memory block for data
§  Amount of data to be transferred
vCPU carries on with other tasks/work
vDMA controller deals with transfer
vDMA controller sends interrupt when finished



I/O module function and mapping


I/O module function:
Control and Timing; this coordinates the flow of traffic between external devices and internal resources.
CPU Communication; this involves command decoding in I/O module, data exchange through data bus, etc.
Device Communication; involves commands, status information and data.
Data Buffering; the data are buffered in the I/O module and then sent to the peripheral device at its data rate.
Error Detection; this is for reporting errors to the processor.

I/O Module Diagram


Thus, I/O Module takes most of processing burden and becomes a high-level interface to processor also refer to as I/O channel, I/O controller, device controller, etc.



I/O Mapping:
This is when a processor, memory and I/O share a common bus. There are two types of interfacing and they include;
1.   Memory mapped I/O;
o  Devices and memory share an address space
o  I/O looks just like memory read and write
o  No special commands for I/O
2.   Isolated I/O;
o  Separate address spaces
o  Need I/O or memory select lines
o  Needs special commands for I/O

External I/O Devices


External I/O Devices:
There are three categories of external devices;
i) Human readable
o  Suitable to communicate with the computer users
o  Screen, printer, keyboard

ii) Machine readable
o  Suitable to communicate with the equipment
o  Monitoring and control
o  Magnetic disk and tape systems, sensors and actuators

iii) Communication
o  Suitable for communicating with remote devices such as terminal, a machine readable device or another computer
o  Modem
o  Network interface card(NC)


Keyboard/Monitor:
·      These are the most common means of computer/user interaction.
·       The user provides input via the keyboard and the monitor displays the output.
·       The basic unit of exchange is character. Associated with each character is a code, typically 7 or 8 bits in length.
·       Each character in this code is represented by a unique 7-bit binary code.
·       Characters are of two types; printable and control characters. Printable characters are the alphabetic, numeric and special characters that can be printed on the paper or displayed on a screen.
·       Control characters do with the controlling of the printing or displaying of characters.


Figure 7.2

The nature of an external device is indicated in Figure 7.2. The interface to the I/O module is in the form of control, data, and status signals.