Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Computer organization and assembly language - Lecture 26: Recursion and String Operations

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

In this lecture, students will be able to understand: Advanced Procedures; What is recursion? recursively calculating a sum; calculating a factorial; string primitive instructions; MOVSB, MOVSW, and MOVSD; CMPSB, CMPSW, and CMPSD; SCASB, SCASW, and SCASD; STOSB, STOSW, and STOSD; LODSB, LODSW, and LODSD. | CSC 221 Computer Organization and Assembly Language Lecture 26: Recursion and String Operations Lecture 25: Review Assembly Implementation of: Stack Parameters INVOKE Directive PROC Directive PROTO Directive Passing by Value or by Reference Example: Exchanging Two Integers Lecture 25: Review Assembly Implementation of: Stack Frames Explicit Access to Stack Parameters Passing Arguments by Reference (cont.) Lecture Outline Advanced Procedures: Recursion What is recursion? Recursively Calculating a Sum Calculating a Factorial String Primitive Instructions MOVSB, MOVSW, and MOVSD CMPSB, CMPSW, and CMPSD SCASB, SCASW, and SCASD STOSB, STOSW, and STOSD LODSB, LODSW, and LODSD Lecture Outline Selected String Procedures Str_length Procedure Str_copy Procedure Str_trim Procedure Str_ucase Procedure Recursion What is recursion? Recursively Calculating a Sum Calculating a Factorial What is Recursion? The process created when . . . A procedure calls itself Procedure A calls procedure B, which in | CSC 221 Computer Organization and Assembly Language Lecture 26: Recursion and String Operations Lecture 25: Review Assembly Implementation of: Stack Parameters INVOKE Directive PROC Directive PROTO Directive Passing by Value or by Reference Example: Exchanging Two Integers Lecture 25: Review Assembly Implementation of: Stack Frames Explicit Access to Stack Parameters Passing Arguments by Reference (cont.) Lecture Outline Advanced Procedures: Recursion What is recursion? Recursively Calculating a Sum Calculating a Factorial String Primitive Instructions MOVSB, MOVSW, and MOVSD CMPSB, CMPSW, and CMPSD SCASB, SCASW, and SCASD STOSB, STOSW, and STOSD LODSB, LODSW, and LODSD Lecture Outline Selected String Procedures Str_length Procedure Str_copy Procedure Str_trim Procedure Str_ucase Procedure Recursion What is recursion? Recursively Calculating a Sum Calculating a Factorial What is Recursion? The process created when . . . A procedure calls itself Procedure A calls procedure B, which in turn calls procedure A Using a graph in which each node is a procedure and each edge is a procedure call, recursion forms a cycle: Recursively Calculating a Sum CalcSum PROC cmp ecx,0 ; check counter value jz L2 ; quit if zero add eax,ecx ; otherwise, add to sum dec ecx ; decrement counter call CalcSum ; recursive call L2: ret CalcSum ENDP The CalcSum procedure recursively calculates the sum of an array of integers. Receives: ECX = count. Returns: EAX = sum Stack frame: Recursively Calculating a Sum .code main PROC mov ecx,10 ; count = 10 mov eax,0 ; holds the sum call CalcSum ; calculate sum L1: invoke dwtoa, eax, addr disp1 ; display eax invoke StdOut, addr disp1 invoke ExitProcess,0 main ENDP ;------------------------------------------ CalcSum PROC ; Calculates the sum of a list of integers ; Receives: ECX = count | Returns: EAX = sum ;------------------------------------------ cmp ecx,0 ; check counter value jz L2 ; quit if zero add eax,ecx ; otherwise, add to sum dec ecx ; .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.