Introduction to Computer organization - PowerPoint PPT Presentation

1 / 77
About This Presentation
Title:

Introduction to Computer organization

Description:

Title: Introduction to Computer organization & Assembly Language Author: Thanawin Last modified by: ALASKA Created Date: 6/8/2004 4:09:19 PM Document presentation format – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 78
Provided by: Than82
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Computer organization


1
Introduction toComputer organization Assembly
Language
2
???????????
Hardware
Software
3
??????????????? Hardware ??? Software
USER
?????????????????
?????????????????
System Library
System Library
?????????????
??????????????????
4
Computer Components
HD
5
?????????????????????????????
  • ????????????????????????????????????????????
  • CPU (microprocessor)??????????????????????????
  • ???????????
  • ????????????? (Keyboard , Mouse , etc.)
  • CPU ??????????????
  • CPU ??????????????????????????????????????
  • ???????????
  • ??????????????? (Monitor , Printer , etc.)

6
??????????????????
  • ????????????????????????? ????????????????????????
    ????????????????????
  • ???????????????????????????????????????
    ??????????????????????????????????????????????????
    ??
  • ??????????????????????????????????????????????????
    ??????????????????????????????
  • ?????????????????? ??????? ???????????????????????
    ??????????????????????????????????????????????????
    ? ??????????????????????????
  • Programming Designing and writing a computer
    program.

7
????????????????????????????
  • There are 3 kind of programming languages
  • Machine language (0s and 1s)
  • Assembly language (mov, and, or, etc)
  • High-level language (nearly like human word)
  • Computer itself understands only Machine language.

8
The translation Process
Compiler /Interpreter
Executable Program
Source Program
9
Language translator
Interpreter / Compiler
main pushl ebp movl
esp, ebp subl 8, esp andl
-16, esp movl 0, eax
subl eax, esp subl 8, esp
pushl .LC0 ..
. 00011000110001110 00110001110101111 00011111111
110001 11011100001011011
Assembler
Program hello Begin writeln(Hello
world!) End.
Machine
Machine language
High-level language
Assembly language
Hello World! _
10
Compiler
  • Read all program at a time.
  • Translate into executable file (machine language)

library
Compiler
Linker
. writeln(a) writeln(b) writeln(c) .
object file
Source
a b c
. 0100100 0100101 0100101 .....
Exe file
11
Interpreter
  • Read high-level language , translate , and then
    execute one command at a time.

Inter- preter
a b c
. writeln(a) writeln(b) writeln(c) .
0100100
0100101
0100110
Source
12
Assembler
  • Turns assembly symbols into machine instructions
  • Process this step in microprocessor

a b c
Assembler
. 0100100 0100101 0100101 .....
mov A, B add B , A sub A, B
push A
13
???????????????????????????????
  • ?????
  • ?????????????????????????????????????
  • ???????????????????????????????????????
  • ?????????????????????????????????????????????
  • ???????
  • ??????????????????
  • ?????????????????
  • ???????????????????????????? ???? Array
  • ?????????????????????????????????????????????????
    CPU ???

14
????????????????????????
  • ?????????????? (Analysis)
  • ??????????????????????????
  • ??????????????????????????????
  • ???????????????????????????????????????
  • ???????????? (Implementation)
  • ???????????????????????????????
    ??????????????????????????????????????????
  • Compile ??????????????????????????????????????????
    ?????
  • ????????????????????????? (Testing Debugging)
  • ?????????????????????????????????
  • ????????????????????????? ?????????????
  • ??????????????????????????? ??????????????????????
    ????????

15
??????????? Microprocessor
  • Intel Zilog Motorolla
  • 4004
  • 8080 Z80 6800
  • 8086,8088 Z8000 68000
  • 80286 Z80000 6802
  • i386 Z80180 68030
  • i486 68040
  • Pentium

16
???????????????????????????????
17
???????????????????????????
HD
18
???????????????????????????
Memory Unit
Central Processing Unit
Output Unit
Input Unit
19
??????????? CPU
  • ?????????????????? CPU
  • ?????????? (Fetch)
  • ?????? (Decode)
  • ???????? (Excute)
  • CPU ??????????????????????????????????????????????
    ???????????? ????? Stored Program Architecture
    ???? Von Neumann Architecture
  • ????????? CPU ?????????? Opcode ??? Operand
  • Opcode ????????????????????????
  • Operand ?????????????????????????

20
???????????
  • ??? ?????????????????????????????????
  • ???? 8 ??? ?????????????????????????????????????
    ?????????
  • ????????????????????????????????????? ???????
    Address
  • ?????? 2 ???? ???? 16 ???
  • ?????????????? 4 ???? ???? 32 ???
  • ???????? 4 ??? ???? 1/2 ????
  • ?????????????????????????????
  • ????????????????????????????? ????????????????????
    ???????????????

21
????????????????????????????????
22
??????????????????
  • ?????????????????????????????????????????????????
    ??????????????? ???
  • ??????????????????????????????? 3 ?????
  • - ?????????
  • - ?????????? ???? ??????????
  • - ?????????

23
?????????????????? ?????????????????????? 80x86
  • 4040 4 ???
  • 8080 8 ???
  • 8086 16 ??? ?????????????????? 1 MB
  • 8088 ????? 16 ??? ??????????????? 8 ???
    ???????????? Z80
  • 80186 ????????????????????????????????????????????
    ???
  • 80286 16 ??? ?????????????????? 16 MB
    ???????????????????????????? ??????????? ??
    Virtual Memory
  • 80386 32 ??? ?????????????????? 4 GB
    ??????????????????????? ???????????
    ?????????????????????????????????????????? ?????
    ????????????????
  • 80386SX ????????? 32 ??? ?????????? 16 ???
  • 80486 ???????????????????????????????
  • Pentium ??????????????????????????????

24
?????????????? 8086
  • 8086 ???????????????? 20 ???
  • ?????????????? 220 ????????????? (
    ?????????????? 1 MB )
  • ??????????? 20 ?????? ????????????????????
    (physical address) ????????????????
    ?????????????????? ????????????????????? 220
    ?????
  • 8086 ??????????? 16 ???
  • ?????????????????????????? (????????????? 20 ???)
  • ????????????????? 2 ???????????????????
  • ?????????????? ???????? ???????
  • ????????????????????????????????????? ?
    ????????????????????? segment
    ?????????????????????????????? offset

25
??????????????????
20100005
26
????????????????? ???????? ???????
  • ???????????????????? ???????? ??????? ????
  • physical address
  • ???????????????????? ????????? 4 ??? (-gt ??????
    20 ???)
  • ????????????????????
  • ???????????????????????????? offset ??? 0000h
    ????? FFFFh 16 ???
  • ?????????????? 64 KB 65536 bytes
  • ?????????????????????????? ?
  • ??????????? 0000h ??????????? physical address
    00000h ?????????? 0FFFFh
  • ??????????? 0001h ??????????? physical address
    00010h ?????????? 1FF0Fh
  • ??????????? 0002h ??????????? physical address
    00020h ?????????? 1FF1Fh

27
??????????????????
  • CS Code segment ???????????????????????????????
    ??
  • DS Data segment ???????????????????????????????
    ?
  • ES Extra segment ??????????????????????????????
    ?????? ?
  • SS Stack segment ??????????????????????????
    stack

28
????????????? 16 ??? ??? 8 ???
AX (Accumulator Register)
BX (Base Register)
CX (Counter Register)
DX (Data Register)
29
??????????????????????????????? 8086
  • ALU ?????? 16 ??? ?????????? 8086 ??????? CPU
    16 ???
  • ??????????
  • ???????????????? (General-Purpose Registers)
  • 16 ??? AX BX CX ??? DX
  • 8 ??? AH AL BH BL CH CL DH ??? DL
  • ?????????????????? (Segment Registers)
  • ?????? 16 ??? CS DS ES ??? SS
  • ??????????????????????? (Index Registers)
  • ?????? 16 ??? SI ??? DI

30
??????????????????????????????? 8086
  • ??????????
  • ????????????????????? (Pointer Registers)
  • ?????? 16 ??? BP ??? SP
  • ????? (Flags)
  • ??????????????????????????
  • ?????????????? ? ??????????????????????????????
  • IP (Instruction Pointer) ???????????????????????
    ??
  • IR (Instrcution Register) ??????????????????
  • etc.

31
??????????
32
?????????????
???????????
33
???????????????
34
???????????????
  • ??????? (Carry flag) ??????? 1 ???????????????????
    ??????
  • ???????????? (Parity flag) ??????? 1
    ??????????????????????????????????????????????????
    1 ??????????
  • ????????? (Auxiliary flag) ??????? 1 ??? 4
    ??????????????????????????????????????
  • ?????????? (Zero flag) ??????? 1
    ???????????????????????????????????
  • ???????????????? (Sign flag) ??????? 1
    ???????????????????????????
  • ??????????? (Trap flag) ???????????? 1
    ???????????????????????????????????????
    ??????????????????? (single step)
    ????????????????????????
  • ?????????????????? (Interrupt Enable flag)
    ???????????? 1 ???????????????????????????????????
    ?????
  • ??????????? (Direction flag) ???????????? 1
    ??????????????????????????????????????????????????
    ????????????????????? ???????????? 0
    ???????????????????????????????????????????????
  • ??????????????? (Overflow flag)
    ????????????????????????????? ???????????? 1
    ??????????????????????????????????????????????????
    ???????????????????

35
??????????????????
  • ?????????????????? (Addressing Mode) ????????????
    CPU ????????????? ???????? 3 ?????
  • ??????????????? ??????????
  • ??????????????????????????
  • ???????????????????????????????

36
????????????
  • ????????????????????????????????????????????????
    ???????????????????????????????????
    ????????????????????? CPU ????????????????????????
    ?????????
  • ???????? ???? ????????????????????????????????
    ????????????????????????? ???????
  • ?????????????????????????????
  • ????????? ??????????????????????
  • ?????????????????????????????????????????????????
    ?????????????????????? CPU
  • ????????? ??????????????????????
  • ????????????????????????????? (system library)

37
?????????????????????????????????????
  • ?????????????????????????????
  • ???????????????? RISC
  • ?????????????? ????????
  • ????????????????????????????
  • ???????????????
  • ??????????????

Memory
CPU
cache
38
????????????????
39
??????????????????????
  • ?????? MOV
  • ??????????????????????????????????????????????
  • ??????????????????????????????
  • ?????????????????????????????????
  • ?????? MOV ??????? , ??????
  • MOV reg,reg
  • MOV reg,mem
  • MOV mem,reg
  • MOV reg,imm
  • MOV mem,imm

reg ?????????? mem ??????????????????
imm immediate (????????)
40
????????????????? MOV
  • ???????????????????????????????????????
  • ???????????????????
  • ??????????????????????????????????????????
  • ???????? (immediate) ?????????????????????????????
  • ??????????????????????????????????????????????????
    ???????????????

41
???????????????????? MOV
  • MOV AX,100h
  • MOV BX,AX
  • MOV DX,BX
  • MOV AX,1234h
  • MOV DX,5678h
  • MOV AL,DL
  • MOV BH,DH
  • MOV AX,1000h
  • MOV 100h,AX
  • MOV BX,100h

42
???????????????????? MOV
  • MOV BYTE PTR 200h,10h
  • MOV WORD PTR 300h,10h
  • MOV AX,2300h
  • MOV DS,AX

43
?????????????????????????????????
  • ??????????????????????????????????????????????????
    ????????????????????????????
  • ????????????? 16 ??? ??? 8 ???

MOV AX,1000h MOV AL,3Ah MOV AH,AL MOV AX,234h
44
??????????????????????????????
  • ???????????????????????????
  • ????????? ????????????????????????????????????????
    ?????????????????? ??????????????????????????????
    ??????????????????? ????????????????????
    ???????????????????????????????????????????????
    DS ???????
  • ????????

MOV AX,6789h MOV DX,1234h MOV 100h,AX MOV 102h
,DX MOV 104h,AH MOV 105h,DL MOV BX,104h MOV
CX,103h MOV 106h,CL
45
MOV AX,6789h MOV DX,1234h MOV 100h,AX MOV 102h
,DX MOV 104h,AH MOV 105h,DL MOV BX,104h MOV
CX,103h MOV 106h,CL
67h
34h
46
??????????????????????????????
  • ????????????????????????????????????????
  • ??????????????????????????????????????????????????
    ??? 16 ??? ???????????????????????????????????????
    ?????????????????????????????????????????????
    ??????????????????????????????????????????????????
    ????
  • ?????????????????????????? little endian
    ????????????????????????????????????????????
    Intel
  • ????????????????????????????? SPARC ???? MIPS
    ??????????????????????????????????????????????????
    ??????? big endian

47
??????????????????????????????
  • ??????????????????????????????????????????????????
    ?????????????? BX

AX ?
MOV AX,102h MOV BX,100h MOV CX,4004h MOV DX,1201h
MOV BX,AX MOV BX2,CX MOV BX3,DX MOV BX4
,BX MOV BX,102h MOV AX,BX
48
????????????????????????????
  • ???????????????????????
  • ?????????????????????????????????????
  • 16 ??? (?????? 0010h) ????
  • 8 ??? (?????? 10h)
  • ??????????????????????????????????????????????????
    ??????????????????
  • ?????????????????????????????????????

MOV 100h,10h
MOV WORD PTR 100h,10h MOV BYTE PTR 100h,10h
MOV 100h,AX
49
DEBUG
50
?????????????????????? DEBUG
  • ?????? ? ????????????????
  • ?????? R (register) ???????????????????
  • ?????? D (dump) ????????????????????
  • ?????? A (assemble) ?????????????? DEBUG
    ??? ?????????????????????????
  • ?????? U (unassemble) ?????????????? DEBUG
    ???? ??????????????????????????????

51
?????????????????????? DEBUG
  • ?????? T (trace) ??????????????????????????? 1
    ??????
  • ?????? P (proceed) ?????????????????????????????
    ?
  • ??????????????????????????????????????????????????
    ??????????
  • ?????? G (go) ???????????????????????????????

52
??????????????????????????? DEBUG
  • ??????? DEBUG ????????????????????????????????????
    ? windows
  • ?????????? ? ????????? DEBUG ???????????? 16
    ??????? ???????????? h ??????????????
  • ???????????????????????????????????????? CSIP
    ???? ???????????????????????????????????????????
    RCS ??? RIP
  • ????????????? (a) , ????????????? (u)
    ????????????????????? (d) ????????????????????????
    ????????????????????????????????????
    ????????????? IP ?????????????????????????????????
    ? offset ???????????? ???? a 100 ???????
  • ??????????????????????????????????????????????
    segmentoffset ???? ??????????????????????????????
    ???????????????????????????????

53
????????????????????????
54
??????????????
  • ?????
  • ????????????????
  • ??????????????????????????
  • ???????????????????????????
  • ??????????????????????????????????????????????
  • ????????????????????????????????

55
???????????????
  • ????? ???????????????????????????????????
  • ???????? 8086 ?????? 16 ??? ??????????????????????
    ???? ???????
  • ??????????????????????????????????????????????????
    ????????????????????????????????????????????

56
???????????????
  • ??????? (Carry flag) ??????? 1 ???????????????????
    ??????
  • ???????????? (Parity flag) ??????? 1
    ??????????????????????????????????????????????????
    1 ??????????
  • ????????? (Auxiliary flag) ??????? 1 ??? 4
    ??????????????????????????????????????
  • ?????????? (Zero flag) ??????? 1
    ???????????????????????????????????
  • ???????????????? (Sign flag) ??????? 1
    ???????????????????????????
  • ??????????? (Trap flag) ???????????? 1
    ???????????????????????????????????????
    ??????????????????? (single step)
    ????????????????????????
  • ?????????????????? (Interrupt Enable flag)
    ???????????? 1 ???????????????????????????????????
    ?????
  • ??????????? (Direction flag) ???????????? 1
    ??????????????????????????????????????????????????
    ????????????????????? ???????????? 0
    ???????????????????????????????????????????????
  • ??????????????? (Overflow flag)
    ????????????????????????????? ???????????? 1
    ??????????????????????????????????????????????????
    ???????????????????

57
?????????? (Zero-flag)
  • ??????????? 1 ?????????????????????????????
  • ???????????????????????? 0

MOV AL,10h ADD AL,E0h ADD AL,20h SUB AL,10h SUB AL
,10h
Z? Z1 Z0 Z0 Z1
AL0 AL20h AL10h AL0
58
???????????? (Parity-flag)
  • ??????????? 1 ????????????????????????????????????
    ?????????????

MOV AL,14h ADD AL,20h ADD AL,10h SUB AL,8h SUB AL,
10h
P? P0 P1 P1 P0
AL34h AL44h AL3Ch AL2Ch
59
??????? (Carry-flag)
  • ??????????? 1 ????????????????????????????????
  • ?????????????????????????????????

MOV AL,77h ADD AL,50h ADD AL,50h SUB AL,A0h ADD AL
,27h
C? C0 C1 C1 C0
ALC7h AL17h AL77h AL9Eh
60
???????????????? (Sign-flag)
  • ??????????? 1 ???????????????????
  • ??????????????????????????????

MOV AL,77h ADD AL,50h ADD AL,50h SUB AL,A0h ADD AL
,27h
S? S1 S0 S0 S1
ALC7h AL17h AL77h AL9Eh
61
???????????????? (Overflow-flag)
  • ??????????? 1 ????????????????????????????????????
    ????????
  • ??????????????????????????????
  • ??????????????????????????????????????????????????
    ?????????????? ???????????????????????????????????
    ???????????

MOV AL,77h ADD AL,50h ADD AL,50h SUB AL,A0h ADD AL
,27h
O? O1 O0 O0 O1
ALC7h AL17h AL77h AL9Eh
62
????????? ?
  • ?????????? (Auxiliary-flag)
  • ??????????? 1 ????????????????????????????????????
    ??????????? BCD
  • ??????????? (Direction-flag)
  • ??????????????????????????????????????????????????
    ?????????.
  • ????????? (Trap-flag)
  • ?????????????????????????????????????
    ??????????????????????????????????????????????????
    ??????????
  • ?????????????????? (Interrupt-flag)
  • ??????????????????????????????????????????????????
    ?????????????????????????????

63
????????????????????????????
  • ?????????????????????????????? ???????????????????
    ??????????????????????
  • ??????????????????????????? 1 ????????????????
    (flag set) ????????????????????????? 0 ???
    ???????????????? (flag cleared)
  • ????????????????????????? ??????????????????????

64
????????????????
  • ??????????????????? INC ??? DEC
  • ????????? ADD ??? ADC
  • ???????? SUB ??? SBB
  • ????????????????? CMP
  • ????????????????????? NEG
  • ????????? MUL ??? IMUL
  • ????????? DIV ??? IDIV
  • ???????????????????? CBW ??? CWD

65
?????????????? INC ?????????????? DEC
  • ??????????????????????????????????????????????????
    ??????
  • ????????????????????????????????????? ??????
    ???????

MOV AL,1 DEC AL DEC AL MOV BX,200h MOV BX,AL INC
BYTE PTR BX
AL0h ALFFh 200hFFh 200h00h
66
???????????? ADD ??? ADC (add with carry)
ADD regs,regs ADD regs,mem ADD mem,regs ADD
regs,imm ADD mem,imm
ADC regs,regs ADC regs,mem ADC mem,regs ADC
regs,imm ADC mem,imm
  • ??????????????????????????????????????????????????
  • ?????? ADD ??? ADC ???????????????????????????????
    ?????
  • ???????????????? ADC ?????????????????????????????
    ???????????????????? ??????????????
    ???????????????????????????????????????????????

67
??????????? SUB ??? SBB (sub with borrow)
SUB regs,regs SUB regs,mem SUB mem,regs SUB
regs,imm SUB mem,imm
SBB regs,regs SBB regs,mem SBB mem,regs SBB
regs,imm SBB mem,imm
  • ?????? SUB ???????????????????????????????????????
    ?? ????????????????????????????????
  • ?????? SBB ?????????????????? ????????????????????
    ????????????? Carry-flag ???? (????? ADC)
  • ?????? SUB ??? SBB ???????????????????????????????
    ?????

68
????????????????????????????
  • ????????? 32 ??? 34DA 1115h ????????????? 32
    ????????????????????????? CX,BX

?? 34DA 115h ?????? DX,AX ??? 16 ??????? ??? 16
???????????????
  • ???????? 16 ??? ???????????? AX ??????? 8
    ??????????????? BL

?? 8 ??????? ?? 8 ????????????????
69
????????????????? CMP
  • ?????? CMP ??????????????????? SUB
    ????????????????????????????????????????????????
    ?????????????????????????? Flag
  • ?????????????? flag ????????? CMP
    ????????????????? SUB
  • ????????????????????? CMP ????????????????
    ???????????

MOV AX,10h CMP AX,100h MOV BL,10h CMP AL,BL
Z-flag 0, C-flag 1, O-flag 0, S-flag 1.
Z-flag 1, C-flag 0, O-flag 0, S-flag 0.
70
????????????????????? NEG
NEG regs NEG mem
  • ?????? NEG ????????????????????????????????????
  • ?????????????????????????? 2s complement
  • ?????? NEG ???????????????????????????????????????
    ????????? ??????????????????????????????????????
    ?????????????

71
??????????????????????????
Instruction Result Z-Flag C-Flag P-Flag S-Flag O-Flag
MOV AL,70h
ADD AL,20h
ADD AL,70h
DEC AL
ADD AL,5
ADD AL,30h
SUB AL,40h
SUB AL,7F
NEG AL
ADC AL,20h
72
????????? MUL ??? IMUL
IMUL regs IMUL mem
MUL regs MUL mem
  • ????????????????? ????????????????????????????
    ??????????????????????????????????????????????????
    ?????? ?????????????????????????
  • ?????? 8 ??? ??????? AL ??????? AX
  • ?????? 16 ??? ??????? AX ??????? DX,AX
  • ?????? MUL ?????????????????????????
  • ?????? IMUL ??????????????????????
  • ??????????????????????????? ??????????????????????
    ????????????

73
???????????????????????
  • ????????? 12h ???? ????? BL

???????????????????? ??????? BL ????????????? AX
MOV AL,12h MUL BL
74
????????? DIV ??? IDIV
IDIV regs IDIV mem
DIV regs DIV mem
  • ??????????????????????????? ??????????????????????
    ?????? ???????????????????????????????????????????
    ??????? ?????????????????????????
  • ?????? 8 ??? ??????? AX ??????? AL ???
    AH
  • ?????? 16 ??? ??????? DX, AX ??????? AX
    ??? DX
  • ?????? DIV ?????????????????????????
  • ?????? IDIV ??????????????????????
  • ????????????????????????????????????????????????.

75
????????????????????
  • ?????????????????????????? ??????????????????????
    0 ????????????????????????????????????????????
    ??????????????????????????????????
  • ??????????????????????????????????????????????????
    ??????????????? ??????????????????????????????
  • ?????? CBW ??????????????????????????????????? AL
    ????????? 16 ????? AX
  • ?????? CWD ??????????????????????????????????? AX
    ????????? 32 ????? DX,AX

???? AL -gt AX. ??????? BL ????????????? AL
76
????????????????????????????????
  • 1. ???????? AL2 BL2 ???????????????????????????
    ?????????????????????? 16 ??? ???????
    ?????????? AX

????? ALAL ?????????????? CX ????????? AL
????????????????? ??? BL ??? BL
????????????????????? AX ???????????????????
ALAL ????????? CX ?????
2. ???????? (CLBLDX)/SI ???????????????????????
????
77
????????????????????????????????
2. ???????? (CLBLDX)/SI ???????????????????????
????
????? CLBL ?????? DX. ???????????? 32
??? ??????? SI ????????? AX ?????? DX
Write a Comment
User Comments (0)
About PowerShow.com