You are on page 1of 40

Microprocessor and

Assembly Language
Shahan Siddiqui
Data representation
Computer is a construction of digital circuits
with two states: on and of
You need to have the ability to translate
between different representations to examine
the content of the machine
Common number systems: binary, octal,
decimal and hexadecimal
Binary numbers
Digits are 1 and 0
(a binary digit is called a bit)
1 = true
0 = false
MSB most significant bit
LSB least significant bit

Bit numbering: MSB LSB


1011001010011100
15 0
A bit string could have different interpretations
Decimal Number System
Base (also called radix) = 10
10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
Digit Position
2 1 0 -1 -2
Integer & fraction
Digit Weight 5 1 2 7 4
Weight = (Base) Position
100 10 1 0.1 0.01
Magnitude
Sum of Digit x Weight
Formal Notation 500 10 2 0.7 0.04

d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2

(512.74)10
4 04/11/17
Binary Number System
Base = 2
2 digits { 0, 1 }, called binary digits or bits
Weights
4 2 1 1/2 1/4
Weight = (Base) Position

Magnitude 1 0 1 0 1
Sum of Bit x Weight 2 1 0 -1 -2

Formal Notation 1 *22+0 *21+1 *20+0 *2-1+1 *2-2

Groups of bits 4 bits = Nibble =(5.25)10


8 bits = Byte (101.01)2

5 04/11/17
The Power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo

3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega

6 26=64 30 230=1G Giga

7 27=128 40 240=1T Tera


6 04/11/17
Octal Number System
Base = 8
8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights
64 8 1 1/8 1/64
Weight = (Base) Position

Magnitude 5 1 2 7 4
Sum of Digit x Weight 2 1 0 -1 -2

Formal Notation 5 *82+1 *81+2 *80+7 *8-1+4 *8-2


=(330.9375)10
(512.74)8

7 04/11/17
Hexadecimal Number System
Base = 16
16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
}
Weights
Weight = (Base) Position 1 E 5 7 A
Magnitude 2 1 0 -1 -2
Sum of Digit x Weight1 *162+14 *161+5 *160+7 *16-1+10 *16-2
Formal Notation =(485.4765625)10
(1E5.7A)16

8 04/11/17
Binary Octal Conversion
Octal Binary
8=2 3
0 000
Each group of 3 bits
represents an octal digit 1 001

2 010
Assume Zeros
Example: 3 011

( 1 0 1 1 0 . 0 1 )2 4 100

5 101

6 110
( 2 6 . 2 )8 7 111

Works both ways (Binary to Octal & Octal to Binary)


9 04/11/17
Binary Hexadecimal Conversion
Hex Binary
16 = 24 0 0000
1 0001
Each group of 4 bits 2 0010
represents a hexadecimal 3 0011
4 0100
digit 5 0101
Assume Zeros 6 0110
Example: 7 0111
8 1000
( 1 0 1 1 0 . 0 1 )2 9 1001
A 1010
B 1011
C 1100
D 1101
(1 6 . 4 )16 E 1110
F 1111

Works both ways (Binary to Hex & Hex to Binary)


10 04/11/17
Octal Hexadecimal Conversion
Convert to Binary as an intermediate step
Example:
( 2 6 . 2 )8

Assume Zeros Assume Zeros

( 0 1 0 1 1 0 . 0 1 0 )2

(1 6 . 4 )16

Works both ways (Octal to Hex & Hex to Octal)


11 04/11/17
Decimal, Binary, Octal and Hexadecimal
Decimal Binary Octal Hex
00 0000 00 0
01 0001 01 1
02 0010 02 2
03 0011 03 3
04 0100 04 4
05 0101 05 5
06 0110 06 6
07 0111 07 7
08 1000 10 8
09 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

12 04/11/17
Unsigned binary integers
Each digit (bit) is either 1 or 0
Each bit represents a power of 2:

Every binary
number is a sum
of powers of 2
Integer storage sizes

Standard sizes:

Practice: What is the largest unsigned integer that may be stored


in 20 bits?
Signed integers
The highest bit indicates the sign. 1 = negative,
0 = positive

If the highest digit of a hexadecmal integer is > 7, the value is


negative. Examples: 8A, C5, A2, 9D
Two's complement notation
Steps:
Complement (reverse) each bit
Add 1

Note that 00000001 + 11111111 = 00000000


Character
Character sets
Standard ASCII(0 127)
Extended ASCII (0 255)
ANSI (0 255)
Unicode (0 65,535)
Boolean algebra
Boolean expressions created from:
NOT, AND, OR
NOT
Inverts (reverses) a boolean value
Truth table for Boolean NOT operator:

Digital gate diagram for NOT:

NOT
AND
Truth if both are true
Truth table for Boolean AND operator:

Digital gate diagram for AND:

AND
OR
True if either is true
Truth table for Boolean OR operator:

Digital gate diagram for OR:

OR
Operator precedence
NOT > AND > OR
Examples showing the order of operations:

Use parentheses to avoid ambiguity


Implementation of gates
Truth Tables (1 of 2)
A Boolean function has one or more Boolean
inputs, and returns a single Boolean output.
A truth table shows all the inputs and outputs
of a Boolean function

Example: X Y
Truth Tables (2 of 2)
Example: X Y
Maxterms and Minterms
Examples: Two variable minterms and
maxterms.
Index Minterm Maxterm
0 xy x+y
1 xy x+y
2 xy x+y
3 xy x+y
The index above is important for
describing which variables in the terms
are true and which are complemented.
Chapter 2 - Part 1
26
Minterm and Maxterm
Relationship
Review: DeMorgan's Theorem
and
xy x y x y x y
Two-variable example:
and
M2 x y m 2 xy
Thus M2 is the complement of m2 and vice-
versa.
Since DeMorgan's Theorem holds for n
variables, the above holds for terms of n
variablesM m
giving:
i i m M
i i

and
Thus Mi is the complement of mi.
Minterm and Maxterm
F1 = m 1 + m 4 + m 7
Minterm Function Example
F1 = m 1 + m 4 + m 7
F1 = x y z + x y z + x y z
F1 = M0.M2.M3.M5.M6
x y z index m1 + m4 + m7 = F1
000 0 0 + 0 + 0 =0
001 1 1 + 0 + 0 =1
010 2 0 + 0 + 0 =0
011 3 0 + 0 + 0 =0
100 4 0 + 1 + 0 =1
101 5 0 + 0 + 0 =0
110 6 0 + 0 + 0 =0
111 7 0 + 0 + 1 =1
Kmap Simplification
K-Maps can be used to simplify Boolean functions by
systematic methods. Terms are selected to cover the
1sin the map.
Example: Simplify F(x, y, z) m(1,2,3,5,7)

z
F(x, y, z)
Chapter 2 - Part 1 30
Kmap Simplification
K-Maps can be used to simplify Boolean functions by
systematic methods. Terms are selected to cover the
1sin the map.
Example: Simplify F(x, y, z) m(1,2,3,5,7)
z xy
y
1 1 1
x 1 1

z
F(x, y, z) z xy
Chapter 2 - Part 1 31
Simplification with Dont Care
Conditions
F(A,B, C, D) m (1,3,7,11,15)
=
d(A,B,C,D) =
m (0,2,5)

32
Design Procedure
1. From the specification of the circuit, determine
the required number of inputs and outputs, and
assign a letter symbol to each

2. Derive the truth table that defines the


relationship b/w inputs and outputs

3. Obtain simplified Boolean function for each


output

4. Draw Logic diagram

5. Verify the correctness of the design


Chapter 3 - Part 1
Design a Combinational Circuit -
Example
Design a combinational circuit with three
inputs and one output. The output must be
logic 1 when the binary value of the inputs is
less than 011(3) and logic 0 other wise. Use
only NAND gates

Chapter 3 - Part 1
Binary Adders
Addition of 3 binary inputs, 'Full Adder'

Logic Diagram of
Full Adder

04/11/17
Overflow
When adding 2 n-bit numbers it is possilbe to
get a n+1 bit result if there is a carry out.
On paper it is easy just add another bit.
In 2s complement add a msb 0 for a positive
or a msb 1 for a negative.
In a computer the number of bits that can be
used is fixed.

04/11/17
Overflow indication.
In 8-bit 2s complement notation the range
that can be represented is -127 to +127.
Then the operation to add +70 to +80 is
Carries 0 1
+70 0 100 0110
+80 0 101 0000
+150 1 001 0110
Also look at the addition of -70 and -80

04/11/17
The other addition
The addition of -70 and -80
Carries 1 0
-70 1 011 1010
-80 1 011 0000
-150 0 110 1010
The rule if the carry into the msb position
differs from the carry out from the msb
position then an overflow has occurred.
The circuit

.
04/11/17
2 to 4 line decoder
In In D3 D2 D1 D0
0 1
0 0 0 0 0 1
D3
0 1 0 0 1 0

1 0 0 1 0 0 D2
1 1 1 0 0 0

D1
D0
Multiplexers
selects binary information from one of many input lines,
and directs it to a single output line
Normally, 2n input lines and n selection variables
4-to-1-line multiplexer

called data selector or MUX


2n-to-1-line multiplexer is constructed from n-to-2n
decoder by adding 2n input lines

You might also like