Lecture Computer organization and assembly language - Lecture 14: Flow Control Instructions in Assembly Language

In this lecture, students will be able to understand: Computer organization, data representation, integer arithmetic, binary representation, Assembly language examples, control flow, JMP Instruction, LOOP Instruction, LOOP Example Summing an Integer Array. | CSC 221 Computer Organization and Assembly Language Lecture 14: Flow Control Instructions in Assembly Language Lecture 13: Review top: . . jmp top JMP Instruction JMP is an unconditional jump to a label that is usually within the same procedure. Syntax: JMP target Logic: EIP target Example: Clock Cycle Instruction Cycle Lecture 13: Review (cont.) LOOP Instruction The LOOP instruction creates a counting loop Syntax: LOOP target Logic: ECX ECX – 1 if ECX != 0, jump to target 00000000 66 B8 0000 mov ax,0 00000004 B9 00000005 mov ecx,5 00000009 66 03 C1 L1: add ax,cx 0000000C E2 FB loop L1 0000000E offset machine code source code Lecture 13: Review (cont.) Nested Loops .data count DWORD ? .code mov ecx,100 ; set outer loop count L1: mov count,ecx ; save outer loop count mov ecx,20 ; set inner loop count L2: . . loop L2 ; repeat the inner loop mov ecx,count ; restore outer loop count loop L1 ; repeat the outer loop Lecture Outline Assembly Language Examples: Control Flow JMP . | CSC 221 Computer Organization and Assembly Language Lecture 14: Flow Control Instructions in Assembly Language Lecture 13: Review top: . . jmp top JMP Instruction JMP is an unconditional jump to a label that is usually within the same procedure. Syntax: JMP target Logic: EIP target Example: Clock Cycle Instruction Cycle Lecture 13: Review (cont.) LOOP Instruction The LOOP instruction creates a counting loop Syntax: LOOP target Logic: ECX ECX – 1 if ECX != 0, jump to target 00000000 66 B8 0000 mov ax,0 00000004 B9 00000005 mov ecx,5 00000009 66 03 C1 L1: add ax,cx 0000000C E2 FB loop L1 0000000E offset machine code source code Lecture 13: Review (cont.) Nested Loops .data count DWORD ? .code mov ecx,100 ; set outer loop count L1: mov count,ecx ; save outer loop count mov ecx,20 ; set inner loop count L2: . . loop L2 ; repeat the inner loop mov ecx,count ; restore outer loop count loop L1 ; repeat the outer loop Lecture Outline Assembly Language Examples: Control Flow JMP Instruction LOOP Instruction LOOP Example Summing an Integer Array Let’s Enjoy ASSEMBLY LANGUAGE Instruction Execution FLOW CONTROL Instruction Examples JMP Instruction LOOP Instruction Summary 7 Reference Most of the Slides are taken from Presentation: Chapter 4 and 5 Assembly Language for Intel-Based Computers, 4th Edition Kip R. Irvine (c) Pearson Education, 2002. All rights reserved. You may modify and copy this slide show for your personal use, or for use in the classroom, as long as this copyright statement, the author's name, and the title are not .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.