ACOE251Sofware Constructs1 Software Constructs What they are …..

Slides:



Advertisements
Similar presentations
Jump Condition.
Advertisements

Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
The "if structure" is used to execute statement(s) only if the given condition is satisfied.
Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
Assembly Programming Notes for Practical 3 Munaf Sheikh
CSC 221 Computer Organization and Assembly Language Lecture 21: Conditional and Block Structures: Assembly Programs.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Computer Organization & Assembly Language
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
LAB Flow Control Instructions
Assembly Language for Intel-Based Computers
CS2422 Assembly Language & System Programming October 17, 2006.
Flow Control Instructions
Conditional Processing If … then … else While … do; Repeat … until.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Lab 5 Part C Write to the screen a character string that uses a ‘$’ to indicate the end of the string. Do not write the ‘$’ to the screen. Use DOS Interrupt.
Topics Control Flow Structure – Conditional Jump – Unconditional Jump Control Flow Structures – IF-THEN – IF-THEN-ELSE – CASE Branches with Compound Conditions.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7)
Lecture 3 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Review the following: if-else One branch if Conditional operators Logical operators Switch statement Conditional expression operator Nested ifs if –else.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Strings, Procedures and Macros
(Flow Control Instructions)
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 5 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Assembly Language. Symbol Table Variables.DATA var DW 0 sum DD 0 array TIMES 10 DW 0 message DB ’ Welcome ’,0 char1 DB ? Symbol Table Name Offset var.
LEA instruction The LEA instruction can be used to get the offset address of a variable Example ORG 100h MOV AL, VAR1 ; check value of VAR1 by moving it.
Conditional Loop Instructions, Conditional Structures
2/20/2016CAP 2211 Flow Control Instructions. 2/20/2016CAP 2212 Transfer of Control Flow control instructions are used to control the flow of a program.
Jumps, Loops and Branching. Unconditional Jumps Transfer the control flow of the program to a specified instruction, other than the next instruction in.
Assembly Language Programming Petra University Dr. Hadi Hassan Conditional Processing.
K.K. Leung Fall 2008Introductory Pentium Programming1 Pentium Architecture: Introductory Programming Kin K. Leung
Addressing Modes Instruction – Op-code – Operand Addressing mode indicates a way of locating data or operands. – Any instruction may belong to one or more.
SELECTION CONTROL STRUCTURE Prepared by: Careene McCallum-Rodney.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7) By Dr. Syed Noman.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Computer Science 210 Computer Organization Machine Language Instructions: Control.
Program design Program Design Process has 2 phases:
Computer Architecture CST 250
Sequence, Selection, Iteration The IF Statement
Algorithms and Flowcharts
Microprocessor and Assembly Language
Lecture 4 Control Flow Structures (LOOPS)
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Assembly Language Programming Part 2
Microprocessor and Assembly Language
(The Stack and Procedures)
Computer Organization and Assembly Language
Computer Science 210 Computer Organization
Chương 4: Lập trình hợp ngữ
(The Stack and Procedures)
Program Logic and Control
Microprocessor Lab CSL1543 0:0:2
Program Logic and Control
Figure 4- 1: Flowchart for Example 4-3
Flow Control Instructions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Computer Science Core Concepts
University of Gujrat Department of Computer Science
EECE.3170 Microprocessor Systems Design I
High-level language structures
UNIT-II Assembly Language Programs Involving Logical
Assembly Language for Intel 8086 Jump Condition
(The Stack and Procedures)
Jump & Loop instructions
Chapter 7 –Program Logic and Control
Chapter 7 –Program Logic and Control
REPETITION Why Repetition?
Part VI Looping Structures
Presentation transcript:

ACOE251Sofware Constructs1 Software Constructs What they are …..

ACOE251Sofware Constructs2 The “IF THEN ….” Construct The “IF THEN” construct is used when a sequence of instructions must be executed only if a condition is satisfied. Pseudo-Code: IF (Condition = True) THEN BEGIN Statement StatementN END Assembly: CMP AL,Condition JNE Cont Statement StatementN Cont: Flowchart

ACOE251Sofware Constructs3 IF THEN :- Example 1 Write a procedure that increments the content of AH only if the content of AL is equal to 50H.

ACOE251Sofware Constructs4 IF THEN :- Example 2 Write a procedure that adds BL to AL. If the sum is greater than 255 then increment the contents of AH.

ACOE251Sofware Constructs5 The “IF THEN…ELSE” Construct The “IF THEN …ELSE” construct is used when a sequence of instructions must be executed only if a condition is satisfied, while another sequence must be executed if the condition is not satisfied.. Pseudo-Code: IF (Condition = True) THEN BEGIN Statement1; Statement2; END ELSE BEGIN Statement1; Statement2; END Assembly: CMP AL,Contition JNE No Yes_Statements JMP Cont No:No_Statements Cont: Flowchart

ACOE251Sofware Constructs6 CASE Structure CASE structure is a multi-way branch instruction: CASE expression Values_1: Statements to perform if expression = values_1 Values_2: Statements to perform if expression = values_2. Values_N: Statements to perform if expression = values N END_CASE

ACOE251Sofware Constructs7 Conversion of Case Structure Consider: CASE AX 1 or 2: Add 1 to BX 3 or 4: Add 1 to CX End_CASE

ACOE251Sofware Constructs8 Conversion of Case Structure (cont’d) FIRST THOUGHTBETTER CODE ;CASE AX; CASE AX ;1 or 2; 1 or 2CMP AX,1JE ADD_BXCMP AX,2 JE ADD_BXJE ADD_BX ;3 or 4; 3 or 4CMP AX,3 JE ADD_CXJE ADD_CXCMP AX,4 JE ADD_CXJNE END_CASE_AX JMP END_CASE_AX ADD_CX: ADD_BX:INCCX INC BXJMP END_CASE_AX ADD_BX: ADD_CX:INCBX INCCXEND_CASE_AX: END_CASE_AX:

ACOE251Sofware Constructs9 Branches with Compound Conditions AND conditions (TRUE IF both conditions are true) How do you implement: IF AX=1 AND BX=1 THEN ADD 1 TO CX END_IF In AL we could code: ;IF AX=1 and BX=1 CMP AX,1 JNE END_IF CMP BX,1 JNE END_IF ;Then add 1 to CX INC CX END_IF:

ACOE251Sofware Constructs10 Branches with Comp. Conditions (cont’d) OR conditions (True if either condition is true, false IF both conditions are false) How do you implement: IF AX=1 or BX=1 Then Add 1 to CX END_IF In AL we could code: ; IF AX=1 or BX=1 CMP AX,1 JE ADD_CX CMP BX,1 JNE END_IF ADD_CX: INC CX END_IF: