Professional Documents
Culture Documents
Computer Basic
Computer Basic
Computer Basic
CPU
CPU
CPU
CPU
RLE
RLE
DLL
_stdcall
Windows CPU
API
FreeBSD Port
Java
BIOS
Windows
32
API
GUI
WYSIWYG
IN OUT
DMA
CPU
- CPU
CPU
CPU
CPU
CPU
CPU
CPU RAM CPU
CPU CPU
C
CPU
CPU ALU
ALU
CPU
/ I/O CPU CPU
CPU
CPU
CPU 20 - 100
CPU
CPU CPU
CPU
CPU
CPU
CPU
CPU
hhhh
C
C++ Java
1 mov eax, dword ptr [ebp-8] /* eax */
2 add eax, dword ptr [ebp-0Ch] /* eax */
3 mov dword ptr [ebp-4], eax /* eax */
assembly (memonic)
mov,add
move addition
CPU
CPU
CPU
(Program Counter)
PC
PC 1
123 456
0100 Windows
0100 1
CPU
+1
overflow
parity check
CPU
call return
call
return return MyFun
0154 MyFun 0154
call
return
00000000 - FFFFFFFF
32
: a[0] - a[4] [] 0-4
CPU
CPU
· CPU 5
CPU
Write Back WB
“ ” CPU
Memory CPU
CPU CPU
CPU
512M
IC
RAM
ROM ROM
IC IC
IC
IC
VCC GND A0 - A9 D0 - D7 RD WR
VCC GND
0 1 +5V 1 0V 0
IC D0 - D7
8 bit = 1 byte A0 - A9
00000 00000 - 11111 11111 2 10 = 1024 1 byte
IC 1 KB
IC IC
IC
IC 1byte
RD WR WR RD 0
1
1KB
1 //
2 char a;
3 short b;
4 long c;
5
6 //
7 a = 123;
8 b = 123;
9 c = 123;
a,b,c 123
32 64
char 1 1
short int 2 2
int 4 4
unsigned int 4 4
float 4 4
double 8 8
long 4 8
long long 8 8
unsigned long 4 8
char short long
[value]
1 char g[100];
2 short h[100];
3 long i[100];
1 1
push
pop
1 //
2 Push(123);
3 Push(456);
4 Push(789);
5
6 //
7 j = Pop();
8 k = Pop();
9 l = Pop();
1 //
2 EnQueue(123);
3 EnQueue(456);
4 EnQueue(789);
5
6 //
7 m = DeQueue();
8 n = DeQueue();
9 o = DeQueue();
EnQueue() DeQueue()
FIFO
(ring buffer)
6
p[2]
p[2] p[2] p[1]
p[2]
50
50 50
IC CPU IC
CPU
CPU
CPU IC IC
CPU IC (Integrated
Circuit)
IC
IC IC : 0V 5V IC
0 1 0 1
0 1 10 11 100 101
IC
(bit) 8 16 32 64
8 8 8
8 8 bit
1 8 8
(= ) 0
100111 6 0 00100111 16
0000 0000 0010 0111
32 64 32 4 64
8
00100111
*
00100111 39 39 3 9
3 * 10 + 9 * 1 10 , 1
7 6 5 4 3 2 1 0 2 7 2 6
2 2 10
-1 1-1=0 2-1=1
0 1 2
* 3 * 10 + 9 *
1 = 39
2
39 39 0010 0111 <<
0100 1110 78
78 39 2 0010 0111 1001 1100
156
>>
1/2 1/4 39
0 1
0 1
0 1 -1
1 0000 0001 -1 1000
0001
+1
-1
(0 ---> 1 , 1 --->
0) +1
1-1
1000 0001 ( 1
)
1-1
1111 1111
1-1
+1
0
3-5
3-5
C unsigned
short short 2
short -32768 - 32767 unsigned short 0-
65536
-32768 32767 0 0~
32767 32768 0 1 -1 ~ -32768 32768 0 0
0
1 0
(0 1)
1
1/2,1/4,1/8 0
-4
-4 63 1/4
-1 1/4
0
8 16 32
0111 1111 8 16 0000 0000
0111 1111 1111 1111
1111 1111 1111 1111 0
1
0 1
0 1 (NOT ) (AND
) (OR ) (XOR )
0 1 1 0
" 1 1 0"
" 1 1 0"
" 1 0 1 0"
ON/OFF
100 MB
100 MB
JPEG
1 8 256 0000
0000 - 1111 1111
compaction algorithm
JPEG/MPEG
Huffman
JPEG
MPEG
MP3/RM/VCD/DVD /
≤50 ms / / / CPU/DSP
JPEG2000
MPEG-2/4
RLE
AAAAAABBCDDEEEEEF 17
RLE
1 17
17
*
AAAAAABBCDDEEEEEF 17 A6B2C1D2E5F1 12
12 / 17 = 70% 70%
* RLE(Run Length
Encoding, ) RLE
RLE
RLE
RLE
RLE
ABCDEFGHIJKLMNOPQRSTUVWXYZ 26 26
RLE
A1B1C1D1E1F1G1H1I1J1K1L1M1N1O1P1Q1R1S1T1U1V1W1X1Y1Z1 52
RLE
1 1 (8 )
A 100 Q 3
8 8 A Q
8 100 *8 +3 *8 = 824 A 2 Q 10
2 * 100 + 3 * 10 = 230
1 ( ) 11
( )
1
11 E 1 C
9 110101101 1 3
1 AAAAAABBCDDEEEEEF
00
14 / 17 = 82%
AAAAAABBCDDEEEEEF
AAAAAABBCDDEEEEEF A-F
A 6 0 1
E 5 1 1
B 2 10 2
D 2 11 2
C 1 100 3
F 1 101 3
1
2 3 100 3
1 0 0 E A A 10 0 B A 100 C
AAAAAABBCDDEEEEEF
000000000000 100100 110 101101 0101010101 111 40 =5 17
5 = 5 / 17 = 29%
BMP Windows
JPEG
TIFF: " "
GIF 256
RLE
JPEG GIF
2000
hard disk
---
CPU
CPU
Windows
Windows 95/98
web
web web
web
WINDOWS
PAGEFILE.SYS
5MB
10MB CPU
swap
CPU
Windows
DLL
DLL Dynamic Link Library
Library DLL
DLL
MyFunc() A B
MyFunc() Static Link
DDL
_stdcall
_stdcall C
_stdcall
_stdcall standard call( ) Windows DLL
_stdcall C
_stdcall C C C _stdcall C
C _stdcall
C Java C
1 //
2 void main(){
3 int a;
4 a = MyFunc(123,456);
5 }
6
7 //
8 int MyFunc(int a,int b){
9 ...
10 }
C push pop
32 CPU 1 push 4 32
push 8 call
add esp,8 esp 8
8
C
_stdcall
CPU
Windows
Windows 512
Windows 1
512 1 =1 1KB 1 =2 2KB 4KB 8KB 16KB 32KB( 1 = 64
)
1 1
= +
wow
CPU
CPU
Graphic Processing Unit GPU
5GB
CPU
CPU
CPU CPU
(native code) C (
)
CPU
Windows CPU
CPU I/O
WIndows Windows
I/O Windows
Windows
API
API
API CPU
FreeBSD Port
“ CPU
” Unix FreeBSD
Ports FTP
FreeBSD Ports
FreeBSD Ports
16000
FreeBSD C C FreeBSD
Virtual Machine
Java
Java Java
Java
Java
BIOS
BIOS(Basic
Input/Output System) BIOS ROM
BIOS
CD-ROM
BIOS
OS OS OS
Microsoft Word
Microsoft Excel
Windows
= +
( )
ADD MOV
bug
Windows C
time() printf()
1 #include <stdio.h>
2 #include <time.h>
3
4 void main(){
5 //
6 time_t tm;
7
8 //
9 time(&tm);
10
11 //
12 printf("%s\n", ctime(&tm));
13 }
time_t tm time_t
time(&tm)
printf("%s\n" ctime(&tm))
CPU
time() printf()
IC I/O
(Real-time clock) IC
OS
time()
printf()
C Windows
Linux
1 #include <stdio.h>
2
3 void main(){
4
5 //
6 FILE *fp = fopen("MyFile.txt","w");
7
8 //
9 fputs(" ", fp);
10
11 //
12 fclose(fp);
13 }
C fputs() fclose()
I/O
fopen() MyFile.txt
w fputs() " " fp fclose()
fp
fp fp fopen()
fopen() fopen()
fputs() fclose() fclose()
Windows
Windows Windows
Windows Windows
Windows 32 64
API
32
32 Windows 32
MS-DOS 16 16 32
32 32 windows
32
64 64
API
Windows API API
Application Programming Interface ,
GUI
GUI(Graphical User Interface)
Linux
WYSIWYG
WYSIWYG Windows
WYSIWYG
WYSIWYG
Windows WYSIWYG
Windows
CPU
CPU
Windows ( )
(Plug-and-Play) (plug)
DLL DLL API
API
CPU ( ) C
CPU
add(addition)
cmp(compare)
C CPU
C
C
C
https://wenku.baidu.com/view/22e2f418650e52ea55
1898ad.html
Windows
1 //
2 int AddNum(int a,int b){
3 return a + b;
4 }
5
6 // AddNum
7 void MyFunc(){
8 int c;
9 c = AddNum(123,456);
10 }
Sample4.c C .c
Windows Sample4.c
1 bcc32 -c -S Sample4.c
Sample4.asm
.asm Sample4.asm
1 .386p
2 ifdef ??version
3 if ??version GT 500H
4 .mmx
5 endif
6 endif
7 model flat
8 ifndef ??version
9 ?debug macro
10 endm
11 endif
12 ?debug S "Sample4.c"
13 ?debug T "Sample4.c"
14 _TEXT segment dword public use32 'CODE'
15 _TEXT ends
16 _DATA segment dword public use32 'DATA'
17 _DATA ends
18 _BSS segment dword public use32 'BSS'
19 _BSS ends
20 DGROUP group _BSS,_DATA
21 _TEXT segment dword public use32 'CODE'
22 _AddNum proc near
23 ?live1@0:
24 ;
25 ; int AddNum(int a,int b){
26 ;
27 push ebp
28 mov ebp,esp
29 ;
30 ;
31 ; return a + b;
32 ;
33 @1:
34 mov eax,dword ptr [ebp+8]
35 add eax,dword ptr [ebp+12]
36 ;
37 ; }
38 ;
39 @3:
40 @2:
41 pop ebp
42 ret
43 _AddNum endp
44 _MyFunc proc near
45 ?live1@48:
46 ;
47 ; void MyFunc(){
48 ;
49 push ebp
50 mov ebp,esp
51 ;
52 ; int c;
53 ; c = AddNum(123,456);
54 ;
55 @4:
56 push 456
57 push 123
58 call _AddNum
59 add esp,8
60 ;
61 ; }
62 ;
63 @5:
64 pop ebp
65 ret
66 _MyFunc endp
67 _TEXT ends
68 public _AddNum
69 public _MyFunc
70 ?debug D "Sample4.c" 20343 45835
71 end
segment ends
end
CPU +
Give me money
Give me money
Give me,money
CPU
CPU
CPU
CPU
CPU x86
x86 CPU
CPU
mov
mov mov
( )
([]) ([])
1 mov ebp,esp
2 mov eax,dword ptr [ebp+8]
push pop
stack
push pop
32 x86 CPU 1 push pop
32 4
C
MyFunc AddNum
MyFunc
Sample4.c
c MyFunc
AddNum c
AddNum
AddNum
Sample4.c AddNum
AddNum
C
1 //
2 int a1 = 1;
3 int a2 = 2;
4 int a3 = 3;
5 int a4 = 4;
6 int a5 = 5;
7
8 //
9 int b1,b2,b3,b4,b5;
10
11 //
12 void MyFunc(){
13 //
14 int c1,c2,c3,c4,c5,c6,c7,c8,c9,c10;
15
16 //
17 c1 = 1;
18 c2 = 2;
19 c3 = 3;
20 c4 = 4;
21 c5 = 5;
22 c6 = 6;
23 c7 = 7;
24 c8 = 8;
25 c9 = 9;
26 c10 = 10;
27
28 //
29 a1 = c1;
30 a2 = c2;
31 a3 = c3;
32 a4 = c4;
33 a5 = c5;
34 b1 = c6;
35 b2 = c7;
36 b3 = c8;
37 b4 = c9;
38 b5 = c10;
39 }
Borland C++
1 _DATA segment dword public use32 'DATA'
2 align 4
3 _a1 label dword
4 dd 1
5 align 4
6 _a2 label dword
7 dd 2
8 align 4
9 _a3 label dword
10 dd 3
11 align 4
12 _a4 label dword
13 dd 4
14 align 4
15 _a5 label dword
16 dd 5
17 _DATA ends
18
19 _BSS segment dword public use32 'BSS'
20 align 4
21 _b1 label dword
22 db 4 dup(?)
23 align 4
24 _b2 label dword
25 db 4 dup(?)
26 align 4
27 _b3 label dword
28 db 4 dup(?)
29 align 4
30 _b4 label dword
31 db 4 dup(?)
32 align 4
33 _b5 label dword
34 db 4 dup(?)
35 _BSS ends
36
37 _TEXT segment dword public use32 'CODE'
38 _MyFunc proc near
39
40 push ebp
41 mov ebp,esp
42 add esp,-20
43 push ebx
44 push esi
45 mov eax,1
46 mov edx,2
47 mov ecx,3
48 mov ebx,4
49 mov esi,5
50 mov dword ptr [ebp-4],6
51 mov dword ptr [ebp-8],7
52 mov dword ptr [ebp-12],8
53 mov dword ptr [ebp-16],9
54 mov dword ptr [ebp-20],10
55 mov dword ptr [_a1],eax
56 mov dword ptr [_a2],edx
57 mov dword ptr [_a3],ecx
58 mov dword ptr [_a4],ebx
59 mov dword ptr [_a5],esi
60 mov eax,dword ptr [ebp-4]
61 mov dword ptr [_b1],eax
62 mov edx,dword ptr [ebp-8]
63 mov dword ptr [_b2],edx
64 mov ecx,dword ptr [ebp-12]
65 mov dword ptr [_b3],ecx
66 mov eax,dword ptr [ebp-16]
67 mov dword ptr [_b4],eax
68 mov edx,dword ptr [ebp-20]
69 mov dword ptr [_b5],edx
70 pop esi
71 pop ebx
72 mov esp,ebp
73 pop ebp
74 ret
75
76 _MyFunc endp
77 _TEXT ends
_DATA
_BSS
call A A
cmp A,B A B
inc A A +1
ige cmp
jl cmp
jle cmp
jmp cmp
mov A,B B A
pop A A
push A A
ret
xor A,B A B A
_BSS b1 - b5 _b1 -
_b5 db 4dup(?) 4 ?
db(define byte) 1 1 db 4 dup(?) 4
db 4 dup(?) dd 4 4 1 db 4
(=4 ) 4
10
c1 - c10
Borland C++
1 mov eax,1
2 mov edx,2
3 mov ecx,3
4 mov ebx,4
5 mov esi,5
x86 CPU
c1 - c5
5 c6 - c10
1 // MySub
2 void MySub(){
3 //
4
5 }
6
7 // MyFunc
8 void Myfunc(){
9 int i;
10 for(int i = 0;i < 10;i++){
11 // MySub
12 MySub();
13 }
14 }
i MySub
XOR a b 1 a b
0
XOR 0 XOR 1
0 01010101 01010101 XOR
0
i++ i +1
++i +1
jl cmp ebx,10 jl
jump on less than( ) i 10 @4
1 i ^= i;
2 L4: MySub();
3 i++;
4 if(i < 10) goto L4;
i ^= i i i XOR MySub() L4
i i 10 MySub()
cmp C
1 // MySub1
2 void MySub1(){
3
4 //
5 }
6
7 // MySub2
8 void MySub2(){
9
10 //
11 }
12
13 // MySub3
14 void MySub3(){
15
16 //
17 }
18
19 // MyFunc
20 void MyFunc(){
21
22 int a = 123;
23 //
24 if(a > 100){
25 MySub1();
26 }
27 else if(a < 50){
28 MySub2();
29 }
30 else
31 {
32 MySub3();
33 }
34
35 }
C Borland C++
C
Java Java native
C Java
bug
CPU
1 //
2 int counter = 100;
3
4 // MyFunc1()
5 void MyFunc(){
6 counter *= 2;
7 }
8
9 // MyFunc2()
10 void MyFunc2(){
11 counter *= 2;
12 }
bug C
C Java
C Java
Windows
Windows Windows
Windows API API
DLL
API
1 BOOL TextOut{
2 HDC hdc, //
3 int nXStart, // x
4 int nYStart, // y
5 LPCTSTR lpString, //
6 int cbString //
7 }
TextOut Windows Windows
Windows Windows CPU
IN OUT
Windows IN OUT
IN OUT
IN OUT
IN OUT CPU
IO
IC
IC IC IO
IO Input/Output I/O I/O
(port)
IO
CPU IO
I/O IC I/O
I/O
CPU
IN OUT
C C
_asm{ } C
AT 61H H IN
2 ON OUT
2 OFF
ON 1 OFF 0 ON
ON 1 0 OR 2 1
03H OR 03H 8 00000011 6
0 OR 03H OR OFF
OFF 0 1 AND 2 0
FCH AND FCH 0FCH 0
A-F 0FCH 8
11111100 6 1 AND 0FCH
OR
1 void main(){
2
3 //
4 int i;
5
6 //
7 _asm{
8 IN EAX, 61H
9 OR EAX, 03H
10 OUT 61H, EAX
11 }
12
13 //
14 for(i = 0;i < 1000000;i++);
15
16 //
17 _asm{
18 IN EAX, 61H
19 AND EAX, 0FCH
20 OUT 61H, EAX
21 }
22 }
main C _asm{}
for
100
100
I/O CPU
I/O IRQ
06 06 BIOS
CPU I/O
CPU IC
CPU
CPU
CPU
CPU
CPU
CPU
CPU
DMA
I/O
DMA(Direct Memory Access) DMA CPU
DMA DMA
CPU DMA
DMA DMA
MS-DOS VRAM
VRAM GPU Graphics Processing Unit
windows VRAM
VRAM
DMA