Giáo trình Vi xử lý - Phạm Hùng Kim Khánh

MỤC LỤC

CHƯƠNG 1: TỔ CHỨC HỆ THỐNG VI XỬ LÝ.1

1. Các hệ thống số dùng trong máy tính và các loại mã.1

1.1. Hệ thập phân (Decimal Number System) .1

1.2. Hệ nhị phân (Binary Number System).1

1.3. Hệ thập lục phân (Hexadecimal Number System).2

1.4. Mã BCD (Binary Coded Decimal).3

1.5. Mã hiển thị Led 7 đoạn (7-segment display) .3

2. Các phép toán số học.4

2.1. Hệ nhị phân .4

2.2. Hệ thập lục phân.7

3. Các thiết bị số cơ bản .8

3.1. Cổng đệm (buffer) và các cổng logic (logic gate) .8

3.2. Thiết bị logic lập trình được.9

3.3. Chốt, flipflop và thanh ghi .10

3.4. Bộ nhớ.12

4. Giới thiệu vi xử lý.13

4.1.Các thế hệ vi xử lý .13

4.2. Vi xử lý (μP – microproccessor).13

4.3. Giao tiếp với bộ nhớ.16

5. μP 8086/8088.21

5.1. Giới thiệu.21

5.2. Mô tả chân.22

5.3. Kiến trúc nội.28

5.4. Các thanh ghi.30

6. Phân đoạn bộ nhớ .32

7. Các cách định địa chỉ.36

7.1 Định địa chỉ tức thời.37

7.2. Định địa chỉ thanh ghi.37

7.3. Định địa chỉ trực tiếp.37

7.4. Định địa chỉ truy xuất bộ nhớ gián tiếp.37

7.5. Định địa chỉ chuỗi .38

7.6. Thay đổi thanh ghi đoạn mặc định.39Giáo trình vi xử lý

iii

Bài tập chương 1.40

CHƯƠNG 2: LẬP TRÌNH HỢP NGỮ.43

1. Các tập tin .EXE và .COM .43

1.1. Tập tin .COM .43

1.2. Tập tin .EXE.43

2. Khung của một chương trình hợp ngữ .43

3. Cú pháp của các lệnh trong chương trình hợp ngữ .45

3.1. Khai báo dữ liệu .45

3.2. Khai báo biến .45

3.3. Khai báo hằng .47

4. Các toán tử trong hợp ngữ .47

5. Các cách định địa chỉ trong hợp ngữ.50

6. Tạo và thực thi chương trình hợp ngữ.51

7. Tập lệnh hợp ngữ.51

7.1. Nhóm lệnh chuyển dữ liệu .51

7.2. Nhóm lệnh chuyển điều khiển .54

7.3. Nhóm lệnh xử lý số học .57

7.4. Nhóm lệnh xử lý chuỗi.62

8. Các cấu trúc cơ bản trong lập trình hợp ngữ .63

8.1. Cấu trúc tuần tự.63

8.2. Cấu trúc IF – THEN, IF – THEN – ELSE.63

8.3. Cấu trúc CASE.64

8.4. Cấu trúc FOR .64

8.5. Cấu trúc lặp WHILE .65

8.6. Cấu trúc lặp REPEAT .65

9. Các ngắt của 8086 .65

9.1. Ngắt 21h .66

9.2. Ngắt 10h .67

10. Truyền tham số giữa các chương trình.68

10.1. Truyền tham số qua thanh ghi.68

10.2. Truyền tham số qua ô nhớ (biến) .69

10.3. Truyền tham số qua ô nhớ do thanh ghi chỉ đến.69

10.4. Truyền tham số qua stack.70

11. Các ví dụ minh hoạ.71Giáo trình vi xử lý

iv

11.1. In chuỗi ký tự ra màn hình .71

11.2. In chuỗi ký tự ra màn hình tại toạ độ nhập vào.71

11.3. Cộng 2 số nhị phân dài 5 byte.72

11.4. Nhập một chuỗi ký tự và chuyển chữ thường thành chữ hoa .73

Bài tập chương 2.74

CHƯƠNG 3: TỔ CHỨC NHẬP / XUẤT.77

1. Các mạch phụ trợ 8284 và 8288.77

1.1. Mạch tạo xung nhịp 8284.77

1.2. Mạch điều khiển bus 8288.78

2. Giao tiếp với thiết bị ngoại vi.80

2.1. Các kiểu giao tiếp nhập / xuất .80

2.2. Giải mã địa chỉ cho thiết bị nhập / xuất.80

2.3. Các mạch cổng đơn giản .81

2.4.Giao tiếp nhập / xuất song song lập trình được 8255A PPI (Programmable

Peripheral Interface) .81

2.4.1. Giới thiệu.81

2.4.2. Sơ đồ khối.82

2.4.3. Mode 0: Nhập / xuất đơn giản.85

2.4.4. Mode BSR .89

2.4.5. Mode 1: Nhập / xuất với bắt tay (handshake) .90

2.4.6. Mode 2: Truyền dữ liệu song hướng .94

2.4.7. Các ví dụ minh họa.95

Bài tập chương 3.108

CHƯƠNG 4: GIAO TIẾP VỚI CÁC THIẾT BỊ ĐƠN GIẢN.109

1. Giao tiếp LED (Light Emitting Diode) .109

1.1. Giao tiếp LED đơn .109

1.2. Giao tiếp ma trận LED .111

2. Giao tiếp bàn phím .115

2.1. Giao tiếp phím đơn .115

2.2. Giao tiếp bàn phím Hex.119

Bài tập chương 4.126

Phụ lục 1: 8255.127

Phụ lục 2: Tập lệnh của 8086 .153

pdf201 trang | Chuyên mục: Vi Xử Lý – Vi Điều Khiển | Chia sẻ: yen2110 | Lượt xem: 192 | Lượt tải: 0download
Tóm tắt nội dung Giáo trình Vi xử lý - Phạm Hùng Kim Khánh, để xem tài liệu hoàn chỉnh bạn click vào nút "TẢI VỀ" ở trên
 Overflow Flag, otherwise sets the operand 
 to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 189 
SETS - Set if Signed (386+) 
 Usage: SETS dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Sign Flag is set, 
otherwise 
 sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SETNS - Set if Not Signed (386+) 
 Usage: SETNS dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Sign Flag is clear, 
 otherwise sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SETC - Set if Carry (386+) 
 Usage: SETC dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Carry Flag is set, 
 otherwise sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SETNC - Set if Not Carry (386+) 
 Usage: SETNC dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Carry Flag is clear, 
 otherwise sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SETO - Set if Overflow (386+) 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 190 
 Usage: SETO dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Overflow Flag is set, 
 otherwise sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SETNO - Set if Not Overflow (386+) 
 Usage: SETNO dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Overflow Flag is clear, 
 otherwise sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SETP/SETPE - Set if Parity / Set if Parity Even (386+) 
 Usage: SETP dest 
 SETPE dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Parity Flag is set, 
 otherwise sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SETNP/SETPO - Set if No Parity / Set if Parity Odd (386+) 
 Usage: SETNP dest 
 SETPO dest 
 Modifies flags: none 
 Sets the byte in the operand to 1 if the Parity Flag is clear, 
 otherwise sets the operand to 0. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg8 - - 4 3 3 
 mem8 - - 5 4 3 
SGDT - Store Global Descriptor Table (286+ privileged) 
 Usage: SGDT dest 
 Modifies flags: none 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 191 
 Stores the Global Descriptor Table (GDT) Register into the 
 specified operand. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 mem64 - 11 9 10 5 
SIDT - Store Interrupt Descriptor Table (286+ privileged) 
 Usage: SIDT dest 
 Modifies flags: none 
 Stores the Interrupt Descriptor Table (IDT) Register into the 
 specified operand. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 mem64 - 12 9 10 5 
SHL - Shift Logical Left 
 See: SAL 
SHR - Shift Logical Right 
 Usage: SHR dest,count 
 Modifies flags: CF OF PF SF ZF (AF undefined) 
 ÚÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄ¿ 
 ³0³ÄÄÄþ>³7 ÄÄÄÄÄÄÄÄÄÄ> 0³ÄÄÄþ>³C³ 
 ÀÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÙ 
 Shifts the destination right by "count" bits with zeroes shifted 
 in on the left. The Carry Flag contains the last bit shifted out. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg,1 2 2 3 2 
 mem,1 15+EA 7 7 2-4 (W88=23+EA) 
 reg,CL 8+4n 5+n 3 2 
 mem,CL 20+EA+4n 8+n 7 2-4 
(W88=28+EA+4n) 
 reg,immed8 - 5+n 3 3 
 mem,immed8 - 8+n 7 3-5 
SHLD/SHRD - Double Precision Shift (386+) 
 Usage: SHLD dest,src,count 
 SHRD dest,src,count 
 Modifies flags: CF PF SF ZF (OF,AF undefined) 
 SHLD shifts "dest" to the left "count" times and the bit positions 
 opened are filled with the most significant bits of "src". SHRD 
 shifts "dest" to the right "count" times and the bit positions 
 opened are filled with the least significant bits of the second 
 operand. Only the 5 lower bits of "count" are used. 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 192 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg16,reg16,immed8 - - 3 2 4 
 reg32,reg32,immed8 - - 3 2 4 
 mem16,reg16,immed8 - - 7 3 6 
 mem32,reg32,immed8 - - 7 3 6 
 reg16,reg16,CL - - 3 3 3 
 reg32,reg32,CL - - 3 3 3 
 mem16,reg16,CL - - 7 4 5 
 mem32,reg32,CL - - 7 4 5 
SLDT - Store Local Descriptor Table (286+ privileged) 
 Usage: SLDT dest 
 Modifies flags: none 
 Stores the Local Descriptor Table (LDT) Register into the 
 specified operand. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg16 - 2 2 2 3 
 mem16 - 2 2 3 5 
SMSW - Store Machine Status Word (286+ privileged) 
 Usage: SMSW dest 
 Modifies flags: none 
 Store Machine Status Word (MSW) into "dest". 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg16 - 2 10 2 3 
 mem16 - 3 3 3 5 
STC - Set Carry 
 Usage: STC 
 Modifies flags: CF 
 Sets the Carry Flag to 1. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 none 2 2 2 2 1 
STD - Set Direction Flag 
 Usage: STD 
 Modifies flags: DF 
 Sets the Direction Flag to 1 causing string instructions to 
 auto-decrement SI and DI instead of auto-increment. 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 193 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 none 2 2 2 2 1 
STI - Set Interrupt Flag (Enable Interrupts) 
 Usage: STI 
 Modifies flags: IF 
 Sets the Interrupt Flag to 1, which enables recognition of all 
 hardware interrupts. If an interrupt is generated by a hardware 
 device, an End of Interrupt (EOI) must also be issued to enable 
 other hardware interrupts of the same or lower priority. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 none 2 2 2 5 1 
STOS - Store String (Byte, Word or Doubleword) 
 Usage: STOS dest 
 STOSB 
 STOSW 
 STOSD 
 Modifies flags: None 
 Stores value in accumulator to location at ES:(E)DI (even if 
operand 
 is given). (E)DI is incremented/decremented based on the size of 
 the operand (or instruction format) and the state of the Direction 
 Flag. Use with REP prefixes. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 dest 11 3 4 5 1 (W88=15) 
STR - Store Task Register (286+ privileged) 
 Usage: STR dest 
 Modifies flags: None 
 Stores the current Task Register to the specified operand. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg16 - 2 2 2 3 
 mem16 - 3 2 3 5 
SUB - Subtract 
 Usage: SUB dest,src 
 Modifies flags: AF CF OF PF SF ZF 
 The source is subtracted from the destination and the result is 
 stored in the destination. 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 194 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg,reg 3 2 2 1 2 
 mem,reg 16+EA 7 6 3 2-4 (W88=24+EA) 
 reg,mem 9+EA 7 7 2 2-4 (W88=13+EA) 
 reg,immed 4 3 2 1 3-4 
 mem,immed 17+EA 7 7 3 3-6 (W88=25+EA) 
 accum,immed 4 3 2 1 2-3 
TEST - Test For Bit Pattern 
 Usage: TEST dest,src 
 Modifies flags: CF OF PF SF ZF (AF undefined) 
 Performs a logical AND of the two operands updating the flags 
 register without saving the result. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg,reg 3 2 1 1 2 
 reg,mem 9+EA 6 5 1 2-4 (W88=13+EA) 
 mem,reg 9+EA 6 5 2 2-4 (W88=13+EA) 
 reg,immed 5 3 2 1 3-4 
 mem,immed 11+EA 6 5 2 3-6 
 accum,immed 4 3 2 1 2-3 
VERR - Verify Read (286+ protected) 
 Usage: VERR src 
 Modifies flags: ZF 
 Verifies the specified segment selector is valid and is readable 
 at the current privilege level. If the segment is readable, 
 the Zero Flag is set, otherwise it is cleared. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg16 - 14 10 11 3 
 mem16 - 16 11 11 5 
VERW - Verify Write (286+ protected) 
 Usage: VERW src 
 Modifies flags: ZF 
 Verifies the specified segment selector is valid and is ratable 
 at the current privilege level. If the segment is writable, 
 the Zero Flag is set, otherwise it is cleared. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg16 - 14 15 11 3 
 mem16 - 16 16 11 5 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 195 
WAIT/FWAIT - Event Wait 
 Usage: WAIT 
 FWAIT 
 Modifies flags: None 
 CPU enters wait state until the coprocessor signals it has finished 
 its operation. This instruction is used to prevent the CPU from 
 accessing memory that may be temporarily in use by the coprocessor. 
 WAIT and FWAIT are identical. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 none 4 3 6+ 1-3 1 
WBINVD - Write-Back and Invalidate Cache (486+) 
 Usage: WBINVD 
 Modifies flags: None 
 Flushes internal cache, then signals the external cache to write 
 back current data followed by a signal to flush the external cache. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 none - - - 5 2 
XCHG - Exchange 
 Usage: XCHG dest,src 
 Modifies flags: None 
 Exchanges contents of source and destination. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg,reg 4 3 3 3 2 
 mem,reg 17+EA 5 5 5 2-4 (W88=25+EA) 
 reg,mem 17+EA 5 5 3 2-4 (W88=25+EA) 
 accum,reg 3 3 3 3 1 
 reg,accum 3 3 3 3 1 
XLAT/XLATB - Translate 
 Usage: XLAT translation-table 
 XLATB (masm 5.x) 
 Modifies flags: None 
 Replaces the byte in AL with byte from a user table addressed by 
 BX. The original value of AL is the index into the translate 
table. 
 The best way to discripe this is MOV AL,[BX+AL] 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 table offset 11 5 5 4 1 
Giáo trình vi xử lý Phụ lục – Tập lệnh 
 Trang 196 
XOR - Exclusive OR 
 Usage: XOR dest,src 
 Modifies flags: CF OF PF SF ZF (AF undefined) 
 Performs a bitwise exclusive OR of the operands and returns 
 the result in the destination. 
 Clocks Size 
 Operands 808x 286 386 486 Bytes 
 reg,reg 3 2 2 1 2 
 mem,reg 16+EA 7 6 3 2-4 (W88=24+EA) 
 reg,mem 9+EA 7 7 2 2-4 (W88=13+EA) 
 reg,immed 4 3 2 1 3-4 
 mem,immed 17+EA 7 7 3 3-6 (W88=25+EA) 
 accum,immed 4 3 2 1 2-3 

File đính kèm:

  • pdfgiao_trinh_vi_xu_ly_pham_hung_kim_khanh.pdf
Tài liệu liên quan