CSC 221 Computer Organization and Assembly Language

Slides:



Advertisements
Similar presentations
Jump Condition.
Advertisements

Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
Assembly Language for x86 Processors 6 th Edition Chapter 1: Introduction to ASM (c) Pearson Education, All rights reserved. You may modify and copy.
CSC 221 Computer Organization and Assembly Language Lecture 21: Conditional and Block Structures: Assembly Programs.
Copyright © 2000, Daniel W. Lewis. All Rights Reserved. CHAPTER 5 MIXING C AND ASSEMBLY.
Assembly Language for x86 Processors 6th Edition Chapter 5: Procedures (c) Pearson Education, All rights reserved. You may modify and copy this slide.
%rax %eax %rbx %ebx %rdx %edx %rcx %ecx %rsi %esi %rdi %edi %rbp %ebp %rsp %esp %r8 %r8d %r9 %r9d %r11 %r11d %r10 %r10d %r12 %r12d %r13 %r13d.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
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
CS2422 Assembly Language & System Programming October 17, 2006.
CS2422 Assembly Language and System Programming Conditional Processing Department of Computer Science National Tsing Hua University.
Flow Control Instructions
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, 4 th Edition Lecture 23: Finite State Machines, WHILE operator (c) Pearson Education, All rights reserved.
Conditional Processing If … then … else While … do; Repeat … until.
Quiz #2 Topics Character codes Intel IA-32 architecture Mostly MASM
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 2: IA-32 Processor Architecture (c) Pearson Education, All rights reserved. You.
Instruction Set Design by Kip R. Irvine (c) Kip Irvine, All rights reserved. You may modify and copy this slide show for your personal use,
Assembly Language for x86 Processors 7th Edition
Low Level Programming Lecturer: Duncan Smeed Low Level Program Control Structures.
Wednesday Feb 1 Project #1 Due Sunday, February 3 Quiz #2 Wednesday, February 6, in class Programming Project #2 is posted Due Sunday, February 10.
Assembly Language for Intel-Based Computers, 6 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
CSC 221 Computer Organization and Assembly Language
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.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
COMP 2003: Assembly Language and Digital Logic Chapter 2: Flags and Instructions Notes by Neil Dickson.
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 5: Procedures Lecture 19: Procedures Procedure’s parameters (c) Pearson Education, 2002.
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.
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 Wei Gao. Assembler language Instructions.
Selection and Iteration Chapter 8 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Assembly Language for Intel-Based Computers, 4 th Edition Lecture 22: Conditional Loops (c) Pearson Education, All rights reserved. You may modify.
CS-401 Computer Architecture & Assembly Language Programming
Practical Session 2 Computer Architecture and Assembly Language.
Computer Architecture and Assembly Language
Assembly Language for x86 Processors 6th Edition
CSC 221 Computer Organization and Assembly Language
Assembly Language for Intel-Based Computers, 5th Edition
Assembly Language for x86 Processors 6th Edition
Homework Reading Labs PAL, pp
Practical Session 2.
Chapter 9.
Assembly Language for x86 Processors 7th Edition
Assembly Language for Intel-Based Computers, 4th Edition
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
Assembly Language for Intel-Based Computers, 5th Edition
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Computer Architecture
INSTRUCTION SET.
More on logical instruction and
Assembly Language Programming Part 2
Microprocessor and Assembly Language
Processor Processor characterized by register set (state variables)
Computer Organization and Assembly Language
Assembly Language for Intel-Based Computers, 5th Edition
Homework Reading Machine Projects Labs PAL, pp
Assembly Language for Intel-Based Computers, 5th Edition
Assembly Language for Intel 8086 Jump Condition
Carnegie Mellon Ithaca College
Assembly Language for Intel-Based Computers, 5th Edition
CS201- Lecture 8 IA32 Flow Control
Credits and Disclaimers
Computer Architecture and Assembly Language
Presentation transcript:

CSC 221 Computer Organization and Assembly Language Lecture 19: I/O and Conditional Jumps in Assembly

Lecture 18: Review Program Components I/O Instructions StdIn proc lpszBuffer:DWORD,bLen:DWORD Description StdIn receives text input from the console and places it in the buffer required as a parameter. The function terminates when Enter is pressed. Parameters 1. lpszBuffer The buffer to receive the text input from the console. 2. bLen The length of the buffer. Include \masm32\include\masm32.inc includelib \masm32\lib\masm32.lib invoke StdIn, addr buffer, 100 Source: C:\masm32\help\masmlib.chm

Lecture 18: Review (cont.) StdOut proc lpszText:DWORD Description: StdOut will display a zero terminated string at the current position in the console. Parameter lpszText : A zero terminates string. Return Value There is no return value. Include \masm32\include\masm32.inc includelib \masm32\lib\masm32.lib invoke StdOut, addr message1 Source: C:\masm32\help\masmlib.chm

I/O Instructions: Example .data message1 BYTE "Type your name: ", 0 message2 BYTE "Your name is ", 0 .data? buffer BYTE 100 dup(?) .code start: invoke StdOut, addr message1 invoke StdIn, addr buffer, 100 invoke StdOut, addr message2 invoke StdOut, addr buffer invoke ExitProcess, 0 end start

Conditional Jump (Jcond) Instructions A conditional jump instruction branches to a label when specific register or flag conditions are met. Examples: JB, JC jump to a label if the Carry flag is set JE, JZ jump to a label if the Zero flag is set JS jumps to a label if the Sign flag is set JNE, JNZ jump to a label if the Zero flag is clear JECXZ jumps to a label if ECX equals 0

Jcond Ranges Prior to the 386: IA-32 processors: jump must be within –128 to +127 bytes from current location counter. IA-32 processors: 32-bit offset permits jump anywhere in memory.

Jumps Based on Specific Flags

Jumps Based on Equality

Jumps Based on Unsigned Comparisons

Jumps Based on Signed Comparisons

Lecture Outline ASSEMBLY LANGUAGE IMPLEMENTATION I/O Instructions Jumps Based On . . . Specific flags Equality Unsigned comparisons Signed Comparisons

Let’s enjoy assembly

Summary Assembly Language Implementation: I/O Instructions StdIn invoke StdIn, addr buffer, 100 StdOut invoke StdOut, addr message1

Summary Assembly Language Implementation: Conditional Jump Instructions Jumps Based on Specific Flags JZ, JNZ, JC, JNC, …… Jumps Based on Equality JE, JNE, JCXZ, ….. Jumps Based on Unsigned Comparison JA, JB, JAE, JBE, ….. Jumps Based on Signed Comparison JG, JL, JGE, JLE, ….

Reference Most of the Slides are taken from Presentation: Chapter 6 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 changed.