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

066 memory ideas kho tài liệu training

45 43 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 45
Dung lượng 663,75 KB

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

Nội dung

Higher dimensions  Assume that we want to remember the multiplication table in memory.. Multiplication table  Declaring the table:  Filling in the table: mov esi,mul_tbl ; cell ptr

Trang 1

Memory Ideas

Assembly language programming

Trang 3

The memory is not just bytes

 Don’t let it limit your thinking

little bytes

Trang 4

section '.bss' readable writeable

my_dogs db NUM_DOGS*sizeof.DOG dup (?)

section '.text' code readable executable

start:

; Access dog number ecx mov esi,my_dogs lea esi,[esi + ecx*sizeof.DOG]

mov eax, dword [esi + DOG.color] mov edx, dword [esi + DOG.age]

Trang 5

Higher dimensions

 Assume that we want to remember the multiplication table in memory

 How can we store a two dimensional object in our one

dimensional memory landscape?

 We use our imagination!

Trang 6

Higher Dimensions (Cont.)

 The cell in row 3 and column 1 is in location 7

Trang 7

Higher Dimensions (Cont.)

 The cell in row 3 and column 1 is in location 13

Trang 8

Higher Dimensions (Cont.)

Trang 9

Multiplication table

 Declaring the table:

mul_tbl dd WIDTH*HEIGHT dup (?)

Trang 10

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 11

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 12

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 13

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 14

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 15

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

ebx

Trang 16

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 17

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 18

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 19

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

ebx

Trang 20

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 21

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 22

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 23

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

ebx

Trang 24

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 25

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 26

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 27

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

ebx

Trang 28

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 29

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 30

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 31

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 32

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 33

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 34

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 35

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

ebx

Trang 36

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 37

Multiplication table

 Declaring the table:

 Filling in the table:

mov esi,mul_tbl ; cell ptr

mov ecx,0 ; row counter

Trang 38

More dimensions

 The same techniques apply to more than 2 dimensions

 Think about how to translate (x,y,z)

coordinates into a linear memory location

Trang 39

Binary tree

 How to represent it using linear memory?

Trang 40

Binary tree (Cont.)

 Let’s number the nodes:

1

Trang 41

Binary tree (Cont.)

 Finally we flatten the tree into linear memory:

Trang 42

Binary tree (Cont.)

 Traversing the tree

5

Trang 43

Binary tree (Cont.)

 Traversing the tree

5

Trang 44

 Use your imagination

Trang 45

Exercises

 Code reading

 Code writing

 Have fun :)

Ngày đăng: 17/11/2019, 08:21

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN