Вы находитесь на странице: 1из 121

1.

1.1
, ()
.
( 2.743-82),
, , "H" - ,
" 1", ,"L - " " 0". .
. 19480 - 89 ,
.
- ,
. ,
, 4 . "" (AND)
, * /\. "" (OR),
, + \/. "" (NOT),
, , .
" ~ ". "=".
.
(1)

0+0=0

1*1=1

(1')

(2)

1+1=1

0*0=0

(2')

(3)

1+0=0+1=1

0*1=1*0=0

(3')

(4)

~1 = 0

~0 = 1

(4')

(1, 2) (1',2') : x + x = x x * x = x.

(5)

(1, 3) (2',3') : x + 0 = x 0 * x = 0.

(6)

(2, 3) (1',3') : 1 + x = 1 x * 1 = x.

(7)

(3) (3') : x +~x = 1 ~x * x = 0.

(8)

(4) (4') : ~(~x) = x.

(9)

, , (1,1'), (2,2'), (3,3') (4,4') :


~( x0+x1) = ~x0 * ~x1 ~(x0 * x1) = ~x0 + ~x1 .

(10)

(10)
( ).
n , :
~(x1 + .. + xn) = ~x1 * . .* ~xn
~(x1 * .. * xn) = ~x1 + .. + ~xn

(11)

. - ,
, : x1 op x0 =
x0 op x1 - , x2 op x1 op x0 = (x2 op x1) op x0 - x2*(x1+x0) =

(x2*x1) + (x2*x0) x2 + (x1*x0) = (x2+x1) * (x2+x0) - , op


, , . ,
, .

1.2
n - () 2n .
0 1.
, - .
() n N=22n. n=2, N=16. n=3, N=256
. 16 2- , ..
. 1
n=2. i- x1 x0.

. "" ,
. "" , .
" " (XOR) ,
.

1.3

, ,
- ( ).
, , .
=2,3,4,8.
. , ,
, : x0 * x1 * x2 * x3 * x4 =
(x0*x1) * (x2*x3*x4) = (x0*x1) * x2 * x3 * x4, ..
, , -
(.1).

, "1",
, (5) (7).

1.4
()
. : 1)
, 2) , 3) , 4) , 5)
(, VHDL) 6) . , Y
x1 x0, : Y=1, Y=0, x1=x0.
.
Y ( 2).


.
(12), .
(12) (). mi i- ,
, 1, ,
0. fi - i - . (12)
, f(..) n-
xi : f(x(n-1),...,xi,. ..,x0) = ~xi*f(x(n-1),...,0,..,x0) + xi*f(x(n-1),..,1,..,x0).
xi=0 ~0*f(x(n-1),...,0,..,x0) + 0*f(x(n-1),..,1,..,x0) = f(x(n-1),...,0,..,x0). xi=1
~1*f(x(n-1),..,1,..,x0) + 1*f(x(n-1),..,1,..,x0) = f(x(n-1),...,1,..,x0), .. xi
. n
.
F=f(x1,x0) .
x1 : F= ~x1*f(0,x0) + x1*f(1,x0) . x0,
:
F =~x1*(~x0*(f(0,0) + x0*(f(0,1)) + x1*(~x0*(f(1,0) + x0*(f(1,1)) = ~x1*~x0*f(0,0) + ~x1*x0*f(0,1) +
x1*~x0*f(1,0) + x1*x0*f(1,1).

(12.1)

(12.1) ,
.
F7-"" F1-"",
1. x1
x0 (00,01,10,11) 0,0,0,1. (12.1)
: F1(x1,x0 ) = ~x1*~x0*0 + ~x1*x0*0 + x1*~x0*0 + x1*x0*1 = x1*x0,
. , F7-"",
, , : 0,1,1,1. ,
(12.1), F7(x1,x0) = ~x1*~x0*0 + ~x1*x0*1 + x1*~x0*1 + x1*x0*1.
x1, F7 = ~x1*x0*1 + x1*(~x0*1 + x0*1).
(8), "1" F7 = ~x1*x0*1 + x1. ,
(~x1+x1) * (x0+x1) = x1+x0.
2, Y = 0*~x1*~x0 + 1*~x1*x0 + 1*x1*~x0 + 0*x1*x0 = ~x1*x0 + x1*~x0
= x1 (+) x0 = F6 ( ).

(12) , ,
: "", "", "", .
1.5
,
(). , , , ..
, F8( -) F14( - ).

, " - " . , , " " , .

1.6
() , , , -
.
1.6.1
- .

VT1 VT2 , x0*x1=1,


, , ~(x0*x1)=0 . VT2
y=0. x0 x1
, - , ..
-. , ,
n-1 "1", n- "0", n-1 VT1
"" (sink) VT2 n- .
VT2 .
1.7
- () (..2. )
.

, ,
..
, " " (.2 - )
.. y=y0*y1=1 y0=y1=1. " ",
y = ~(x0*x1) * ~(x2*x3) ~(x0*x1 + x2*x3)
(.2). , , .

1.8 " - - "


, -
(.3). a,b,..e , -,
C E ( ).
&1 , (.4). *
.

, , .. 0.
, , 0.
Y 0. , ()
, .. 1 (
).

1.9
,
.
""
.
. , " ", ,

, . Z . - Z- .5. ,
- .

~OE=0, VT3
. VT1 VT2
, x0*x1=1, , .
VT2 y=0. x0 x1
, - , .. ~OE=0
-. ~OE=1. VT3
VT1 VT2
, . "y" .
Z.
,
. , ,
,
. Z -
, .


. (Output Enable (~OE)), ,
, 1, , 0, ,
.

1.10
(12) ( ) ,
.
.
. xi. Y
1, 1 .
. :

(12): Y = ~x2*x1*x0 + x2*~x1*x0 + x2*x1*~x0 + x2*x1*x0. (3,5,6,7 -


). .6.

4 "" 1 "".
- ,
.

1.11
() .
() :

: 1)
. 2) .
,
( ,
). 3) .
4) () 2^i . 5)
,
. 6) ,
1, . 7)
.
3 - A,B,C, Ya = x2*x0 (x1
, ). Yb = x1*x0 Y = x2*x1.
Y = Ya + Yb + Yc = x2*x0 + x1*x0 + x2*x1.

(13)

(.7.) , .6.

1.12 "-" "--"


(13) (9) :
Y =~(~( x2*x0 + x1*x0 + x2*x1))

(14)

(14) (.8,) --.

(14) (11) ~( ~(x2*x0) * ~(x1*x0) *


~(x2*x1)) . - (.8, ).

1.13
(.9).
.

L H,
( , ), -
( , ).
, . .9
t1,0 - t0,1 - .
t..0,1 t..1,0
0 1 (.9).
t. t... t..0,1
t..1,0. F t...
, , t...

.

10

. y = a*b
+ c*a + d = a*(b+c)+d. () (A), - (B) .
.10.

, 2t... < 3t...


() .
/ ( (B) ).
1.14
t..
.
, .
.11. , x0 x1
, .. x0 = ~x1, y = ~(x1 * ~x1) = 1. t..,
x0' x0 4t..
"" ( 1..2), t.. -
( 0..1).
"".

"" ,
. F = x1*x2
+ ~x1*x0, x2=x0=1 , , ~x1
x1 (. .12).

11

( ) , ..
, x2=x0=1, x0*x2=1 F = x1*x2
+ ~x1*x0 + x0*x2 1 x2=x0=1.
,
.

1.15
1. .
?
(1=10-9).
( ),
. 34
t..

t..

t...

t..

2. . : , ,
.

, , .
, , .
, , .
, , .

12

, , .
3. .
1. , .
2. , .
3. , .
4. , .
5. , .
1

4. ?

x3*x2 + ~x1*x0 + x3*~x2


x1*x0 + ~x2*x1 + ~x0*~x3
~x0*~x2 + ~x1*~x2 + x3*~x1
~x1*~x0 + x2*~x1 + ~x3*~x0
x0*x1 + x2*x3 + x3*~x2

2.


.

.
().

13

2.1
"" .
"" , - XVII.
n- C(n-1), C(n-2), ... ,C1,C0
:
D = Cn-1*bn-1 + Cn-2*bn-2 + ... + C1*b1 + C0*b0 (15)
D - , Ci - i- , b - ,
b i - ( ) i- n .
(BIN),
(DEC), (HEX) - (BCD) .
BCD 10, ,
i- 4- . (OCT) .
16- 0 9 , 10
: A(a) = 10, B(b) = 11, C(c) =12, D(d) = 13, E(e) =14.
(15),
10010011 = 1*27 + 1*24 + 1*21 + 1*20 = 147 (DEC). 16 , , , 4
(8,4,2,1) Ci.
HEX , ,
, .
:
00111011.
:

128 64 32 16 8 4 2 1

7 6 5 4 3 2 1 0

0 0 1 1 1 0 1 1

0 + 0 + 32+ 16+ 8 + 0 + 2 + 1 = 59(DEC)

(HEX)16- 00111011.
:

3 2 1 0

8 4 2 1
0 0 1 1

: 16-

3 2 1 0

8 4 2 1
1 0 1 1

0 + 0 + 2 + 1 (3) 8 + 0 + 2 + 1 (11) = 3B(HEX)

HEX 11 B.
- , 1998,
- 0001 1001 1001 1000. BCD,
19(DEC) = 19(BCD), : 10011(19DEC) 1
1001(19BCD). - .

14

, 11001001(BIN) = [C9(HEX),201(DEC)] = ?(BCD), .. 1100=12


.

2.2
() ,
.
m = 2n, n - . m < 2n.
2n , n -
, .. . n=2 m=4, "2
4" OE.
/ 1, - 0. ,
x .

y0 3- :

, 1- ,
y0 : y0 = OE*~a1*~a0.
. yi
-: y0 = ~(~(OE*~a1*~a0)).
.13.
"..." (A), - ().
2 .

15

().
~OE=1 -(0..3) OE=0,
a0,a1, ~yi=1, yi=0, .13.
t0..t1 t2..t3 "", .. yi
"0", "1". t1..t2 ~OE=0(OE=1) yi
a1,a0. A1A0=10,
, - 3 "1". ~y2=0, y2=1,
y2. OE, ,
.14. OE=1 , ~OE1 = ~OE2 = 0 OE3 = 1.

"3 8" 15337(5557),


.15. ,
, ()
. ai ,
, .

16

2.3
,
,
(). ,
OE x. ,
a1a0=10(BIN)=2(DEC), x y2, yi=0. .16.
"1 4" .

2.4
.17 "3 8" "4 16",
"1 8" "1 16".

~OE=1 OE=0 (.14) yi "1",


ai. ~OE=0 ( ),
a3. a3=0, (A)
, OE (B) a3
1 (. .4), .. (A). a3=1,
(B), ~OE
(A) . a3 a2..a0,
, 0000 ... 0111 (0 ... 7)
(A) 1000 ... 1111 (8 ... 15) (B).
yi, "4 16" 0 15. .17,
, - (
).

17

2.5
xi y,
ai.
OE, "0"
( .5). "4 1",
4 log4 = 2 .

x . 7,
128 . .5 4-x 64
( x0 ... x3) , 64 . 0
, , y=x0, a1=0 a0=0 OE=1, x1 ... x3.
: y=x0*OE*~a1*~a0.
y . :
y = OE(x0*~a1*~a0 + x1*~a1*a0 + x2*a1*~a0 + x3*a1*a0). (16)
:
-----------------------------------y = ~(OE*x0*~a1*~a0)+ ... +~(OE*x0*a1*a0).(17)
(17) , .18,

18

.19.
a1a0 = 11(BIN) = 3(DEC), y D3, ,
OE=1. , ,
.
,
"", ..
.
, ,
. (16) (12),
, fi = xi OE = 1. , "n"
"n" ,
fi.

2.6
() ,
,
.
. "4 2"
(.20):


. ,
, ("x" 0 1).

19

, 2+4+8=14
. .21. 0000 .
.
24=16
4. 12 ()
d. ( ),
. , ,
. .22.
d 1.

y1 y0:
-- -- -------

-- -- -------

y1 = x0*x1 = x0 + x1 y0 = x0*x2 = x0 + x2.

.23. x3
"", - ,
, , , , ..
. x3,
x0 + x1 + x2 + x3 0, ,
, .

,
. . 3,
11(BIN) = 3(DEC

20

2.7
() .
. .
-
(.24).
.

, .. 0
9 , , .
, , , , 0
G. 1
B C .. bi - 2i (8,4,2 1).
.25 . A.
, A .

. ,
A, . , .25-1
A.
,
, .. ~Ya, .

21

, .. . 1010
- ,
. : ~Ya =
x2*~x1*~x0 + ~x3*~x2*~x1*x0.

: Ya = ~(x2*~x1*~x0 + ~x3*~x2*~x1*x0).
-- 15334
(.25.). 5142
5141 .

2.8
n- X=(x(n-1),..,x0)
Y=(y(n-1),..,y0). :
0 (+) 0 = 0
0 (+) 1 = 1 (+) 0 = 1
1 (+) 1 = 0 1 .
(+) - ( F6
).
.
:
0 (+) 0 (+) 0 = 0
0 (+) 0 (+) 1 = 1
0 (+) 1 (+) 1 = 0 1
1 (+) 1 (+) 1 = 1 1 .
, ()
. .26, .

22

xi,yi - X Y, ci - , si c(i+1) - . c(i+1)


, :
c(i+1) = xi*yi + xi*ci + yi*ci.

(18)

si .26 . : si = xi*~yi*~ci + ~xi*~yi*ci +


xi*yi*ci+ ~xi*yi*~ci = ~yi(xi*~ci + ~xi*ci) + yi(xi*ci + ~xi*~ci) = ~yi(xi (+) ci) + yi(xi*ci + ~xi*~ci).
, .

-------------------

------------------

xi*ci + ~xi*~ci = ~(xi*ci) * ~(~xi*~ci) = (~xi+~ci) * (xi+ci) =


--------------------------------- --------------~xi*xi + ~xi*ci + ~ci*xi + ~ci*ci = ~xi*ci + xi*~ci =
~(xi (+) ci) = ~F6 = F9.

si = ~yi(xi (+) ci) + yi~(xi (+) ci) = 1
yi (+) (xi (+) ci) = yi (+) xi (+) ci.

(19)

(18) (19)
.27.

23

n-
(.28.). , ,
x0,y0 s(n-1).
,
2t.., .
:
t... = n*2t.. (20)

.

- ()
.
. (18) ,
: x + y = ~x*y + x*~y + xy.
- .
c1 = x0*y0 + x0*c0 + y0*c0 = x0*y0 + c0(x0 + y0) =
x0*y0 + c0(~x0*y0 + x0*~y0 + x0*y0) =
x0*y0(0 +1) + c0(~x0*y0 + x0*~y0) =

24

x0*y0 + 0(x0 (+) y0).

(21)

(19) (21) .29.

,
. (),
gi pi .
:
c1 = g0 + p0*c0, 2 = g1 + p1*c1 =
= g1 + p1*g0 + p1*p0*c0,
3 = g2 + p2*c2 =

(22)
(23)
(24)

= g2 + p2*g1 + p2*p1*g0 + p2*p1*p0*c0, (25)


......, . (22,24) - , .. c3 c2,c2
c1, c1 c0. (23,25) , ..
ci ,
. 1 2 .30.

25

.29 30 , ,
, xi, yi c(i+1)
3- 3t...
ci si, .. t.., : t... =
4t.. .
.

2.9

X Y , .
F(X==Y), 1, xi=yi i, .
X=(x1,x0) Y=(y1,y0).
.31, .

F(X==Y) = ~y1*~x1*~y0*~x0 + ~y1*~x1*y0*x0 + y1*x1*~y0*~x0 + y1*x1*y0*x0 = ~y1*~x1(~y0*~x0 +


y0*x0) + y1*x1(~y0*~x0 + y0*x0) = ~(x0 (+) y0)*~(x1 (+) y1) =
F9(x0,y0)*F9(x1,y1) = ~(F6(x0,y0)+F6(x1,y1)).
, ~F6(x,y) = F9(x,y) (. ).
.31,.
"/", 5551,

26

. .32 ,
. X = (x7,x6,...,x0)
Y=(y7,y6,...,y0) X = 1.
.

2.10 ()

,
.
, P(arity) . ,
.33.

M2 - " ".
4 : P = ~x3*~x2*F6(x1,x0) + ~x3*x2*~F6(x1,x0) + x3*x2*F6(x1,x0) +
x3*~x2*~F6(x1,x0) = F6(F6(x3,x2),F6(x1,x0)) = (x3 (+) x2) (+) (x1 (+) x0).
.34.

n- x(n-1),
x(n-2),...,x1,x0, x'(n-1),x'(n-2),..., x'1,x'0. P1 = x0 (+) x1 (+) .. (+) x(n1) .
P2 = x'0(+) x'1(+) ... (+) x'(n-1) (+) P1.
P1 , : P2 = (x0 (+)

27

x'0) (+) (x1 (+) x'1) (+) (x2 (+) x'2)(+)... ,


, xi=x'i xi (+) x'i =0, P2=0!
P2=1.
n- .

2.11

1. "", HEX ,
" ". :
5C 01011100

2. .

y7y6..y1y0
a2,a1,a0 OE3=1,~OE2=0,OE1=1. 00010000
" ".

28

3. .

: , X5=1,
101. ( 101(BIN) = 5(DEC)).
y2,..y1,y0 x7,..x1,x0. 110
" ".

4.

: , X6=1, X5=1, X4=1, X2=1,


110. (
= 110(BIN) = 6(DEC)).
y2,..y1,y0 x7,..x1,x0. 010
" ".

5.

29

: , ~OE,
Xi
~OE=0, .. . , MUX'a
. "1" A2,A1,A0 = 100(BIN) = 4(DEC),
X4=1, Y=0. ,
2,3,4 111. ,
( ). 5,6 , ~OE=1 Y
( ),
z.
" ".

3.

()
, .
t..
.

30

3.1

0 1 ( ) .
,
. :
- (RS-),
- "" (D - ),
- (JK - ),
- (T - ).

, - (
)
( - 0 1, - 1 0 ).
.

3.1.1 RS -
S(et) - R(eset) - - Q
- ~Q. X 0,
S R , S R
1. , S=R=0
. S=R=1 .
( 6).

Q X - , Q , . d
. - S,R
Qt, Q X.
dt.
Q(t+dt) .35, .

31

RS - :
Q(t+dt) = S + ~R*Qt = ~(~S * ~(~R*Q)). (26)
.35, . , Qt Q(t+dt)
, , .
, .36.

B , , .. RS
, A - , RS .
R=S=1 - ,
Q ~Q 1, Q*~Q = 0. ,
. ,

RS , .
RS .37.
t.., "-", ~S = 0 - 3,
Q , ~Q.
t2 - t0 = dt .
~R = 0, ~Q . ,
dt.

32

RS ""
.
. .38.

t0 , .
t1 ~S,~R 1,1 0,1
1. , Q = 1 ,
. t1..t2 " - ".
t2 (~S = 1, ~R = 0). t3
~S,~R 1,0 1,1 , ..
Q = 0. ( t3) .
.

3.1.2 RS -
- 1 2 (. 36),
RS - ( ).
.39.

33

, C=0 Q=~(~Q*1)=Q, ~Q=~(Q*1)=~Q, ..


S R, .
C=1 , RS-.
, "", .. C,
. .40.

t4 C = 1 R
S. t0...t1 R 1, S = 0, Q
0. t1 t2 R = S = 0 (Q
). t2 R = 0, S = 1 (Q = 1).
S t3 , t3 , ..R = 0, S
= 1. .

3.1.3 D -
D - : D(t)
/ () L(oad)/L(atch) - : "".
C(lock). Q
D L = 1 Q(t+dt) = Qt L = 0.
:

Q X - , Q , .
.41. ""
(. - ) . Q(t+dt) = ~L*Qt + L*D + D*Qt =
L*D + Qt(~L + D) = L*D + Qt((~L + D)*(~L + L)) = L*D + Qt*((~L + D*~L) + D*L) = L*D + Qt*(~L + D*L) =
~(~(L*D) * ~(Qt*(D*L + ~L))) = ~(~(L*D) * ~(Qt*~(~(D*L) * L))).
.41, .

34

~(D*L) * L ~(D*L) * L = (~D + ~L)*L = ~D*L


D- RS- , .
.42 ,
~S ~R ( ).

~S 0, ~R , Q=1
3. 2- .
4, , 3 . . D
L . , (~S ~R)

. ,
~S=1 ~R=0, , (Q = 0). D-
/ ~S ~R :
Q(t+dt) = S + ~R * (~L*Qt + L*D + D*Qt).

(27)

RS-,
D-. , ~S = 0 (S = 1) ~R = 1
( "1"), ~S = ~R = 1, RS- ""
, D-. .

35

t0 t1 L = 1 ( ~R ~S )
D Q ( D-
). t1
,
~R t2. Q = 0 L = D = 1
t3. t4 ~S = 0. .41
C, ,
, .

D - ""
D- .

3.1.4 D -
c D- L(C) .
L 0 1. L=0, L=1
, ..
(. 7).
~S ~R (.43).

36

Q X - , Q , .
D- " - - - "
.

.
, D- ,
(.44).

3.1.5 JK-
JK- J K, ,
, . :

37

Q X - , Q , .
, (~R) (~S),
C 1 0, 15,
, .. JK - .
JK- ~R ~S:
Q(t+dt) = S + ~R ( J*~Qt + ~K*Qt ). (27.1)
JK- .45.
" - - - ", .
JK - .

, RS, J S, K - R. , J = K
= 1 (. 8),
C, ,
.46.

38

3.1.6 T -
J = K = 1 (. 46) . , ,
. -,
0, 1, ..
. T - ,
D , JK - .
3.1.7
JK D - K (.471), : J=K=0, J=K=1, J=0 K=1, J=1 K=0
, .. . ,
C . .47-2 JK T -
(J=K=1). , 0.

D- T-,
D. Q(t+dt) = D, D D =
~Qt , Q(t+dt) = ~Qt, ..
C (.48-1,2).

, ,
RS- (.48-3), ,
~S ~R.
.48-1 Fmax
D- .
C
t... = tba (.48-4). t = tab
D, C.

39

. , F. < 1 / (t... + t).


th - (hold)
(),
.

3.2


. .

3.2.1
, .
, "", .
.49 8-
. C
(Qi=Di), - .

, , (. 50)
, (
). - "".
n- D- : D0=DS=x,
Di=Q(i-1), i=1,2,...,n-1. DS - .

C , i-
t.. (i+1)- .
, .. t0,1
t..
. ,

40

. C = 1
DS Q7 DS = x .
, , .
, . ,
. ,
Di,
L ~R .
~Ri, ~Si .
9.

Di X - , Di , .
~Ri ~Si : ~Si = ~(L*Di*~R)
~Ri = ~R*(~L + Di). , .51,
.

~R , ~R=0, ~Ri=0, ~Si=1


, L,Di C. L Di.
~R = 1, L = 1, Qi = Di
C. , , ~R L , ~Ri = ~Si = 1,
, .

,
( , "" )
(.52).

41

(COM-), 58051,
.

3.2.2
, ,
, .
, DSL,
DSR, (D0..D2), C, ~R 0
M1,M0, .53.

D- , , , 1 2
, . M1=0, M0=1, D
,
( ). DSR
. M1=1, M0=0, D
,
( ).
DSL. M1=M0=1 Qi=Di
.

M1=M0=0. D- (
). -
. 8-
153313. ( n )
2^n, n- . 5,
2 , 20.

42

3.2.3
( ), Di
L, C ,
.

( ), Di
, -, L , -,
C - .

( ).

3.3
() - ,
Q, . CR.
- , ,
:
Q = (D + SUM(C)) mod M
CR = (D + SUM(C)) \ M
: Q - , D - ,
SUM(C) - M -
( ,
), CR - ,
, mod -
M, \ - . D = 0 SUM(C) < M,
, Q = SUM(C) CR = 0. C M-
. : D =17, SUM(C) = 9, M = 8, Q = 26 mod 8 = 2, CR = 3.
(T-).
, , .. .
.
() ,
. - = 2, n = 2^n.
i- (i+1)-
.
1: CR i- (i+1)- , i- 0-
, (i+1)-
.

43

Q i+1 i..0

Q i+1 i..0

0 9999
DEC

-------1 0000

0 1111 1--->|
BIN

-------1 0000

|
|--->0

Qi ( .
), - .
2: ,

, ,
.

3.3.1 C
.
= 16 . ,
JK-

2 ,
, .. .
(J = K = 1). CR (Carry),
C .
~R , ~S ".1", ""
~R = 0. "+1".
, .

44

:
1) n- Q = Q3Q2Q1Q0 = n, 5, Q = 0101 = 5, 11- - Q = 1011 = 11(DEC), ..
.
2) 16- ""
, .. =16.
3) 2 (i+1), i -
, .
4) , ,
Q = Q0Q1Q2Q3 = 1111 = 15, .. ,
, 1.
. ,
, . ,
.
"-1".
5) ,
1 0, 0 1 -
.


: t.. = n * t.., n- . F.
< 1/t... .56.
.

t... (6,4,0).

45

, .. Fmax. < 1/(t.. +


t) F..

3.3.2
.
M = 8.
, Di
C(+1) ~L = 0,
~R.

i- (i+1)- CRi = Qi*..*Q1*Q0*(CE*PE)


"". CE ( ) PE ( )
(CE = PE = 1). J K ,
- (J = K= 0) (J = K = 1). "i"
, CR(i-1) = J = K = 1, ..
, 1. CR(i-1) =
J = K = 0 Qi . ,
- , CRi JK
t... = t.. + t.."", .
Fmax < 1/(t... + t). Fmax. =
Fmax..

3.3.3

46

R, CR
BR . .

, 2 (Q1 = 1 Q0 = 0).
, "-1" - , "+1" .
"2 1",
--, Q0=0.
(~Q0 = 1) .
T1 . ,
T0,
Q0 = 1 (~Q0 = 0).
, ..
t1,0 t = t.. +
t.., "+1" "-1"
0. T1 .
1 Q1Q0 = 11 = 3, .
, "+1" - , "-1"
.
, .. ~Q0 = 1 T1. t
T0, c ~Q0
T1, , "-1" .
10 01, .. 1.
15336 15337,
~L . .

47


. "+1" "-1" "1 2".
, U/~D = (Up/~Down) = 1, C
, - .
.

3.3.4
n - Mi.
.
CRi
F.
- QQ N
?

.
CR1 = (D1 + F) \ M1 (1 ). , D < M, CR1 =
F2 = F \ M1. , CR2 =
F3 = F2 \ M2 = F \ (M1* M2) . CRn = F =
F\(M1*M2*...*Mn).

48

1- QQ1 = (D1 + N) mod M1,


QQ2 = (D2 + CR1) mod M2, QQn = (Dn + CR(n-1)) mod Mn,
CRi .

3.3.5 -
.
, , .

.
.
D tclk = 1., N, D.
N=M-1-D ( M-1 = 11..1).
, D+1 ,
T = tclk * D, .. D - 0 = M - 1 - (M - 1 - D) = D.

3.3.6
6 10 ( - ).
Qi BCD
.
: ,
.

, R . 1)
(

49

, 1). N=1997 .
QQ0 = 1997 mod 10 = 7. CR0 =1997 \ 10 = 199
, QQ1 = (199 mod 10) = 9 CR1 = 199 \ 10 = 19.
BCD = 0000 0000 0001 1001 1001 0111,
001997. ! ,
- . BCD : N =
QQ(n-1) * 10^(n-1) + ... + QQ1 * 10^1 + QQ0 * 10^0. , N
: 1 < = N <= 999999.
2) , "a", "b"
T 10^i (i =..-1,0,1,..), T = 1,
.

"a" : F = 1/dt. "b" "c"


dt = T / N, dt / T. F = N / T T = 1
F = N. : (1...(10^6)-1).
"a" F = 10^i (i=2,3,..),
F =10^6[]. T = N * dt = N / F
(1..999999).

3.3.7

.
+ ?

: 1) (R)eset , ~R = 0 ,
. 2) U/~D = 0 (Down - )
, U/~D = 1 (Up - ) - . 3)
( ,
C),
(4) (1) : 3.

50

Q3Q2Q1Q0
4 Q3Q2Q1Q0 = 1100 ?

: 1) (DEC) 1100(BIN) = 12(DEC) . 2)


, ( C "-1"). 3) , =
8.
.
Q2Q1Q0 . , C 94.

: 1) , -
R=1. 2) CR
CR = (0 + SUM(C)) \ M = 94\4 = 3. 3)
Q = 3 mod 5 = 3.

. (0..9AbCdEF)
+ ?
.
: 0

2 3 4

8 ...

: 07 39 4f 6f 7d 77 7c 06 07 ...

: 1) c (-->). 2) ~R=0
3) C
(U/~D=1) (U/~D=0). 4)
. 5) HEX .6)
, 06 = 00000110 (BIN) .. 1( C B).
= GFEDCBA.
: A.

51

4.
() ,
.
()
.
4.1 R-2R
,
.
Uo I = Io * 2n.

" 0" R0 = 2R.


" 1" R1 = R + 2R||R0 = 2R. ||
. , Rn-1 = R + 2R||Rn-2 = 2R
, Uo, R =
2R||Rn-1 = R, .. R .

Io*2n = Uo/R

(1)

, n-1 ,
2R, Rn-1 2R.
n-2 .. "" Io*2i, ..
2i.
(), (. .64). , ,
, 5721,2 11081.

di .
i- , - .
:

52

1) ,
2)R .
, - dU , . dU =
U / ( = )
,-, . (*)
, : Ioc + (Io * 2i * di) = 0 (Io
* 2i * di) = -I. Io (1) : -I =
(U/(R * 2n)) * ((di*2i)). , U = I * R. I
, R = R :
n-1
___
U \

U*D

U = - ---- > (2i * di) = - ---- ,


2n /__

(2)

2n

i=0
D = (2i * di) - .
n = 10 U = -10.24, U = (10.24/1024)*D (0, 0.01, 0.02
... 10.22, 10.23). .

-U, +U.

.

53

4.2

4.3
-
. , -
, - .
" " ,
.
. , , . 10- 10..00(BIN) = - 512(DEC).
01..11(BIN) = 511. 10-
11..11(BIN) = -1(DEC). 00..01(BIN) = 1(DEC).
, U
, . .

54

4.4 ( )
. 1 (
).
( ), (
), - ( ).
( ) .
.

10 (. ).
"" R. RG1
, R .

t0 RG1 ."1" ( ).
RG1 10..00(BIN) = 2^(n-1) = 512.
U(n-1) = U * 2^(n-1) / 2^n = U / 2. ,
U(n-1) <= U, , U(n-1) > U,
.
t1 (n-2) RG1
: Qn-1,1,0,0,..,0 : (Qn-1) * 2^(n-1) - ,
, 2^(n-2) = 0100..0(BIN) = 256 -
"". U(n-2) = U(n-1) * Q(n-1) + U *2^(n-2) / 2^n = (Uo /
2) * Q(n-1) + U / 4 . U(n-2) <= U,
, U(n-2) > U, (n-2)- .

55

n-.
~RDY,
. , .
T = tclk*n. tclk = t(i+1)-ti .
.

5721 11131(..).
D : D = |(U * 2^n)| / Uo, D
.

4.5
2^n .
U(i), ,
, U U(i).

56

(0 .. Uo) i- ,
U(i).
i "1",
"0". ,
.
/, ,
. , ,
1- (n-1)- ,
, .
"1", 0 <=
U < U(1), . - Mi = 0 , Mi = 1
. :
M1 M0

1 1

0 0

0 1

1 0

, ,
(.).

t0 C
. t1

57

. C ( t2),
C U .
t3,
t4,
. T
= Tclk, .. , .
11071,..5.

4.6
: D3D2D1D0 = 0100 , Uo
= -8v. .

:1) , U = - (Uo / 2^n) * D, n- (


, n = 4 ). 2) D - =
0100(BIN) = 4(DEC).
: 2 .
Uo 16 . n
, , U
-1,5 -1,75.

: 1) U = - (Uo/2^n)*D, n- ,
n D U.
: 6 .
: U = 2.5v, Uo = 8v. D3D2D1D0
.

58

: . D = (U * 2^n)
/ Uo , ..
D3D2D1D0 0111. Uo = -8v.
3- C.

: 1) , (+1). 2) L=1
BIN- = 0111 = 7(DEC). 3) 3-
4) (
).
: 5 .
C 2 .
+, Di L,C.
.

: 0 1 2 3 4 5 6 7 8 9 a b c d e f
: 1 8 e f b 6 9 2 7 c a d 4 0 5 3
: 1) (L)oad Q3Q2Q1Q0 = D3D2D1D0 = 0100(BIN) =
4(DEC). 2), (-1), 2
. 3) , Q0 A1,..,Q2 c A0,.. ..
A3..A0 (=4). 4) Y3Y2Y1Y0,
A3A2A1A0 BIN (b = 1011). 5)

59

Y0 -> X2 , Y1 -> X3 , Y2 -> X0 , Y3 -> X1. 6) 1110


, , .
: U = -14

5. ()

. ,
, .. , , .
: ()
() (). , , (RAM, Random Access Memory), - (ROM, Read Only Memory).
(Flash) ,
(Nonvolatile - NV). , ,
.
.
, , ,
. (SRAM),
(DRAM), (RG). : -
(ROM), - (PROM
OTP), - ()
(EPROM) c (EEPROM,Flash).

(PLM, PML, PLA, PAL, PLD, FPGA ..)
.
() : , ,
" ", ( ).
(). ( )
2n (1,4,8,16, 32,64..), 8- , ,
.
. :
, .
210 = 1024 = 1K. ( )
( ) Kb
KB.

60

"n" "n"-
, . , 511- 1 1111 1111(BIN) =
511(DEC) = 1FF(HEX). 16- .
2 n * m, 2n - , m -
, 8K * 8 (/ 53717), .. 8192 .
64K,
,
/ 16K * 4, 64K * 1 ..

5.1
D- . 53710

.

: n- (A0 .. An-1), DIO -


, - ~OE, - ~CS
- ~WE, - ~WR/RD,
, ,
- . EO, DI, WR -
//. j
, , k-
(DCc), n-k
(DCr). 2 n-k 2k, ..
, , 2k * 2n-k = 2n.

61

,
. .

Z . (j-) i- .
i = (r * 2k + c) 2n , r
c - . (C)hip (S)elect - ~CS, ,
,
.
~CS = 1 ( ), -
. . , L- D- - ,
. - Q , ..
EO / DIOi
.
~CS = 0, -
~WE ~OE.
~WE = 0. ~OE ,
EO, 0, .
i - , An-1,An-2,...,A1,A0(BIN) = i(DEC),
Yr Yc 1 ij
DIOj.
~WE=1, ~OE=0 Yr=Yc=1, ~Q
ij DIOi.
, 2^n j-
j- - DIOj.
(). ()
.
j- Rj,
-ij .

62

,
.
.
Cash-.

5.2
,
D- . ,
, DRAM , SRAM.
. ,
, .
k- k-
"1 2", k- .
, ,
, - ,
, - .
.
.
, :
1) , 2)
, 3) ( ), 4) .
/ 5657 256K*1 (218K)
18- 9- "2
1", - 153316.

512 * 512 = 29 * 29,


, 9- .
/ ~R/C S , , A(0..8) = Y(0..8)
.
~RAS. ~R/C = 1 A(9..17),
~CAS. ~WE
/ . - (SIMM, EDO, SDRAM..)

63

. 10, 256M
.

5.3
, ,
.
" ". " " 200
. , .
, , ,
. - (EPROM),
(EEPROM). "1".
. / EPROM 5732
(2 * 8) .
Flash- " " 100 ,
.

5.4 (PROM,OTP)
,
. .75 .

"i"
Yi = 1, . j-
fi. (fi=1),
, DOj = 0.
(fi=0), DOj=1. j- ,
/ . Yi = mi,
mi- A0..An-1. -,

64

2^n-1

n-1

~DOi =(fi * mi), mi = (/Ak).


i=0

k=0

/Ak = ~Ak, Ak 0 /Ak = Ak, Ak = 1.


(12), n- m m- n- (
).

5.5 (NVSRAM)

- NonVolatile Memory,
:

EEPROM , SRAM
EEPROM
/

5.6 ()
n-, m- (n>m),
. n/m -
, , , .
, 256K ,
8 / 1 = 8 5657, .

- .. ,
.

5.7
2k "k"
, "n" An+k-1, . .An+0, An-1, An-2, ... A1, A0.
An+k-1 .. An+0

65

2k ,
. "k 2 k".
, 2K*4, 8 256*4 5411
"3 8", .

j-
Rj. A10,A9,A8
, 256-
(). () A10..A0 = 11000011010 = 61A.
, (A10..A8 = 110 =6) .
~Y6 = 0 ~OE1
, 1 1010 = 1A(HEX) = 26(DEC) A7..A0 26-
().
()
. 2n-
() ,
() ,
. .

5.8

().
: 1) , 2) ,
3) , 4) , 5)
, 6)
.


'
() ,, .
, (, ,
) .
, .. ,

66

().
, , /,
. .1.

( ' )
.2 . .

. ( X)
()
. .2 x1 .
, .
, . .3
.

/,
. (=1), - , - MUX1
.

67

E, "/"
. MUX2,
. C F(use)1 F(use)2
"2->1" ,
MUX.
.

5.9
: )
- ram rom? ) ( ) )
?

: 1) : ~CS,
~OE ~WR,
(ram). 2) 2^2 .
3) = 2

68

Y , .

:
, . X -
. : x0*x2 + x0*x1.
Y.

: .
. ,
Yi = ~(~b * ~c * ~d * ~e * ~f * ~g * ~h). Yi
, , .

69

. (
)!
: ~(b + c + d + e + f + g + h)

6.

6.1
() ()
:
- () - - ;
- / n- - n- ;
- - - ;
- - - .
, ,
U = f(U).

U1/Uoh - , -"1". U1/Uoht


- , - "1". U0/Uol -
, - "0". U0/Uolt -
, - "0". U1/Uih - ,
- "1". U1/Uiht - ,
- "1". U0/Uil - , "0". U0/Uilt - , - "0". Ucc .
/ ,
.

70

6.2
,
.

6.3 (,N)
-
(/).
/. / ,

71


, .

N 0 1 j. . m,n - .

6.4
,
.
( 1554,1564,1594 .) 1533 (AC,
HC,ACT,HCT,FCT ALS). , 25
() - .

+U,

+U,

164,176

4000(74C) 3..15;9

561,564

4000A

3..15

1561

4000B

3..18

1554

74AC

2..6

1564

54/74HC

1594

ACT

FCT

2..6
2..6

2..6

155 74

158 74L

131 74H

555 74LS

531 74S

1533 74ALS

1531 74F

ACQ/ACTQ 2..6

FASTr

FCTx/FCTxT 2..6

BCT

5
5

.....................................................
,
. , 1024,

, .
/ 16, 64
.
,
- ()

72

. ,
/ (. ). . ,
- ( 1533 1554."".1993.,.24).

+ : , , +- :
, OKR :
, +5 HCT, R, :
, +10 40109,14504
LTC1045, : 74C901/2,4049/50,14504 LTC1045.
.

73

6.5

- (),
() , U = (U+ - U-)
: U = "1" (U+ > U-) U = "0" (U+ <= U-)
U = "-1" (U+ <= U-) .
.

() ,
.0 1 . ()
: (U-) < .0 (U+) > U, ..
, 0 U,
. () ()
, ,
. ,
. ()
.

6.6
19480-89
.
t..1,0 / tPHL - .
,
() H L , 0,5 .
t..0,1 / tPLH - - L H .

74

t.. / tPAV - .
t1,0 / tTHL - . ,
H L , 0,1 0,9
.
t0,1 / tTLH - - L H .
t / tSU - .
.
t / tH - . ,
.
/ N - . ,
.
/ Ni - . , .
U / Ucc - .

7.

7.1
()
:
D = Cn-1*bn-1 + Cn-2*bn-2 + ... + C1*b1 + C0*b0 + C-1*b-1 + C-2*b-2 +..,
D - , Ci - i- , b -
,b i - i- n .
: (BIN), (DEC),
(HEX) - (BCD) . BCD
10, , i-
4- . (OCT) .
16 1.

75

10010011 = 1 * 2^7 + 1 * 2^4 + 1 * 2^1 + 1 * 2^0 = 147 (DEC).


16 - , 4
16 - .
HEX , - . , 1997, - 0001
1001 1001 0111. BCD, 19(DEC) =
19(BCD), : 19(DEC) = 10011(BIN), 19(BCD) = 1 1001(BIN).
- . ,
11001001(BIN) = ?(BCD) = C9(HEX) = 201(DEC), .. 12 = 1100 !

7.2
.
.

76

- (4 ), ( byte 8 ), (DoubleWord 16 )
(LongWord 16 ) .
.

7.3
, .
. , ,
- .
, ,
.

.
, - .
, - .
, ..
.

1. . , . 00001001
= 9, 10001001 = -9. ,
. , ,
.
2. , " 1".
- : 00001001 = 9, 11110110 = -9. , ..
. () ,
(). : 7 + (-5) = 2.

00000111 = 7
11111010 =-5 ( 00000101 = 5)
1 00000001
1
00000010 = 2
, ..
, .
.
, .. 0...00 1. ..11
, 1...11.: (00001001 = 9) +
(11110110 = -9) = 11111111. ,
" 1". ---

77

3. " 2" .
. , 9.

00001001 = 9

11110111 =-9

11110110 -
1

00001000 -
1

11110111 =-9

00001001 = 9

. +0 = 00000000, -0 = 11111111 + 1 = 00000000 (


).
.

00001001 = 9
11110111 =-9
1 00000000
,
, . ,
, " 2-" .

7.4

: 0 <= D <= 2^n - 1. n -


: 0

- 255 (DEC) : 0

00..0 - 11..1 (BIN)


0

FF (HEX)

- 65535

00..0 - 11..1
0

- FFFF

:-2^(n-1) <= D <= +2^(n-1)-1. n -


.
: -128 - +127 (DEC) : -32768-+32767
10..0 - 01..1 (BIN)

10..0 - 01..1

80

8000 - 7FFF

7F (HEX)

7.5 ()
, ..
: .

78


. 3
( - ).
D = M * 2^(E-127)

. D - , M -
, - , SM - .

7.6
()
, 23 - 1,xx..xx. Mmax = 1,111..11 = 1 +1/2 +1/4+ 1/8
+...= 2, Mmin= 1,000..00 = 1 (SM=0) -1 -2 ,
(SM=1). Emax = 11111110 = 254, Emin = 00000001 = 1.
+Dmax = Mmax * 2^(254-127) = 3,4 *
10^38 +Dmin = Mmin * 2^(1-127) = 1,17 * 10^(-38).
. 23 2^23 10^7, ..
6-7 , 38. ,
11111111 00000000 IEEE 754 854
,
, , -.

7.7 -
- () Binary Coded Decimal (BCD) ,
, -
. 1996 : 0001 1001 1001 0110.
, ()
18- , .

7.8 -
, ,
- . , ,

79

, , ,
.
, : ASCII, -7, -8, ,
. ASCII 7- (-7)
128 .
(-8, ).
256. .
, (NULL) .
(HEX) (HEX) (HEX)
--------+--------- -------+--------- -------+--------"" 00

"A" 41

"" 81

"0" 30

"B" 42

"" 82

"1" 31

"C" 43

"" 83

.. ..

.. ..

"9" 39

"Z" 5A

":" 3A

"[" 5B

.. ..
"" 9F
"" A0

\_________ASCII ___________/
\_______________ _______________/
Internet -8.
16- Unicode 65536 .

7.9
BCD HEX
0 1. :

4.
.

7.10
( )
.
10000110. , :

80

1) = 10000110,
) = 86(HEX),
) = 206(OCT),
) = 134(DEC),
2) =-122(DEC),
3) - = 86(BCD),
4) "",
4') -8 "",
5) "1.",
6) ,
7) , 3 8-,
8) ,
9) ..
.
, ASCII "1" + "2" "3", 31(HEX) + 32(HEX)
= 63(HEX), "c".

8. 8086(88)

8.1
() ,
80x86 : 181086/88 (8086/8088).
, - , - ,
8086, - . 1.
8086 .

81


. 4-
: (AX,BX,CX,DX), 4-
( SP,BP,SI, DI) - ()
( F).
, .. . ,
,
. c, 8-
AH, AL, BH, BL, CH, CL DH, DL.
16- () . SP
(StackPointer) " " -
, . BP(Base Pointer)
. SI DI (Source Destination Index) ,
.
, .1 ,
. CS,SS,DS,ES
64- .
.
(SP,SI,DI,IP).
, ,
(CS) (IP). IP 16-
.
.
.
:
( " - " FIFO ).
,

82

.
.

8.2

F.

x , .
, ,
(), .
, , " XX" - (XX).

ZF - / (Zero), 1, ,
(ZF)=0.
CF - (Carry) ,
1 , (CF)=0. CF
.
SF - (Sign) , , ..
.
PF - (Parity). (PF)=1,
( - ).
AF - (Auxiliary) ,
( D3) ( D4).
BCD .
OF - (Overflow) , -
, .
: (OF)=1, / /
.

: 125 + 4 = 129
-128.. ..+127 ( 129 - ).
0 1 1 1 1 1 0 1 = +125
0 0 0 0 0 1 0 0 = +4
1 0 0 0 0 0 0 1 = +129 > +128 ( -127 ???)
//:
01 :
D7 1, D7 = 0, (OF) = 1, (CF) = 0, (ZF) =
0, (SF) = 1, (PF) = 0, (AF) = 1. .
()
PSW.

8.3

83

8086 20- , 2^20


. 16-
.
, .
16 64Kb.
- , , ,
.
CS,SS,DS ES. 16- ,
20- , 20-
( 16)
(IP,SP,DI,SI).
. ,
: = (IP) +
(CS) * 16, (IP) - , , (CS) - ,
(CS) * 16 - .
.2.

8.4 ( )
, ,
.
.3. ,
, 16
().

84

C . t0
(+). ~RES
0 t1, C
1. t0..t1 RESET .1.
. CS
FFFFh, IP 0000h.
C ~RES "1", RESET
. .
FFFF:0000 ,
, .
SW. C .
.
64Kb.
, ~MX/MN = 1. ,
( ), ,
.
G CLK, .
, .
, .
4 T1 ... T4.

T1 /
(), , . T2
, T3,T4 - .

85

( ) , RDY
RDY = 0, TW, ,
(RDY = 1). ,
TI.
/ (AD15..0)
"" RG BD.
( )
. D- RG ALE
D-.
.
, , .
, -, BD , -,
() .
~DT/R (~DT/R=0 - Transmit, ~DT/R=1
- Receive).
~DEN (Data Enable).
():
~MEMR ( ),~IOR ( ), .
~MEMW (
()), ~IOW ( ()). ,
, , (~RD,~WR)
M/~IO, : .
, 4
.

8.5
DC,
. .
,
, . , DC 4
A19..A16,
2^20 / 2^4 = 64, 16- (2^4 = 16) ,
( .4 7 ).
, , .

86

, :
(PPI IOP),
8- PA,PB PC ,
, , 8- .
.
.

- -UART
( -PCI IOS). RxD - TxD
. , .
, , ..
-PIT,
16- . ,
3..65535 .

, ,

87

- PIC (
IRi). .

DC ~CS = 0,
. ()
, .. ~CS = 1. ,

/ (~MEMR, ~MEMW) ,
/ (~IOR, ~IOW) / .

(DMA).

8.6
,
" - " (LIFO).
.
.
. , (bottom)
SP MOV SP,0fffeh. 0fffeh -
, , , . . .
SP , (top).
- .
PUSH AX POP BX.
AX 874c.

PUSH :

SP 1: (SP) <-- (SP) - 1.


87: ((SP)) <-- (AH).
SP 1: (SP) <-- (SP) - 1.

88

4c: ((SP)) <-- (AL).

POP , :

(BL) <- ((SP)),


(SP) <- (SP) + 1,
(BH) <- ((SP)),
(SP) <- (SP) + 1.

" " . .7
PUSH AX , .8
POP BX.
,
, ,
, ,
, , "".
:
1) CALL RET
(IRET),
2) ,
3) ( ),
4) .

8.7 -
- ().
.



() DMA
(MCS-96)

.
- ,
. 4-
.

8.7.1 -
, ,
. :

(IN) (OUT)
(MOV, LODSB,..).

89

64K .5 .

0000 ...XXXX .

- ~IOR,~IOW
~MEMR,~MEMW .
.
.5 .
.
.
. .
, , 99,99..% ,
. .

8.7.2 -

( ),
( )
( ), 0.

.
: ,
. ,
INTR -
. :
1. , INT(R)
;
2. ,
STI(EI 8085), -INTA;
3. () - N;
4. PSW, CS,IP ( ),
;
5. IF ( ) TF ( ), ..
(IF) = 0 ;

90

6. IP 4*N, CS -
. 4 () .
7. - .
INT_SUBR:
STI
PUSH AX
....;

....;

MOV AL,5;
....;

....
POP AX
IRET
, STI-
, .5. push pop
, (
AX).
8. IRET - IP,CS PSW;
9. .
INT N .3. N 0 <= N <= 255,
1024 .

8.7.3 ()
, ( )
, .. : (AX AL) - .
HOLD, HLDA.
, ~OE
~BUSEN = 1 . ( )
- .
/.

91

.6 () -
(..t1, t2..) ,
. ()
( t1..t2), . - (),
. ()
,
, t2-t1.
,
- (), .

().
MCS-96.


. o.

: ,
. .
. -
. " ".
: 4dba.
: PUSH AX; PUSH CX; POP DX; POP BX.
BH? (
POP).

92

: - - ,
BX. " - "
" - ", , AX
BX. PUSH AX "
- ". : c9
: POP AX; POP DX.
DL?

: 4c

( p p pp).
+ ? , ,
, .

: ~DEN=0 ( ) 4 ( ):
1) M/~IO = 0, ~RD = 0 / (~IO) - (~RD). 2) M/~IO = 0, ~WR =
0 / (~IO) -(~WR). 3) M/~IO = 1, ~RD = 0
(M) -(~RD). 4) M/~IO = 1, ~WR = 0
(M) -(~WR).
: .

93

9.

9.1 . .
""
.
, .
, .
:

1) - ,
2) PROG.ASM . PROG
, ASM - ,
3) ( )
TASM.EXE. PROG.OBJ (
).
.2 3,
4) TLINK.EXE PROG.OBJ
PROG.EXE PROG.COM.
5) .1, .

94

) ,
) ,
) ,
) .

.,,
, .. . ,
, ..
.

9.2
,
[ ]:
[:]

[()]

[;]

31 ? @ . _ $.
, , .
- () , ADD
(addition).
,
.
b(B), o(O), d(D), h(H) 2, 8, 10 16- .
, .

95

,

.

181086 (8086) .
, INT XXh CD(HEX).
:

1) ,
2) ,
3) ,
4)
5) .

,
,
,

.


.
() (),
MOV AX,CX CX AX.
,
MOV AL,0f5h 245(f5) AL.
,
, IN AL,40h
40h.
, , ..
MOV AL,[BX] al ,
BX.
,
.

9.3 , ,
80X86(8088)
9.3.1
1. $ - . .
.
text DB 'This string has NN letters'

96

NN = $ - text; NN = text (
). '..NN..' NN!
2. @data - .
....
mov ax,@data
mov ds,ax;
DS .
3. ??date, ??time, ??filename - ,
, ASCII.

9.3.2
1. () - ,
2. [] - [BX] bx.
.
3. +, -, *, / - , , .
mov ax, (2 * 3 + 8 / 2) - 2; ax 8.
4. MOD - . .
5. SHL,SHR - , .
mov si, 01010101b SHR 3; SI 0Ah (00001010).
6. NOT - .
7. AND,OR,XOR - "","",".".
mov dl, (10d OR 5d) XOR 7d; (dl) 8.
8. : - .
mov dl,[es:bx]; dl es (bx)
().
9. OFFSET - (
).
mov bx, OFFSET table

9.3.3 ()
1. : - ( ).
jmp lbl .... ....
lbl: ....
2 . = - .
videoram = 0B800h; videoram = 0B000h;
3. .CODE - , ,
.

97

4. .DATA - .
5. DB,DW - : DB,
: DW.
....
.DATA
fibs DB 1,1,2,3,5,8,13
rus DB ' '
buf DB 80 DUP(0); 80 ,
int DW 65535; FFFFh.
Array DW 100 DUP (0); 100
6. END - .
....
.CODE
MyPROG:....; ( ).
....;
....
END MyPROG
7. ENDM -
8. ENDP - .
9. EQU - .
BlkSize EQU 512
BufBlks EQU 4
BufSize EQU BlkSize * BufBlks
10. LABEL - .
....
.DATA
m_byte LABEL BYTE; m_byte BYTE
m_word DW 0;
.CODE;m_word WORD
....
mov [m_word],0204h
add [m_byte],'0'; m_word
add [m_byte+1],'0';3234h,ASCII '0' 30h
11. LOCAL -
: ??XXXX, XXXX =
(0000...FFFF)h. ??XXXX ?
??, .

98

12. MACRO - .
Swap MACRO a,b; a,b - ( )
mov ax,b;
mov bx,a; ,
mov a,ax; xchg ;
mov b,bx; mov a,b;
ENDM
: Swap m,n
13. .MODEL - .
.MODEL tiny; , (64 Kb).
14. PROC - .
Print PROC NEAR
;
Print ENDP
....
call Print; .
15. .STACK - .
.STACK 200h; 512 .
16. .RADIX base - , base -
: 2, 8, 10, 16.
.RADIX 8
oct

= 77; oct 63d.

17. ; - .

9.3.4
1. MOV DST,SRC; (SRC) (DST). ,
AL - (AL) (al),
<-- .
mov al,ch; (al) <-- (ch).
mov cx,dx;
mov bh,[mems];
mems BH. : mov bh,mems.
mov al,[bx];
BX .
mov bx,OFFSET src; BX
SRC, .

99

mov al,table[bx];
table
(bx) . :
mov al,[table + bx]
mov al,table + bx.
BX

AL


mov al,[table + bx]

0010

BX

XX

AL


mov al,[table + bx]

0010

58

0800 (table)

08xx

xx

0810

58

0800 (table)

08xx

xx

0810

58

2. PUSH RP; RP ( push bx).


3. POP RP; RP ( pop ax).
4. XCHG DST, SRC; (DST) (SRC).
.
5. XLAT SRC; SRC
= (AL), AL. SRC BX.
: XLATB.
....
.DATA
src DB 15d,10h,00110101b,'A','B',166d
.CODE
....
mov al,2;
mov bx,OFFSET src; AL
xlatb; 00110101b = 35h = 53d = ASCII'5'
6. IN ACCUM, PORT; AL AX PORT.
<= FF , >
FF, , DX (
).
in al,0a5h; AL A5h ....

100

mov dx,379h; AL
in al,dx; 379h
7. OUT PORT, ACCUM; AL AX
PORT.
out 0ffh,al;
....
mov dx,37Ah; AX out dx,ax; 37Ah
8. LEA RP,M; RP ()
M.
lea di, rus; - mov di, OFFSET rus.

9.3.5
1. ADD DST, SRC; SRC DST DST.
add al, [mem_byte]; mem_byte
add [mem_word], dx; mem_word
add ch,10001010b;
2. INC DST; (DST) 1 ( (DST)).
inc si; (SI) <-- (SI) + 1.
inc count; (count) <-- (count) + 1.
3. SUB DST, SRC; (SRC) (DST) DST.
4. DEC DST; (DST).
5. CMP DST, SRC; DST SRC. (SRC)
(DST) DST .

OF SF ZF CF

DST > SRC

0/1 0 0 0

DST = SRC

0 0 1 0

DST < SRC

0/1 1 0 1

0/1 - , 0 1 .
OF SF , CF .
OF 1,
.
OF 1,
. DST > SRC
, :

101

DST:

1. (+127)

SRC:

- (+2)

2.

(+127)

- (-2)

-------

-------

(+125) (OF)=0

(+129)? (OF)=1

: -128 <= x < = +127. SF


'1', 1, ..
. . ZF '1'
(!), . CF = 1,
. .
SF = ZF = CF = 0, : SF = 1, ZF = CF = 0.

9.3.6
1. AND DST, SRC; "".
mov dh, 10101100b;
and dh, 0f0h;
DH 10100000b.
2. OR DST, SRC; "".
or bx,dx; (BX)=5F0Fh, (DX)=7777h,
;(BX)=7F7Fh.
BX

0101 1111 0000 1111 = 5F0F

DX

0111 0111 0111 0111 = 7777

BX ()

0111 1111 0111 1111 = 7F7F

3. XOR DST, SRC; " ".


xor al,55h; (AL)=5ah, (AL)=0fh.
4. NOT DST; .
5. TEST DST, SRC; AND ,
.
6. SHR DST, CNT; , ,
CF. DST .
mov bl,10110010b;(CF) = x
shr bl,1;(BL) = 01011001,(CF) = 0

0-- >

1
0

0
1

1
0

0
1

(CF)=X
----(CF)=0
->

mov cl,4;

102

shr bl,cl;(BL) = 00000101,(CF) = 1.


7. SHL DST, CNT; .
8. RLC DST, CNT;
9. RRC DST, CNT;
10. ROR DST, CNT;
11. ROL DST, CNT;

9.3.7
1. CALL SUBR; SUBR;
call delay;
mov ....
2. RET; CALL,
MOV ..
3. JMP NAME; NAME.
jmp short name; name,
; -128 +127 .
jmp near name; name,
; 65535 , .
jmp name; jmp near name;
4. JA NAME JNBE NAME; , , , CMP
DST, SRC , name.
5. JB NAME JNAE NAME; , , , CMP
DST, SRC , name
( 4 5 ).
6. JZ NAME JE NAME; , -
( "").
7. JNZ NAME JNE NAME; " ". ( 6 7
c ).

9.3.8
1. LOOP NAME; (CX) 1
, (CX) 0.
....
mov cx,64h; syc loop syc
syc: ....; 100 .

103

....
loop syc
2. LOOPZ NAME LOOPE NAME ZF .
, (CX) = 0 (ZF) = 0 . ..
.
3. LOOPNZ, LOOPNE - "".
....
mov cx,1000d; 1000
next: .... ;,
.... ; 129,.. ASCII
cmp al,''; .
loopnz next
9.3.9 ( )
1. LODSB; lodsb SI ,
SI 1, CLD ( DF)
SI 1, STD ( ).
....
.DATA
string DB 'abcdefg'
.CODE
....
cld; AL
mov si,OFFSET [string+2]; ASCII ''
lodsb; SI 'd'.
2. MOVSB; SI
DI (SI) (DI) 1. SI ,
DS, ES. DI
ES.
....
.DATA
msg DB ' O.K.'
LEN = $ - msg;LEN 8
.CODE
....
cld
lea si,msg; SI
mov ax,0b800h;

104

mov es,ax;
lea di,es:(0a0h * 3);4-
mov cx,LEN;LEN -
rp: movsb;
inc di;
loop rp; (CX)
....; ' O.K.' 4-
; .
3. REP ; .
:
....
mov cx,LEN; , ' O.K.'
rep movsb; B800:(A0 * 3),
; : OK. ?
4. CMPSB; c (SI)
(DI): ((SI)) - ((DI)). CMP
DST, SRC , . CMPSB
(CX) 1 (SI) (DI) 1, (DF) = 0.
5. REPZ REPE; . , (CX) = 0
(ZF) = 0.
....
.DATA
src DB 'To be, or not to be'
dst DB 'To be ,or not to be'
len = $ - dst;len 19
.CODE
....
cld; (DF) = 0
push ds;
pop es; ds es
mov cx,len; dst cx
lea di,dst; () dst DI
lea si,src
repe cmpsb;
je equal; ,
not cx; -
add cx,len;
jmp notequal;
equal:

....

105

....
notequal: ....
(CX) = 5.

9.3.10
1. CLC; (CF) = 0.
2. STC; (CF) = 1.
3. CMC; .
4. CLD; (DF) = 0, (
) .
5. STD; (DF) = 1,
.
6. STI; (IF) = 1, .
7.CLI; .
8. NOP; .

9.3.11
1. INT INUM; ,
, INUM * 4, INUM = (0...255). 4-
,
. 256 * 4
.
AH,
:
....
mov ah,14d; ,
mov al,31h; .
int 10h; '1'(ASCII 31h).
....
.DATA
privet DB ' morning !','$';
.CODE
....
lea dx,privet; DX
mov ah,9;9 -
int 21h; ....

106

9.3.12
, .

"+" - , , "-" - , "1" - 1, "0" 0 (), "#" - , "?" -


, >1 - , >n - .

9.3.13
1) EXE
.MODEL tiny
.STACK 200h;
.DATA
.....;
.CODE
mov ax,@data
mov ds,ax
..... ;

107

..... ;
mov ah,4ch;
int 21h; DOS
END
2) COM
.MODEL tiny
.CODE
ORG 100h
main: ..... ;
..... ;
mov ah,4ch;
int 21h; DOS
..... ;
END main
9.3.14
1. R1,R2 - - .
2. RP - .
3. SRC,DST -, ( )
4. M,M1,M2 - M,
M1 M2.
5. CNT - , CL CX.
6. SUBR,NAME - (
).
7. NAME
, -128
+127 .
8. INUM - .
10.

10.1 (PPI)

. PPI 8-
, - PA,PB,PC. PC
, "" 4- -
D7..D4 D3..D0. , (IOP),

108

D7..D0.
A1,A0 : PA,PB,PC
/ ( CSR - Control and Status Register).
A1

A0

PA

PB

PC

CSR

PPI "
" (Chip Select, Crystall Select, CS) ~CS = 0,
( - -).
- , "1" (A7=A6=A5=A4=1).
A1,A0
(),
.

A7 A6 A5 A4 A3 A2 A1

A0

(HEX)

PA

F0

PB

F1

PC

F2

CSR

F3

A3,A2 ,
(x - Don't Care Bits). 16-
, , . ,
PB 1111xx01 = 11110001(BIN) = F1(HEX).
(CPU) (),
PPI IN..... OUT.... : in al,XX out
XX,al.
IN OUT ( ,
). : IN AL,0F1h OUT
0F1h,AL.

1 ) ( F1) , (
-). (0)
~CS PPI .
2 ) ) OUT. ,
AL ~IOW
~WR. ~IOW
( PB). ) IN.
~RD ~IOR , AL
PB.

PPI ( )
. .
, : ,

109

..
"0", D6,D5,D2:

D7

D6

D5

D4

D3

D2

D1

D0

PA

PCh

PB

PCl

PA,PB,PCh,PCl (
, , , IN !).
( 1),
( <----- ), ( 0),
( -----> ).

10.1.1 PPI
,
. -
( )
PA ( ). / R
PC ( PC0), PC7.
PB.
PA
U, PB - . D4 (PA)
D7

D6

D5

D4

D3

D2

D1

D0

PCh

PCl

, D1(PB) - . ,
PC0 ( PCl) ,
PC7(PCh) - ,
:
D7

D6

D5

D4

D3

D2

D1

D0

HEX

98

,
.

110

R = 1 (
). R
T. .
~RDY = 0,
.
; ++++++++ PPI ++++++++
mov al,98h ; 98
out 0f3h,al; F3
...........
; ++++++++ ++++++++
mov al,01 ; PC0
out 0f2h,al; (R = 1)
mov al,00 ;
out 0f2h,al; (R = 0)
w: in al,0f2h ; (AL) PC
test al,80h; PC7 ( 80h),
jnz w

; - ,

in al,0f0h ; (~RDY=0), PA
...........; F0 ( ) .
; , , ..

; ++++++++ ++++++++
mov al,XXh ; XX
out 0f1h,al; PB F1.
...........

10.2 (PIT)
CTi

111

.
, / 7.
: CLKi - . G(ATE)i -
/ . OUTi - .
A1,A0 .
A1

A0

CT0

CT1

CT2

CSR

,
.
Chip Select 0- .
DC CPU PIT OE
: A7=1,A6=A5=0.
0- A4=A2=A1=0.
A1,A0 :

A7 A6 A5 A4 A3 A2 A1

A0

(HEX)

CT0

80

CT1

81

CT2

82

CSR

83


Ni ( ).
.
D7

D6

D5

D4

D3

D2

D1

D0

D7

D6

Ni

D5

D4

0 (CT0)

Ni

1 (CT1)

Ni

2 (CT2)

Ni

Ni

D3

D2

D1

Ni

D0

Ni

Ni -

112

D7,D6
.
D5,D4 Ni i- .

3 <= Ni <=255, i-
, , 0
(D5=0,D4=1).]

256 <= Ni <216 256, i-


, , 0
(D5=1,D4=0).

, 256 < Ni <216 256, i-


(D5=1,D4=1).

D3,D2,D1 . 0,2,3,4
GATE=1 GATE=0. 1 5 GATE
.

0. . OUTi
T = T * (Ni + 1). T -
CLKi.

1. .
: T = T * Ni.

2. Q>2.
: F = F / Ni. F = 1 / T F
= 1 / T. - (
T/T).

113

3. Q=2
(). ,
.

4 5. -. 4
T T = T*(N +1).
5 T = T*N.

D0 Ni . D0=0,
, - , -.
10.2.1 PIT

T1,
T2 F0 T1.

1. T1 = 15.

2. Fclk = 2.

3. F2 = 1.

4. F0 = 100.

Ni .

114

CT0. D7,D6 = 00 CT0.


100 2 3. 2
Q (
) Q/2 . 3
D3,D2,D1 = x11 = (011 111). CT0 3 N0 = 2000000 /
100 = 20000(DEC) = 4E20(HEX). 256 < N0(20000) <2 16 256,
N0 4E 20.
D5,D4 = 11. D0. -
N0 = 20000 ( ) 16- (
- ), D0 = 0 ( N0 ).
CT0 36(3E):

D7

D6

D5

D4

D3

D2

D1

D0

HEX

36

3E

CT2. CT2 D7,D6 = 10.


1 2 3. , 3
Q=2
CT2, .. ,
. 2
D3,D2,D1 = x10 = (010 110). N2 CT2 F0 / F2 =
100(DEC) = 64(HEX) 3<=N2<=255. , N2
, .. D5,D4 = 01.
N2 , ,
N2 - ,
D0 = 0.
CT2.

D7

D6

D5

D4

D3

D2

D1

D0

HEX

94

9C

CT1. CT2 D7,D6 = 01.


0 1. 1
GATE. 0
GATE1 = 1, D3,D2,D1 = 000.
0: N1 = (T1 / T2) - 1 = 15/1 -1 = 14(DEC) = E(HEX).
CT1 , D5,D4 = 01. N1 = 14
, 0E(00001110 BIN), 14(00010100 BCD). ( )

115

,
.
N1
D0 1.
, CT1 :
D7

D6

D5

D4

D3

D2

D1

D0

HEX

51

:
;####
mov al,51h; CT1
out 83h,al; 83
mov al,9ch ; CT2
out 83h,al; 83
mov al,3eh ; CT0
out 83h,al; 83
;#### Ni
;#### 0,2,3
;#### () Ni CLKi
mov al,14h ; N1=14(BCD !) CT1
out 81h,al; 81
mov al,64h ; N2=100(DEC) CT2
out 82h,al; 82
mov al,20h ; N0=20000(DEC)=4e20(HEX)
out 80h,al; CT0 80
mov al,4eh ; - N0
out 80h,al;
;#### .

10.3 (PCI)
(-) (() U(S)ART)
.
(IOS).
,
.
( ) ,
( , )
( ).

116

,

. . CT0
( ) .

: TxD - , RxD - , CLK -


, TxC - , RxC -
, ~CTS - (
). ~CTS "",
, " ", -
! , RS-232C, ~CTS
. C/~D - "/".
C/~D = 0 , , C/~D = 1,
. PCI
PPI.
,
.

PCI. ,
" " .
~CS A4,A3,A2 = 111(BIN) = 7(DEC)
A7,A6,A5 = 100(BIN).
PCI (A1 = 0).

/
(CSR)

(HEX)

A7

A6

A5

A4

A3

A2

A1

A0

CSR

9D

117

.
() :

, ST, ,

5..8 ,

/ PB,

1..2 - SP.

.
. / 01011001, 10011010.
, :

, , ,
. .
D7

D6

D5

D4

D3

D2

D1

D0

D7

D6

D5

D4

1 -

"" -

2 -

D3

D2

D1

D0

fTxC(RxC) / 1

fTxC(RxC) / 16

fTxC(RxC) / 64

D7,D6 - , " "


.
-.

(fTxC(RxC)/x)-1 D1,D0. fTxC fRxC TxC RxC


fCLK/(4.5). 16
64 . fTxC(RxC)/x (baud)
(bps). .
D1,D0 = 01 . .
fCLKmax = 2, fTxC(RxC) = fCLK/4.5 =444444,44.

118

16- (.
). 444444,44 / 16 = 27777
.

D3,D2 .

D5,D4 .
, - " "

. - " "

- .

, /
.
(CRC-,
.).

D0

TxEN

, D0=1

D2

RxEN

, D2=1

D4

ER

''0" , D4=1

D6

RESET

, D6=1


.
.
D7

D6

D5

D4

D3

FE

OE

PE

D2

D1

D0

RxRDY

TxRDY

D5,D4,D3, , /
:

PE=1 (Parity Error), /,

OE=1(Overrun Error),
, ,

FE=1(Frame Error), -().

RxRDY ( ), RxRDY=0,
.
TxRDY ( ) - TxRDY=0,

.

119

,
. - 8007(HEX). 8 :
fd,87,9c,88,40,55,8a,b8. 80,83 9c,9d .
fCLK(N0=5)>4.5.

;####
mov al,1eh; CT0,1 ., 3, BIN
out 83h,al; . 1e 83
mov al,5 ; . Fclk N0=5
out 80h,al; CT0 80
;####
...........
mov al,40h; D6=1
out 9dh,al;
mov al,0cfh; : 2 -,
out 9dh,al ; ,8 . , fTxC(RxC) / 64
mov al,01h; TxEN=1
out 9dh,al;
;####
mov cl, 8;
mov bx,8007h;
nxt: mov al,[bx]; AL
out 9ch,al;
wt: in al,9dh;
shr al,1; ? (TxRDY=1?),
jnc wt; , ,
inc bx; , .
dec cl; ?
jnz nxt; , .
........; , .

10.4

120

121