While Loop While Loop i := 0; x := 2; WHILE i < 100

Slides:



Advertisements
Similar presentations
The Important Thing About By. The Important Thing About ******** The important thing about ***** is *****. It is true s/he can *****, *****, and *****.
Advertisements

Repetition Statements Perform the same task repeatedly Allow the computer to do the tedious, boring things.
Do-while Loops Programming. COMP102 Prog Fundamentals I: do-while Loops /Slide 2 The do-while Statement l Syntax do action while (condition) l How it.
Chapter 3 Introduction to the 68000
Branching Instruction OP (4-bit)Cond (4-bit)Displacement (8-bit or 16-bit) 0110CondDisplacement (8-bit) 0110Cond0000 Displacement (16-bit)
Chapter 6 Introduction to Data Structures. Defining Constant EQU XVALEQU7 MOVE.B#XVAL, D0.
Control Structures in ARM Implementation of Decisions Similar to accumulator instructions One instruction sets the flags, followed by another instruction.
1 Memory-Mapped I/O Lecture 23 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
EECC250 - Shaaban #1 Lec # 6 Winter Stack-Related Instructions PEA Push Effective Address Calculates an effective address and pushes it.
 Introduce yourself and make sure you know the other person’s name.  Find the scripture mastery reference and mark it.  Talk to each other and answer.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 2.
A loop is a repetition control structure. it causes a single statement or block to be executed repeatedly What is a loop?
Infix to postfix conversion Use a loop to read the tokens one by one from a vector infixVect of tokens (strings) representing an infix expression. For.
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
CEG 320/520: Computer Organization and Assembly Language ProgrammingFlow Control 1 Flow Control.
© 1999, by Que Education and Training, Chapter 7, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
9/20/6Lecture 3 - Instruction Set - Al1 Project Description.
Making Decision – Microprocessor
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
Memory/Storage Architecture Lab 컴퓨터의 개념과 실습 Assembly Example.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
For Code Next For Code Next A loop is a segment of a code that repeats (changing slightly each time)
Structured Programming The Basics. Control structures They control the order of execution What order statements will be done in, or whether they will.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
1 Karel – Chapter 6 Instructions That Repeat Note: Original slides provided by and modified for Mr. Smith’s AP Computer Science.
CPSC 233 Tutorial 5 February 2 th /3 th, Java Loop Statements A portion of a program that repeats a statement or a group of statements is called.
Loops Tonga Institute of Higher Education. Introduction Programs need to be able to execute tasks repeatedly. Use loops to repeat actions  For Loop 
MODULE 1 : WHY PROGRAMMING LANGIUAGES - Overview Programming fundamentals is about knowing how to give instructions in a computer language to the computer.
Structured Programming The Basics
Factors, Prime Numbers & Composite Numbers
Slide 7 Mikroprosesor Sub. Algoritma Program___
Merging Merge. Keep track of smallest element in each sorted half.
Lesson 05: Iterations Class Chat: Attendance: Participation
Computer Architecture & Operations I
How many words can you make from
Ms. Hubbard 5th Grade Topic 1
Multiply a Teens Number
Introducing Do While & Do Until Loops & Repetition Statements
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Scrolling text repeating until end of slide.
Pick up the handout on your way in!!
CSCI206 - Computer Organization & Programming
Iteration with While You can say that again.
مراجعة الحاسب.
CPS120: Introduction to Computer Science
البرمجة بلغة الفيجول بيسك ستوديو
Group2 Group members:
Computer Architecture
Factors, Prime Numbers & Composite Numbers
SHADING VENN DIAGRAMS
IST256 : Applications Programming for Information Systems
; main program ; main move Param2, -(sp) move Param1, -(sp) Call Sub1
Factors, Prime Numbers & Composite Numbers
Warm-Up Combine Like Terms: 6x + 2y - 3x + 4y -3z + 4x -5y + 2z.
Loops.
Multiples and Factors.
A LESSON IN LOOPING What is a loop?
Please insert Title Please insert sub-title 1
Put the title here Here is the sub-title.
Put the title here Here is the sub-title.
x 4 = 7 x 4 = 3 x 4 = x 4 = 1 x 4 = 2 x 4 = x 4 = 6 x 4 = 0 x 4 = Instructions Cut out the cards choose a question, find the.
Using Addition Properties
Decisions in assembler code
Accum A: Index X: CCR Bit Z: $0100 $0101 $0102 $0103 $0104 $0105
Factors, Prime Numbers & Composite Numbers, Prime Factorization

You are the manager of a team of ARM programmers
ECE511: Digital System & Microprocessor
Conditional Branching (beq)
Presentation transcript:

While Loop While Loop i := 0; x := 2; WHILE i < 100 org $2000 sub d0, d0 movea d0, a0 move I(a0), d0 ; d0 = i = 0 move X(a0), d1 ; d1 = x = 2 move const(a0), d2 ; d2 = 1 move const+2(a0), d3 ; d3 = 100 while cmp d0, d3 ; 100 – i bgt DO ; go if 100 > i bra DONE DO add d2, d0 ; i = i + 1 add d1, d1 ; x = x + x bra while DONE move d1, X(a0) move const+4(a0), d0 trap #0 I dc 0 X dc 2 const dc 1, 100, 3 end While Loop i := 0; x := 2; WHILE i < 100 DO { i := i + 1; x := x + x; } END

Repeat Loop Repeat Loop sub d0, d0 i := 0; movea d0, a0 org $2000 sub d0, d0 movea d0, a0 move I(a0), d0 ; d0 = i = 0 move X(a0), d1 ; d1 = x = 2 move const(a0), d2 ; d2 = 1 move const+2(a0), d3 ; d3 = 100 REPEAT add d2, d0 add d1, d1 cmp d0, d3 ; 100 – i beq DONE bra REPEAT DONE move d1, X(a0) move const+4(a0), d0 trap #0 I dc 0 X dc 2 const dc 1, 100, 3 end Repeat Loop i := 0; x := 2; REPEAT { i := i + 1; x := x + x; } UNTIL ( i == 100 ) END

For Loop Try Yourself For Loop x := 2; FOR i = 1 to 100 DO x := x + x; END i = 1 i <= 100 true Body of loop i ++