DAT2343 Implementing Standard Logic Flows with 80x86 Assembler © Alan T. Pinck / Algonquin College; 2003.

Slides:



Advertisements
Similar presentations
Flow of Control Instruction/Control structure Looping structure Looping structure Branching structure Branching structure For assembly language program.
Advertisements

Machine Instructions Operations 1 ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson Slides4-1.ppt Modification date: March 18, 2015.
ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Computer Organization & Assembly Language
80x86 Instruction Set Dr. Qiang Lin.
The CPU Revision Typical machine code instructions Using op-codes and operands Symbolic addressing. Conditional and unconditional branches.
CS2422 Assembly Language & System Programming October 17, 2006.
Flow Control Instructions
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
Ch. 7 Logic, Shift and Rotate instr.
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
1 Assembler A short Overview. 2 Content Language Levels High Level  micro code Machinecode language Assembler languages Structure Commands.
5. Assembly Language. Basics of AL Program data Pseudo-ops Array Program structures Data, stack, code segments.
(Flow Control Instructions)
Executing and Linking an assembly program. Lesson plan Review Program logic and control Practice exercise Assembling, Linking and Executing Programs Practice.
Microprocessors The ia32 User Instruction Set Jan 31st, 2002.
1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 06: Control Structures Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,
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.
October 1, 2003Serguei A. Mokhov, 1 SOEN228, Winter 2003 Revision 1.2 Date: October 25, 2003.
3.4 Addressing modes Specify the operand to be used. To generate an address, a segment register is used also. Immediate addressing: the operand is a number.
Microprocessor MA Rahim Khan Computer Engineering and Networks Department.
COMP 2003: Assembly Language and Digital Logic Chapter 2: Flags and Instructions Notes by Neil Dickson.
The Assemble, Unassemble commands of the debugger: U Command for converting machine code language source Equivalent machine code instructions Equivalent.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 251 Introduction to Computer Organization.
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.
Computer and Information Sciences College / Computer Science Department CS 206 D Computer Organization and Assembly Language.
Selection and Iteration Chapter 8 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
CS2422 Assembly Language and System Programming 0 Week 13 & 14 Codes in Assembly Language.
Introduction to assembly programmıng language
Data Transfers, Addressing, and Arithmetic
Homework Reading Labs PAL, pp
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Assembly Language Programming Part 3
ICS312 SET 7 Flags.
Lecture Set 5 The 8051 Instruction Set.
Instruksi Set Prosesor 8088
Microprocessor and Assembly Language
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
INSTRUCTION SET.
Machine control instruction
Assembly IA-32.
INSTRUCTION SET.
More on logical instruction and
Assembly Language Programming Part 2
ECE 353 Introduction to Microprocessor Systems
Microprocessor and Assembly Language
UNIT: 2 INSTRUCTION SET OF 8086.
CS 301 Fall 2002 Assembly Instructions
CS 301 Fall 2002 Control Structures
4.4 Bit Manipulation Instructions
Introduction to Assembly Language
Flags Register & Jump Instruction
Lecture 1 Instruction set of 8086 Лектор: Люличева И.А. 1.
Shift & Rotate Instructions)
Program Logic and Control
Program Logic and Control
Homework Reading Machine Projects Labs PAL, pp
Conditional Jumps and Time Delays
Flow Control Instructions
EECE.3170 Microprocessor Systems Design I
Computer Organization and Assembly Language
Assembly Language for Intel 8086 Jump Condition
CNET 315 Microprocessor & Assembly Language
Chapter 7 –Program Logic and Control
Chapter 8: Instruction Set 8086 CPU Architecture
Chapter 7 –Program Logic and Control
CS-401 Computer Architecture & Assembly Language Programming
UNIT-II ADDRESSING MODES & Instruction set
Presentation transcript:

DAT2343 Implementing Standard Logic Flows with 80x86 Assembler © Alan T. Pinck / Algonquin College; 2003

Jumping Out of Sequence Basic Form JMP address “address” will normally be specified using a label reference (but could be specified as a literal numeric address)

Variance In Numeric Code for a JMP Samples of numeric code for various JMP instructions (from DEBUG) 0ADB:021A EB04 JMP ADB:021C EBF2 JMP ADB:021E E9FF00 JMP ADB:0221 E9FCFE JMP ADB:0224 EA B JMP 0B48:0320 Short: address within -127 to +128 of IP value (1 byte address) Near: address within the same segment (2 byte address) Far: address within a different segment (4 byte address)

Basic 80x86 Flags & Conditional Jump Mnemonics Zero flag (NZ, ZR) JNZ …; JZ … Carry flag (NC, CY) JNC …; JC … Sign flag (PL, NG) JNS …; JS … Overflow flag (NV, OV) JNO …; JO …

Basic 80x86 Flags & Conditional Jump Mnemonics (2) Important Note: All conditional jumps are “short” There are 4 other flags (which we will not use in this course): Parity, Interrupt Enable, Direction, and Auxiliary Carry There are some additional conditional jump mnemonics (presented on later slides) which combine flag settings.

Instructions Which Modify The Flags Most arithmetic operations: ADD, SUB, INC, DEC, CMP Bit-level logical operations: AND, OR, XOR, NOT Shifts and Rotates SHL, SHR, ROL, ROR

Instructions Which Do NOT Modify The Flags Any instruction not identified on the previous slide; Specifically, the following do NOT modify the flags: MOV IN JMP/Jxx

Unsigned Comparisons Less than (before)JB Less than Or Equal toJBE Equal toJE (or JZ) Not Equal toJNE (or JNZ) Greater than (after) Or EqualJAE Greater thanJA

Signed Comparisons Less thanJL Less than Or Equal toJLE Equal toJE (or JZ) Not Equal toJNE (or JNZ) Greater than Or Equal toJGE Greater thanJG

Limitations on Conditional Jump Distance As noted earlier all conditional jumps must be short jumps; the address must be within +127 and -128 bytes of the instruction following the conditional jump. When the location is further away than this a reversed conditional jump over a near (or far) jump must be used: JNC SkipCarryError JMP CarryError ;more than 128 bytes away SkipCarryError:

Implementing the IF…ELSE Structure IF num1 < num2 THEN ….. ELSE …. ENDIF mov ax,num1 sub ax,num2 jc then jmp else then: …… jmp endif else: …… endif:

Implementing the WHILE Structure WHILE num1 < num2 DO ….. ENDWHILE while: mov ax,num1 sub ax,num2 jc do jmp endw do: ……. jmp while endw:

Calling a Near Sub-Procedure To call a procedure within the same segment as the call: CALL procName

Near Procedure Structure Must be coded within the same segment as any call to this procedure: procName PROC NEAR ; instructions required by procedure RET procNameENDP

Calling a Far Sub-Procedure To call a procedure “procName” within a segment called “segName”: CALL segName:procName

Far Procedure Structure segName SEGMENT ; … procName PROC FAR ; instructions required for proc RET ; (translated as RETF, ; return far) procName ENDP ; … segName ENDS

End of Lecture