Data Transfers, Addressing, and Arithmetic

Slides:



Advertisements
Similar presentations
Department of Computer Science and Software Engineering
Advertisements

ACOE2511 Assembly Language Arithmetic and Logic Instructions.
Web siteWeb site ExamplesExamples Irvine, Kip R. Assembly Language for Intel-Based Computers, MUL Instruction The MUL (unsigned multiply) instruction.
Gursharan Singh Tatla 21-Nov-20101www.eazynotes.com.
Joseph L. Lindo Assembly Programming Sir Joseph Lindo University of the Cordilleras.
8086 : INSTRUCTION SET By, Pramod Sunagar Assistant Professor
1 Lecture 4: Data Transfer, Addressing, and Arithmetic Assembly Language for Intel-Based Computers, 4th edition Kip R. Irvine.
9-1 ECE 424 Design of Microprocessor-Based Systems Haibo Wang ECE Department Southern Illinois University Carbondale, IL x86 Instructions Part.
CS2422 Assembly Language & System Programming September 28, 2006.
Shift and Rotate Instructions
Chapter 4 Basic Instructions. 4.1 Copying Data mov Instructions mov (“move”) instructions are really copy instructions, like simple assignment statements.
Outline Data Transfer Instructions Arithmetic Instructions Data-Related Operations and Directives Indirect Addressing JMP and LOOP Instructions.
CEG 320/520: Computer Organization and Assembly Language ProgrammingIntel Assembly 1 Intel IA-32 vs Motorola
CSC 221 Computer Organization and Assembly Language
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
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.
Arithmetic Flags and Instructions
Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 4 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Click to add Title Comunicación y Gerencia Click To add Subtitle Click to add Text Fundamentals of Assembly Language.
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.
EEL 3801 Part V Conditional Processing. This section explains how to implement conditional processing in Assembly Language for the 8086/8088 processors.
Review of Assembly language. Recalling main concepts.
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.
Fall 2012 Chapter 4: Data Transfers, Addressing, and Arithmetic.
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.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
Comparison Instructions Test instruction –Performs an implied AND operation between each of the bits in 2 operands. Neither operand is modified. (Flags.
Multiplication and Division instructions Dr.Hadi AL Saadi.
I NTEL 8086 M icroprocessor بسم الله الرحمن الرحيم 1.
CS2422 Assembly Language and System Programming 0 Week 9 Data Transfers, Addressing, and Arithmetic.
Format of Assembly language
Assembly Language for Intel-Based Computers, 5th Edition
16.317: Microprocessor System Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor and Assembly Language
Microprocessor Systems Design I
EE3541 Introduction to Microprocessors
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Basic Assembly Language
Multiplication and Division Instructions
Assembly IA-32.
Assembly Language Lab (4).
INSTRUCTION SET.
Assembly Language Programming Part 2
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
Assembly Language for Intel-Based Computers, 4th Edition
Symbolic Instruction and Addressing
CS 301 Fall 2002 Assembly Instructions
X86’s instruction sets.
Chapter 4: Instructions
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Data Transfers, Addressing, and Arithmetic
Morgan Kaufmann Publishers Computer Organization and Assembly Language
Symbolic Instruction and Addressing
Multiplication and Division Instructions
Symbolic Instruction and Addressing
Basic Instructions.
Flow Control Instructions
Assembly Language for Intel-Based Computers, 4th Edition
University of Gujrat Department of Computer Science
Chapter 5 Arithmetic and Logic Instructions
Computer Architecture and System Programming Laboratory
Chapter 6 –Symbolic Instruction and Addressing
Computer Organization and Assembly Language
CNET 315 Microprocessor & Assembly Language
Multiplication and Division Instructions
Multiplication and Division Instructions
Chapter 8: Instruction Set 8086 CPU Architecture
Computer Architecture and Assembly Language
Presentation transcript:

Data Transfers, Addressing, and Arithmetic Lecture 6

Data Transfer Instructions Operand Types Three basic types of operands: *Immediate: a constant integer (8, 16, or 32 bits) -value is encoded within the instruction ƒ *Register: the name of a register -register name is converted to a number and encoded within the instruction *Memory: reference to a location in memory memory address is encoded within the instruction, or a register holds the address of a memory location

Direct Memory Operands -A direct memory operand is a named reference to storage in memory -The named reference (label) is automatically dereferenced by the assembler. The brackets imply a deference operation .Data Var1 byte 10h .code Mov al, var1 Mov al, [var1]

MOV Instruction *MOV Instruction Move (copy) from source to destination *Syntax: MOV destination, source -destination operand’s contents change source operand’s contents do not change -Both operands must be the same size -Both operands cannot be memory operands -CS, EIP, and IP cannot be the destination -No immediate to segment moves

Here is a list of the general variants of MOV, excluding segment registers: -MOV reg, reg -MOV mem, reg -MOV reg, mem -MOV mem, imm -MOV reg, imm

Examples: .data count BYTE 100 wVal WORD 2 .code mov bl,count mov ax,wVal mov count,al mov al,wVal ; error, AL is 8 bits mov ax,count ; error, AX is 16 bits mov eax,count ; error, EAX is 32 bits

Arithmetic Instructions – Processing Binary Data Description ADC Add with carry IDIV Divide signed ADD Add IMUL Multiply signed CBW Convert byte to word MUL Multiply unsigned CDQ Convert doubleword to quadword NEG Negate CWD Convert word to doubleword SBB Subtract with borrow CWDE Convert word to extended doubleword SUB Subtract DIV Divide unsigned

XCHG Instruction XCHG Instruction exchanges the values of two operand. At least one operand must be a register – -No immediate operands are permitted

example

INC and DEC Instructions -Add 1, subtract 1 from destination operand, operand may be register or memory . INC destination : Logic: destination ← destination + 1 DEC destination: Logic: destination ← destination – 1

Example:

ADD Instruction ADD Instruction ADD destination, source: Logic: destination ← destination + source

Example:

SUB Instruction SUB Instructions o SUB destination, source Logic: destination ← destination – source

example

7.3.1 Addition and Subtraction Of Binary Data Format for ADD and SUB instructions: (note: there are no direct memory-to-memory operations)

NEG Instruction NEG (negate) Instruction -Reverses the sign of an operand - Operand can be a register or memory operand

example

• Implementing Arithmetic Expressions

Exercise Assume that BYTE1 is defined as DB 05, show the result for the following instructions:

Indirect Addressing -An indirect operand holds the address of a variable, usually an array or string. -It can be dereferenced (just like a pointer).

example

Arrays Array Sum Example -Indirect operands are ideal for traversing an array -The register in brackets must be incremented by a value that matches the array type

Indexed Operands Indexed operands -An indexed operand adds a constant to a register to generate an effective address. There are two notational forms: [label + reg] label[reg]

example

Pointers Pointers Declare a pointer variable that contains the offset of another variable

example

Shift instructions SHR/SAR/SHRD: Shifting Bits Right SHR – shift logical right SAR – shift arithmetic right

Example of the SHR instruction

SHL/SAL/SHLR : Shifting Bits Left

Example:

JMP and Loop Instructions JMP Instruction : JMP is an unconditional jump to a label that is usually within the same procedure . Syntax: JMP target Logic: EIP ← target JMP Example : top: . jmp top

LOOP Instruction LOOP Instruction The LOOP instruction creates a counting loop Syntax: LOOP target The assembler calculates the distance, in bytes, between the offset of the following instruction and the offset of the target label. It is called the relative offset The relative offset is added to EIP.

LOOP Example Add 1 to AX each time the loop repeats When the loop ends, AX = 5 and ECX = 0 mov ax, 0 mov ecx,5 L1: add ax loop L1

Unconditional Transfer Instructions

1. CALL and RET[n] Instructions CALL instruction is to shift control to the procedure that is called. RET[n] instruction is to return control to the procedure that made the call. Usually the RET[n] instruction is the last instruction to be executed in the called procedure. Its format:

3. INT instruction enable program to interrupt its own processing INT exits normal processing and access the Interrupt Vector Table in low memory to determine the address of requested routine. The operation then transfer to BIOS or OS for specified action and returns to the program to resume processing. Refer to section 5.5.6 for examples of INT instructions.

Conditional JUMP Instructions Format for conditional jump (Jnnn) is: There are varieties of conditional jump instructions that transfer control depending on settings in the flags register: ZF, CF, OF, AF and SF. Table 7.7.1 below shows some example of conditional jump that are used for unsigned data. The LOOP A20 statement in Table 7.5.3, can be replaced by using the conditional statement, JNZ A20 and DEC CX as in Table 7.7.2.

Table 7.7.2

conditional jump instructions usually used with other instructions: CMP, INC, DEC etc. the following are examples of conditional jump instruction:

Thanks for listening