1. Trang chủ
  2. » Giáo Dục - Đào Tạo

01 moving data 17 38 tủ tài liệu bách khoa

16 54 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 16
Dung lượng 0,96 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Trang 1

car *c = malloc(sizeof(car));

c->miles = 100;

c->gals = 17;

float mpg = get_mpg(c);

free(c);

Car c = new Car(); c.setMiles(100); c.setGals(17);

float mpg = c.getMPG();

get_mpg:

pushq %rbp movq %rsp, %rbp

popq %rbp ret

0111010000011000

100011010000010000000010

1000100111000010

110000011111101000011111

Trang 2

¢  

¢  

¢  

¢  

¢  

¢  

¢  

¢  

Trang 3

¢  

§  

§ 

§  

§ 

¢  

§  

¢  

§  

§  

Trang 4

¢  

§  

§  

§  

§  

§  

¢  

%eax

%ecx

%edx

%ebx

%esi

%edi

%esp

%ebp

Trang 5

¢  

¢  

§ 

§ 

§ 

§  

§ 

§ 

§ 

§ 

§ 

%eax

%ecx

%edx

%ebx

%esi

%edi

%esp

%ebp

Trang 6

movl

movl $0x4,%eax movl $-147,(%eax)

movl %eax,%edx movl %eax,(%edx) movl (%eax),%edx

var_a = 0x4;

*p_a = -147;

var_d = var_a;

*p_d = var_a; var_d = *p_a;

Trang 7

¢  Indirect

§ 

movl (%ecx),%eax

¢  

§ 

§ 

§ 

movl 8(%ebp),%edx

Trang 8

void swap(int *xp, int *yp)

{

int t0 = *xp;

int t1 = *yp;

*xp = t1;

*yp = t0;

}

swap:

pushl %ebp movl %esp,%ebp pushl %ebx

movl 12(%ebp),%ecx movl 8(%ebp),%edx movl (%ecx),%eax movl (%edx),%ebx movl %eax,(%edx) movl %ebx,(%ecx)

movl -4(%ebp),%ebx movl %ebp,%esp

popl %ebp ret

Trang 9

void swap(int *xp, int *yp)

{

int t0 = *xp;

int t1 = *yp;

*xp = t1;

*yp = t0;

}

movl 12(%ebp),%ecx # ecx = yp movl 8(%ebp),%edx # edx = xp

Register

yp

xp

%ebp

0

4

8

12

-4

Trang 10

movl 12(%ebp),%ecx # ecx = yp

0x120 0x124

4

8

12

-4

123

456

0x124 0x120 0x11c 0x118 0x114 0x110 0x10c 0x108 0x104 0x100

yp

xp

%eax

%edx

%ecx

%ebx

%esi

%edi

%esp

%ebp 0x104

Trang 11

movl 12(%ebp),%ecx # ecx = yp

0x120 0x124

4

8

12

-4

123

456

0x124 0x120 0x11c 0x118 0x114 0x110 0x10c 0x108 0x104 0x100

yp

xp

%eax

%edx

%ecx

%ebx

%esi

%edi

%esp

%ebp 0x104

0x120

0x120

Trang 12

0x120 0x124

4

8

12

-4

123

456

0x124 0x120 0x11c 0x118 0x114 0x110 0x10c 0x108 0x104 0x100

yp

xp

%eax

%edx

%ecx

%ebx

%esi

%edi

%esp

%ebp

0x120

0x104

0x124

0x124

Trang 13

0x120 0x124

4

8

12

-4

123

456

0x124 0x120 0x11c 0x118 0x114 0x110 0x10c 0x108 0x104 0x100

yp

xp

%eax

%edx

%ecx

%ebx

%esi

%edi

%esp

%ebp

0x124 0x120

0x104

456

456

Trang 14

0x120 0x124

4

8

12

-4

123

456

0x124 0x120 0x11c 0x118 0x114 0x110 0x10c 0x108 0x104 0x100

yp

xp

%eax

%edx

%ecx

%ebx

%esi

%edi

%esp

%ebp

456 0x124 0x120

0x104

123

123

Trang 15

456

0x120 0x124

4

8

12

-4

0x124 0x120 0x11c 0x118 0x114 0x110 0x10c 0x108 0x104 0x100

yp

xp

%eax

%edx

%ecx

%ebx

%esi

%edi

%esp

%ebp

0x124 0x120

123

0x104

456

123

Trang 16

0x120 0x124

4

8

12

-4

456

0x124 0x120 0x11c 0x118 0x114 0x110 0x10c 0x108 0x104 0x100

yp

xp

%eax

%edx

%ecx

%ebx

%esi

%edi

%esp

%ebp

456 0x124 0x120

0x104

123

123

123

Ngày đăng: 09/11/2019, 07:12