Assembly Language for Intel-Based Computers, 4 th Edition Lecture 23: Finite State Machines, WHILE operator (c) Pearson Education, 2002. All rights reserved.

Slides:



Advertisements
Similar presentations
Assembly Language for x86 Processors 6 th Edition Chapter 1: Introduction to ASM (c) Pearson Education, All rights reserved. You may modify and copy.
Advertisements

CSC 221 Computer Organization and Assembly Language Lecture 21: Conditional and Block Structures: Assembly Programs.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
Assembly Language for x86 Processors 6th Edition
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Conditional Loop Instructions LOOPZ and LOOPE LOOPNZ.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Symbolic Constants Equal-Sign Directive Calculating.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Intrinsic Data Types (1 of 2) BYTE, SBYTE 8-bit unsigned.
Assembly Language for Intel-Based Computers
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
CS2422 Assembly Language and System Programming Conditional Processing Department of Computer Science National Tsing Hua University.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers Chapter 3: Assembly Language Fundamentals Kip Irvine.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 3: Assembly Language Fundamentals (c) Pearson Education, All rights reserved. You.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Defining and Using Procedures Creating Procedures.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, Stack Operations Runtime Stack PUSH Operation POP.
Conditional Processing If … then … else While … do; Repeat … until.
1 Lecture 6 Conditional Processing Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
CS2422 Assembly Language & System Programming October 19, 2006.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 2: IA-32 Processor Architecture (c) Pearson Education, All rights reserved. You.
Assembly Language for x86 Processors 7th Edition
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 3: Assembly Language Fundamentals Assembling, Linking and Running Programs Example Programs.
Assembly Language for Intel-Based Computers, 6 th Edition Chapter 8: Advanced Procedures (c) Pearson Education, All rights reserved. You may.
Assembly Language for x86 Processors 7th Edition
Web siteWeb site ExamplesExamples ASSEMBLY LANGUAGE FOR INTEL- BASED COMPUTERS, 5 TH EDITION Chapter 6: Conditional Processing Kip R. Irvine.
Assembly Language for Intel-Based Computers, 6 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
Fall 2013 Chapter 6: Conditional Processing. Questions Answered by this Chapter How can I use the boolean operations introduced in Chapter 1 (AND, OR,
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You.
Assembly Language for x86 Processors 6th Edition
Chapter 6: Conditional Processing. 2 Chapter Overview Boolean and Comparison Instructions Conditional Jumps Conditional Loop Instructions Conditional.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You.
Assembly Language for Intel-Based Computers Chapter 7: Integer Arithmetic (c) Pearson Education, All rights reserved. You may modify and copy.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You.
Assembly Language for Intel-Based Computers, 4 th Edition Unpacked and Packed Integers (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 10: Structures and Macros (c) Pearson Education, All rights reserved. You.
Sahar Mosleh California State University San MarcosPage 1 Finite State Machine.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 5: Procedures Lecture 18 Linking to External Library The Book’s Link Library Stack Operations.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 5: Procedures Lecture 19: Procedures Procedure’s parameters (c) Pearson Education, 2002.
Conditional Processing Computer Organization and Assembly Languages Yung-Yu Chuang 2005/11/03 with slides by Kip Irvine.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 13: 16-Bit MS-DOS Programming Interrupts (c) Pearson Education, All rights reserved.
Language Translation Part 2: Finite State Machines.
CSC 221 Computer Organization and Assembly Language Lecture 16: Procedures.
CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions.
CSC 221 Computer Organization and Assembly Language Lecture 20: Conditional and Block Structures.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 2: IA-32 Processor Architecture (c) Pearson Education, All rights reserved. You.
Assembly Language for Intel-Based Computers, 4 th Edition Lecture 22: Conditional Loops (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for Intel-Based Computers, 4 th Edition Week 10: Conditional Processing Slides modified by Dr. Osama Younes.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
Assembly Language for x86 Processors 6th Edition
CSC 221 Computer Organization and Assembly Language
Assembly Language for x86 Processors 7th Edition
Assembly Language for Intel-Based Computers, 5th Edition
Chapter 6: Conditional Processing
Assembly Language for x86 Processors 6th Edition
CSC 221 Computer Organization and Assembly Language
Assembly Language for x86 Processors 7th Edition
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5th Edition
Assembly Language for Intel-Based Computers, 4th Edition
Conditional Processing
Presentation transcript:

Assembly Language for Intel-Based Computers, 4 th Edition Lecture 23: Finite State Machines, WHILE operator (c) Pearson Education, 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 changed. Chapter corrections (Web)Assembly language sources (Web)Chapter correctionsAssembly language sources Slides prepared by Kip R. Irvine Revision date: 07/11/2002 Modified by Dr. Nikolay Metodiev Sirakov Kip R. Irvine

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Application: Finite-State Machines A finite-state machine (FSM) is a graph structure that changes state based on some input. Also called a state-transition diagram. We use a graph to represent an FSM, with squares or circles called nodes, and lines with arrows between the circles called edges (or arcs). A FSM is a specific instance of a more general structure called a directed graph (or digraph). Three basic states, represented by nodes: Start state Terminal state(s) Nonterminal state(s)

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Finite-State Machine Accepts any sequence of symbols that puts it into an accepting (final) state Can be used to recognize, or validate a sequence of characters that is governed by language rules (called a regular expression) Advantages: Provides visual tracking of program's flow of control Easy to modify Easily implemented in assembly language

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, FSM Examples FSM that recognizes strings beginning with 'x', followed by letters 'a'..'y', ending with 'z': FSM that recognizes signed integers:

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Your turn... Explain why the following FSM does not work as well for signed integers as the one shown on the previous slide:

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Implementing an FSM StateA: call Getnext; read next char into AL cmp al,'+'; leading + sign? je StateB; go to State B cmp al,'-'; leading - sign? je StateB; go to State B call IsDigit; ZF = 1 if AL = digit jz StateC; go to State C call DisplayErrorMsg; invalid input found jmp Quit The following is code from State A in the Integer FSM: View the Finite.asm source code.Finite.asm source code

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Flowchart of State A State A accepts a plus or minus sign, or a decimal digit.

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Your turn... Draw a FSM diagram for hexadecimal integer constant that conforms to MASM syntax. Draw a flowchart for one of the states in your FSM. Implement your FSM in assembly language. Let the user input a hexadecimal constant from the keyboard.

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Using the.IF Directive Runtime Expressions Relational and Logical Operators MASM-Generated Code.REPEAT Directive.WHILE Directive

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Runtime Expressions.IF eax > ebx mov edx,1.ELSE mov edx,2.ENDIF.IF,.ELSE,.ELSEIF, and.ENDIF can be used to evaluate runtime expressions and create block-structured IF statements. Examples: MASM generates "hidden" code for you, consisting of code labels, CMP and conditional jump instructions..IF eax > ebx && eax > ecx mov edx,1.ELSE mov edx,2.ENDIF

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, Relational and Logical Operators

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, MASM-Generated Code mov eax,6 cmp eax,val1 mov val1 DWORD 5 result DWORD ?.code mov eax,6.IF eax > val1 mov result,1.ENDIF Generated code: MASM automatically generates an unsigned jump (JBE).

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, MASM-Generated Code mov eax,6 cmp eax,val1 mov val1 SDWORD 5 result SDWORD ?.code mov eax,6.IF eax > val1 mov result,1.ENDIF Generated code: MASM automatically generates a signed jump (JLE).

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, REPEAT Directive ; Display integers 1 – 10: mov eax,0.REPEAT inc eax call WriteDec call Crlf.UNTIL eax == 10 Executes the loop body before testing the loop condition associated with the.UNTIL directive. Example:

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, WHILE Directive ; Display integers 1 – 10: mov eax,0.WHILE eax < 10 inc eax call WriteDec call Crlf.ENDW Tests the loop condition before executing the loop body The.ENDW directive marks the end of the loop. Example:

Web siteWeb site ExamplesExamples Lecture 23, April 13,2005, 3PM-4:15PM Irvine, Kip R. Assembly Language for Intel-Based Computers, The End