BAHAR DÖNEMİ MİKROİŞLEMCİLER LAB4 FÖYÜ

Similar documents
Computer Architecture..Second Year (Sem.2).Lecture(4) مدرس المادة : م. سندس العزاوي... قسم / الحاسبات

EXPERIMENT WRITE UP. LEARNING OBJECTIVES: 1. Get hands on experience with Assembly Language Programming 2. Write and debug programs in TASM/MASM

Introduction to 8086 Assembly

Selection and Iteration. Chapter 7 S. Dandamudi

LABORATORY WORK NO. 7 FLOW CONTROL INSTRUCTIONS

Jump instructions. Unconditional jumps Direct jump. do not change flags. jmp label

IFE: Course in Low Level Programing. Lecture 6

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

8086 INSTRUCTION SET

Lab 6: Conditional Processing

Conditional Processing

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Intel Instruction Set (gas)

Basic Assembly Instructions

CMSC 313 Lecture 05 [draft]

Week /8086 Microprocessor Programming

Assembly Language Lab # 6

Chapter 6 (Part a) Conditional Processing

Lecture (08) x86 programming 7

Branching and Looping

APPENDIX C INSTRUCTION SET DESCRIPTIONS

Lecture 5 Program Logic and Control

TUTORIAL. Emulador Emu8086 do. Microprocessador 8086

mith College Computer Science CSC231 Assembly Week #9 Spring 2017 Dominique Thiébaut

Branching and Looping

Control. Young W. Lim Mon. Young W. Lim Control Mon 1 / 16

CHAPTER SEVENTEEN Assemblers versus Compilers. Intel 80x86 Assembly Language

It is possible to define a number using a character or multiple numbers (see instruction DB) by using a string.

EC 333 Microprocessor and Interfacing Techniques (3+1)

Assembler lecture 5 S.Šimoňák, DCI FEEI TU of Košice

US06CCSC04: Introduction to Microprocessors and Assembly Language UNIT 3: Assembly Language Instructions II

Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION 80x86 Instructions

Computer Systems C S Cynthia Lee

ECE 498 Linux Assembly Language Lecture 3

7 LOW-LEVEL CONTROL STRUCTURES

Assembly Language LAB

from WRITE GREAT CODE Volume 2: Thinking Low-Level, Writing High-Level ONLINE APPENDIX A The Minimal 80x86 Instruction Set by Randall Hyde

Assembly Language Tutorial

2.1 Chapter Overview. 2.2 Low Level Control Structures. 2.3 Statement Labels. Low-Level Control Structures

X86 Addressing Modes Chapter 3" Review: Instructions to Recognize"

Section 002. Read this before starting!

Lecture 8: Control Structures. Comparing Values. Flags Set by CMP. Example. What can we compare? CMP Examples

UNIT II 16 BIT MICROPROCESSOR INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING. The Intel 8086 Instruction Set

Branching and Looping

Selected Pentium Instructions. Chapter 12 S. Dandamudi

Summer 2003 Lecture 4 06/14/03

Am186 and Am188 Family Instruction Set Manual. February, 1997

IBM PC Hardware CPU 8088, Pentium... ALU (Arithmetic and Logic Unit) Registers. CU (Control Unit) IP.

mith College Computer Science CSC231 Assembly Week #10 Fall 2017 Dominique Thiébaut

CS-202 Microprocessor and Assembly Language

Chapter Four Instructions Set

Ex : Write an ALP to evaluate x(y + z) where x = 10H, y = 20H and z = 30H and store the result in a memory location 54000H.

Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.

x64 Cheat Sheet Fall 2014

Chapter 12. Selected Pentium Instructions

Section 001. Read this before starting!

SPRING TERM BM 310E MICROPROCESSORS LABORATORY PRELIMINARY STUDY

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 6: Conditional Processing

An Introduction to x86 ASM

PESIT Bangalore South Campus

CS356 Unit 5. Translation to Assembly. Translating HLL to Assembly ASSEMBLY TRANSLATION EXAMPLE. x86 Control Flow

CSC 2400: Computer Systems. Towards the Hardware: Machine-Level Representation of Programs

Arithmetic Instructions

Read this before starting!

9/25/ Software & Hardware Architecture

Machine Programming 2: Control flow

We will first study the basic instructions for doing multiplications and divisions

UNIT III 8086 Microprocessor. Lecture 1

Assembler lecture 4 S.Šimoňák, DCI FEEI TU of Košice

CSC 8400: Computer Systems. Machine-Level Representation of Programs

Intel x86 Jump Instructions. Part 5. JMP address. Operations: Program Flow Control. Operations: Program Flow Control.

Intel x86 Jump Instructions. Part 5. JMP address. Operations: Program Flow Control. Operations: Program Flow Control.

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 5

Section 001 & 002. Read this before starting!

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

Section 001. Read this before starting!

Assembly Language: IA-32 Instructions

Basic Assembly SYSC-3006

5.1. CS356 Unit 5. x86 Control Flow

Assembly Language for Intel-Based Computers, 5 th Edition. Kip R. Irvine. Chapter 6: Conditional Processing

Arithmetic and Logic Instructions And Programs

Assembly Language II: Addressing Modes & Control Flow

International Islamic University Chittagong (IIUC) Department of Electrical and Electronic Engineering (EEE)

Signed number Arithmetic. Negative number is represented as

SOEN228, Winter Revision 1.2 Date: October 25,

Code segment Stack segment

CS61 Section Solutions 3

mith College Computer Science CSC231 Assembly Week #11 Fall 2017 Dominique Thiébaut

Lab 3. The Art of Assembly Language (II)

COMP211 ASSEMBLY PROGRAMMING

M80C286 HIGH PERFORMANCE CHMOS MICROPROCESSOR WITH MEMORY MANAGEMENT AND PROTECTION

Basic exploitation techniques

Sungkyunkwan University

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College February 9, 2016

The higher the values of above, the more powerful the CPU. Microprocessors are categorized in additional as: RISC or CISC.

Logic Instructions. Basic Logic Instructions (AND, OR, XOR, TEST, NOT, NEG) Shift and Rotate instructions (SHL, SAL, SHR, SAR) Segment 4A

Intel 8086: Instruction Set

CS 31: Intro to Systems ISAs and Assembly. Kevin Webb Swarthmore College September 25, 2018

Credits and Disclaimers

CONTENTS. 1. Display a Message Display a one Digit Number Accept a Character from keyboard and display the character 4

Transcription:

LAB4 RELATED INSTRUCTIONS: Compare, division and jump instructions CMP REG, memory memory, REG REG, REG memory, immediate REG, immediate operand1 - operand2 Result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according to result. MOV AL, 5 MOV BL, 5 CMP AL, BL ; AL = 5, ZF = 1 (so equal!) DIV REG memory LOOP label JMP label 4-byte address Unsigned divide. when operand is a byte: AL = AX / operand AH = remainder (modulus) when operand is a word: AX = (DX AX) / operand DX = remainder (modulus) MOV AX, 203 ; AX = 00CBh MOV BL, 4 DIV BL ; AL = 50 (32h), AH = 3 Decrease CX, jump to label if CX not zero. CX = CX - 1 if CX <> 0 then jump else no jump, continue MOV CX, 5 PRINTN 'loop!' LOOP label1 CONDITIONAL JUMP INSTRUCTIONS Unconditional Jump. Transfers control to another part of the program. 4-byte address may be entered in this form: 1234h:5678h, first value is a segment second value is an offset.

always jump MOV AL, 5 JMP label1 ; jump over 2 lines! PRINT 'Not Jumped!' MOV AL, 0 PRINT 'Got Here!' JNO label Short Jump if Not Overflow. if OF = 0 then jump ; -5-2 = -7 (inside -128..127) ; the result of SUB is correct, ; so OF = 0: MOV AL, -5 SUB AL, 2 ; AL = 0F9h (-7) JNO label1 PRINT 'overflow!' PRINT 'no overflow.' JNE label Short Jump if first operand is Not Equal to second operand (as set by CMP instruction). Signed/Unsigned. if ZF = 0 then jump CMP AL, 3 JNE label1 PRINT 'AL = 3.' PRINT 'Al <> 3.' JNLE label Short Jump if first operand is Not Less and Not Equal to second operand (as set by CMP instruction). Signed. if (SF = OF) and (ZF = 0) then jump

CMP AL, -3 JNLE label1 PRINT 'AL <= -3.' PRINT 'Al > -3.' JNL label Short Jump if first operand is Not Less then second operand (as set by CMP instruction). Signed. if SF = OF then jump CMP AL, -3 PRINT 'AL < -3.' PRINT 'Al >= -3.' JNP label Short Jump if No Parity (odd). Only 8 low bits of result are checked. Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if PF = 0 then jump MOV AL, 00000111b ; AL = 7 JNP label1 PRINT 'parity even.' PRINT 'parity odd.' JNS label Short Jump if Not Signed (if positive). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if SF = 0 then jump MOV AL, 00000111b ; AL = 7

JNS label1 PRINT 'signed.' PRINT 'not signed.' JNZ label Short Jump if Not Zero (not equal). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if ZF = 0 then jump MOV AL, 00000111b ; AL = 7 JNZ label1 PRINT 'zero.' PRINT 'not zero.' JO label Short Jump if Overflow. if OF = 1 then jump ; -5-127 = -132 (not in -128..127) ; the result of SUB is wrong (124), ; so OF = 1 is set: org 100h MOV AL, -5 SUB AL, 127 ; AL = 7Ch (124) JO label1 PRINT 'no overflow.' PRINT 'overflow!' JS label Short Jump if Signed (if negative). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if SF = 1 then jump MOV AL, 10000000b ; AL = -128

JS label1 PRINT 'not signed.' PRINT 'signed.' JPO label Short Jump if Parity Odd. Only 8 low bits of result are checked. Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if PF = 0 then jump MOV AL, 00000111b ; AL = 7 JPO label1 PRINT 'parity even.' PRINT 'parity odd.' JPE label Short Jump if Parity Even. Only 8 low bits of result are checked. Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if PF = 1 then jump MOV AL, 00000101b ; AL = 5 JPE label1 PRINT 'parity odd.' PRINT 'parity even.' JP label Short Jump if Parity (even). Only 8 low bits of result are checked. Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if PF = 1 then jump

MOV AL, 00000101b ; AL = 5 JP label1 PRINT 'parity odd.' PRINT 'parity even.' JZ label Short Jump if Zero (equal). Set by CMP, SUB, ADD, TEST, AND, OR, XOR instructions. if ZF = 1 then jump MOV AL, 5 CMP AL, 5 JZ label1 PRINT 'AL is not equal to 5.' PRINT 'AL is equal to 5.' JNGE label Short Jump if first operand is Not Greater and Not Equal to second operand (as set by CMP instruction). Signed. if SF <> OF then jump CMP AL, 3 JNGE label1 PRINT 'AL >= 3.' PRINT 'Al < 3.' JNG label Short Jump if first operand is Not Greater then second operand (as set by CMP instruction). Signed. if (ZF = 1) and (SF <> OF) then jump

CMP AL, 3 JNG label1 PRINT 'AL > 3.' PRINT 'Al <= 3.' LABROTORY PRELIMINARY: 1. Find the changed flags for following instructions and mnemonics: Instruction C Z S O P A I D CMP 0Fh, 20h CMP 0FFEh, 0FEFh CMP 0DFBh, 0DFBh Mnemonic C Z S O P A I D JO JNO JC, JB, JNAE JNC, JAE, JNB JE, JZ JNE, JNZ JBE, JNA JA, JNBE JS JNS JP, JPE JNP, JPO JL, JNGE JGE, JNL JLE, JNG JG, JNLE 2. Find the summation of even numbers between 20 to 56 then assign to AX, and summation of odd number is same range to assign to BX using CMP, DIV and one of the jump instructions. ORG 100H