Assembly Language Wei Gao. Assembler language Instructions.

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.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
8086 : INSTRUCTION SET By, Pramod Sunagar Assistant Professor
Intel’s 8086 instruction-set
CS2422 Assembly Language & System Programming October 17, 2006.
8-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
CS2422 Assembly Language and System Programming Conditional Processing Department of Computer Science National Tsing Hua University.
Flow Control Instructions
Microcomputer & Interfacing Lecture 3
Conditional Processing If … then … else While … do; Repeat … until.
Chapter 4 - Implementing Standard Program Structures in 8086 Assembly Language from Microprocessors and Interfacing by Douglas Hall.
Lecture 5 Multiplication, Division and Branches Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Dr. José M. Reyes Álamo 1.  Review: ◦ of Comparisons ◦ of Set on Condition  Statement Labels  Unconditional Jumps  Conditional Jumps.
Assembly Language for Intel-Based Computers, 6 th Edition Chapter 6: Conditional Processing (c) Pearson Education, All rights reserved. You may modify.
5. Assembly Language. Basics of AL Program data Pseudo-ops Array Program structures Data, stack, code segments.
Arithmetic Flags and Instructions
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
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.
Review of Assembly language. Recalling main concepts.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
Practical Session 2. Flags Register (Status Register) A flag is a single bit of information whose meaning is independent from any other bit Each flag.
COMP 2003: Assembly Language and Digital Logic Chapter 2: Flags and Instructions Notes by Neil Dickson.
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.
Selection and Iteration Chapter 8 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
CS-401 Computer Architecture & Assembly Language Programming
Practical Session 2 Computer Architecture and Assembly Language.
Computer Architecture and Assembly Language
Computer Architecture CST 250
Chapter Nov-2010
Data Transfers, Addressing, and Arithmetic
Computer Architecture and Assembly Language
Homework Reading Labs PAL, pp
Practical Session 2.
Today we are going to discuss about,
Instruction Set of 8086 Microprocessor
Instruksi Set Prosesor 8088
EE3541 Introduction to Microprocessors
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
INSTRUCTION SET.
Assembly IA-32.
INSTRUCTION SET.
Assembly Language Programming Part 2
Microprocessor and Assembly Language
Microprocessor & Interfacing
اصول اساسی برنامه نویسی به زبان اسمبلی
CS 301 Fall 2002 Assembly Instructions
Computer Organization and Assembly Language
فصل پنجم انشعاب و حلقه.
Fundamentals of Computer Organisation & Architecture
Program Logic and Control
Program Logic and Control
Homework Reading Machine Projects Labs PAL, pp
Flow Control Instructions
Computer Architecture and System Programming Laboratory
X86 Assembly Review.
UNIT-II Assembly Language Programs Involving Logical
Chapter 7 –Program Logic and Control
Chapter 8: Instruction Set 8086 CPU Architecture
Chapter 7 –Program Logic and Control
Computer Architecture and Assembly Language
Computer Architecture and System Programming Laboratory
UNIT-II ADDRESSING MODES & Instruction set
Presentation transcript:

Assembly Language Wei Gao

Assembler language Instructions

Transfer instructions They are used to move the contents of the operators. Each instruction can be used with different modes of addressing. MOV MOVS (MOVSB) (MOVSW)

Loading instructions They are specific register instructions. They are used to load bytes or chains of bytes onto a register. LODS (LODSB) (LODSW) LAHF LDS LEA LES LODS (LODSB) (LODSW) INSTRUCTION

LEA INSTRUCTION Purpose: To load the address of the source operator Syntax: LEA destiny, source The source operator must be located in memory, and its displacement is placed on the index register or specified pointer in destiny.

Stack instructions These instructions allow the use of the stack to store or retrieve data. POP POPF PUSH PUSHF

Logic instructions They are used to perform logic operations on the operators. AND NEG NOT OR TEST XOR

Arithmetic instructions They are used to perform arithmetic operations on the operators. ADC ADD DIV IDIV MUL IMUL SBB SUB

IDIV INSTRUCTION Purpose: Division with sign. Syntax: IDIV source It basically consists on the same as the DIV instruction, and the only difference is that this one performs the operation with sign. For its results it used the same registers as the DIV instruction.

The same with IMUL…

Jump instructions They are used to transfer the flow of the process to the indicated operator.

JMP JA (JNBE) JAE (JNBE) JB (JNAE) JBE (JNA) JE (JZ) JNE (JNZ) JG (JNLE) JGE (JNL) JL (JNGE) JLE (JNG) JC JNC JNO JNP (JPO) JNS JO JP (JPE) JS

JMP INSTRUCTION Purpose: Unconditional jump. Syntax: JMP destiny This instruction is used to deviate the flow of a program without taking into account the actual conditions of the flags or of the data.

JE (JZ) INSTRUCTION Purpose: Conditional jump. Syntax: JE label It jumps if it is the equal or if it is zero.

JNE (JNZ) INSTRUCTION Purpose: Conditional jump. Syntax: JNE label It jumps if it is not equal or zero.

JG (JNLE) INSTRUCTION Purpose: Conditional jump Syntax: JG label It jumps if it is larger

JL (JNGE) INSTRUCTION Purpose: Conditional jump Syntax: JL label It jumps if it is less than or if it is not larger than or equal to.

Instructions for cycles:loop They transfer the process flow, conditionally or unconditionally, to a destiny, repeating this action until the counter is zero. LOOP LOOPE LOOPNE

LOOP INSTRUCTION Purpose: To generate a cycle in the program. Syntax: LOOP label The loop instruction decreases CX by 1, and transfers the flow of the program to the label given as operator if CX is different than 1.

Counting instructions They are used to decrease or increase the content of the counters. DEC INC

DEC INSTRUCTION Purpose: To decrease the operator. Syntax: DEC destiny This operation subtracts 1 from the destiny operator and stores the new value in the same operator.

Comparison instructions They are used to compare operators, and they affect the content of the flags. CMP CMPS (CMPSB) (CMPSW)

CMP INSTRUCTION Purpose: To compare the operators. Syntax: CMP destiny, source This instruction subtracts the source operator from the destiny operator but without this one storing the result of the operation, and it only affects the state of the flags.

Assembly Programming Examples

In order to write useful programs, we need to be able to input and output data. A typical input and output routine… the file io.h provides a set of macro definitions that make it possible to do input, output, and numeric conversion fairly easily.

Example 1 Input/output using macros defined in io.h

oppgave this week: write a program to implement number guessing game.

Requirement: A Game (1) you can ask player1 to input a number, then ask player2 to guess the number,player2 will try to input a number. (2)if the input is bigger than the target, the system will output' it's too high!!‘. if it is smaller, output will be 'it's too low'. until player2 guess the number with a message display 'you got it!' (3)there is a counter for number of player2's guesses. (4)when player2 got the target, he is asked whether he would like to play again? if yes he can play again, if not the game ends. (5)optional: if you like you can also make it more like a real game. eg. design that when player2 has tried more than 10 times still not successful, then he fail, he can choose to try again or exit.