Professional Documents
Culture Documents
Microprocessor and Assembly Language: Shahan Siddiqui
Microprocessor and Assembly Language: Shahan Siddiqui
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
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
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
Magnitude 5 1 2 7 4
Sum of Digit x Weight 2 1 0 -1 -2
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
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4 )16
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:
NOT
AND
Truth if both are true
Truth table for Boolean AND operator:
AND
OR
True if either is true
Truth table for Boolean OR operator:
OR
Operator precedence
NOT > AND > OR
Examples showing the order of operations:
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
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