CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7) By Dr. Syed Noman.

Slides:



Advertisements
Similar presentations
Jump Condition.
Advertisements

Progam.-(6)* Write a program to Display series of Leaner, Even and odd using by LOOP command and Direct Offset address. Design by : sir Masood.
Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
ICS312 Set 6 Operands. Basic Operand Types (1) Register Operands. An operand that refers to a register. MOV AX, BX ; moves contents of register BX to.
Assembly Language :CSC 225 (Lec#4: Flag Register and Conditional Statements) By Dr. Syed Noman.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#4)
Lecture 2 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
Assembly Language for Intel-Based Computers Chapter 5: Procedures Kip R. Irvine.
Irvine: Assembly Language for Intel-Based Computers (1999) Symbolic Constants Equal-sign Directive EQU Directive TEXTEQU Directive.
Introduction to Computer Engineering by Richard E. Haskell Branching Instructions Module M17.2 Section 11.1.
Kip Irvine: Assembly Language for Intel-Based Computers Overview Stack Operations (PUSH and POP) Procedures Procedure Parameters Software Interrupts MS-DOS.
Flow Control Instructions
Irvine, Kip R. Assembly Language For Intel-Based Computers.data string db "This is a string." COUNT = ($–string) ; calculate string length.code mov cx,COUNT.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#8) By Dr. Syed Noman.
Factorial of a number data segment x1 db 4 fact dw ? data ends
Program.-(4)* Write a program for input two integer number with message and display their sum. Algorithm steps Algorithm steps 1.Display message for input.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#6)
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)
COSC 456 Lesson 8 Cool Codes ADD AL,SIAL AL + SI ADD AL,[SI]AL AL + [SI] INC BXBX BX + 1 INC [BX]Ambiguity error INC BYTE PTR [BX][BX] [BX] + 1 INC WORD.
1/2002JNM1 Positional Notation (Hex Digits). 1/2002JNM2 Problem The 8086 has a 20-bit address bus. Therefore, it can access 1,048,576 bytes of memory.
BIOS and DOS Programming in DOS INT 10 and 21H. Interrupts There are some extremely useful subroutines within BIOS or DOS that are available to the user.
Lecture 4 Presented By Dr. Shazzad Hosain Asst. Prof. EECS, NSU.
String-Introduction String is a series of bytes or a series of words in sequential memory locations. Index registers - SI (Data segment) - DI (Extra segment)
Overview of Assembly Language Chapter 4 S. Dandamudi.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#5) By Dr. Syed Noman.
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#9) By Dr. Syed Noman.
Chapter 8 Advanced Programming Applications Objectives: Linking separate object files together Creating and using an object code library Predicting the.
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.
ACOE251Sofware Constructs1 Software Constructs What they are …..
In Class Program Write, assemble and test a program: –Use the DB directive to define the following list of numbers and name it array: 31h, 32h, 33h, 34h.
Review of Assembly language. Recalling main concepts.
Control Structure vs. Assembly Language NASM. If-then-else If conditional then then_actions jump to endif else else_actions endif.
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.
Computer Organization & Assembly Language University of Sargodha, Lahore Campus Prepared by Ali Saeed.
Assembly Language Lecture 2. Lecture Outline Program Structure Memory models Data Segment Stack Segment Code Segment Input and Output Instructions INT.
Program Structure Example for Data Segment CRLF EQU 0DH, 0AH PROMPT DB 'Enter a digit between 0 and 9', 0 VAR1 DB ? ARRAY DW 1234h, 23h, 0FF54h.
Computer Architecture CST 250
Introduction to assembly programmıng language
Presentation on Real Mode Memory Addressing
COURSE OUTCOMES OF MICROPROCESSOR AND PROGRAMMING
Microprocessor and Assembly Language
Lecture 4 Control Flow Structures (LOOPS)
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Microprocessor and Assembly Language
(The Stack and Procedures)
Arithmetic Instructions
Symbolic Instruction and Addressing
8086 Registers Module M14.2 Sections 9.2, 10.1.
Morgan Kaufmann Publishers Computer Organization and Assembly Language
(The Stack and Procedures)
Program Logic and Control
Microprocessor Lab CSL1543 0:0:2
Assembly Language Programming
Program Logic and Control
Symbolic Instruction and Addressing
Flow Control Instructions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
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
By Nasser Halasa Assembly Language.
Chapter 7 –Program Logic and Control
Part VI Looping Structures
Presentation transcript:

CEN 226: Computer Organization & Assembly Language :CSC 225 (Lec#7) By Dr. Syed Noman

Implementing loop without loop statement Printing ‘*’ ten times on the screen mov ah,2 mov dl,’*’ mov cx,10 disp_char: int 21h dec cx cmp cx,0 jne disp_char 2

General format for using loop instruction mov cx, count ; count = # of times to repeat loop start_loop: ; use any label name ; while cx > 0 ; repeat loop body instructions loop start_loop 3

Implementing loop with loop statement mov ah,2 mov dl, ‘*’ ; al = ‘*’ mov cx, 10 ; cx = 10 ; loop count disp_char: int 21h; display ‘*’ loop disp_char ; cx = cx - 1, if (cx != 0) Here, cx is initialised to 10, the number of iterations required. The instruction loop disp_char first decrements cx and then tests if cx is not equal to 0, branching to disp_char only if cx does not equal 0. 4

Program to print name 10 times.model small.data myName db 13,10,‘Dr. Syed Noman$’.code mov mov ds,ax mov cx,10 mov ah,9 mov dx, offset myName again: int 21h loop again mov ax,4c00h int 21h end 5

Program print digits from 0 to 9.model small.code mov cx,10 mov ah,2 mov dl,30h; mov dl, ‘0’; mov dl,48; mov dl, b again: int 21h inc dl loop again mov ax,4c00h int 21h end 6

Program print even numbers from 0 to 9.model small.code mov cx,5 mov ah,2 mov dl,30h again: int 21h add dl,2 loop again mov ax,4c00h int 21h end 7