Part 1: Data Transfer Instructions The most fundamental type of instruction in assembly language is the data transfer instruction. These instructions allow us to move data into and between registers and memory locations. They are the instructions we use when setting variables, initializing values, and reading data from memory. Start by creating a new assembly language program and filling in the necessary preprocessor directives. In the .data segment, create 3 variables with no initial values: A byte variable called "data1" Another byte variable called "data2" A dword variable called "bigdata" The most simple (and most-used) data transfer instruction is the MOV (move) instruction. This instruction simply takes data from one location and copies it into another of the same size. Note that the data is not removed from the original source - both the source and the destination will contain the same data once the MOV instruction completes. We have already used this instruction in previous labs - this is how we set the values of variables and registers. There are a few limitations to the MOV instruction: The source and destination operands must be the same size. Both operands can't be variables or memory locations The instruction pointer register can't be a destination (it can be read, but not overwritten) The MOV instruction takes 2 operands. The first is the destination, where the value will be moved into. The second is the source, where the value is copied from. Use two MOV instructions to set the value of the data1 variable to 100 and the value of the data2 variable to -50. Verify that they worked by looking at the variables' values using the debugger. In those last instructions, a memory location (variable) is being set to an immediate value (included directly in the program itself). The MOV instruction can also be used to move values from one location to another. Use a MOV instruction to move the value of the data1 variable into the AL register. Look at the value of data1 using the debugger. Notice how it didn't change after the MOV instruction? MOV only copies the value into the destination - the source is left unchanged.  There are other types of data transfer instructions that we can use. What if we want to move a value into a larger location? There are two instructions for this, based on whether the number is signed or unsigned: The MOVZX (move with zero extend) instruction copies a value into a larger location than the source, and fills the rest of the new space with 0's. If the original number was a negative signed number, its value will not be the same after the copy. The MOVSX (move with sign extend) instruction copies a value into a larger location than the source, and preserves the original value even if it's negative. This is only useful if the original value was a signed number. Both of these instructions will only work if the destination is a register. Use the MOVZX instruction to copy the value of AL into the ESI register. Verify that it's still holding the correct number using the debugger. The XCHG (exchange) instruction swaps the source and destination instead of just performing a copy. This changes both locations.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Part 1: Data Transfer Instructions

The most fundamental type of instruction in assembly language is the data transfer instruction. These instructions allow us to move data into and between registers and memory locations. They are the instructions we use when setting variables, initializing values, and reading data from memory.

Start by creating a new assembly language program and filling in the necessary preprocessor directives. In the .data segment, create 3 variables with no initial values:

  • A byte variable called "data1"
  • Another byte variable called "data2"
  • A dword variable called "bigdata"

The most simple (and most-used) data transfer instruction is the MOV (move) instruction. This instruction simply takes data from one location and copies it into another of the same size. Note that the data is not removed from the original source - both the source and the destination will contain the same data once the MOV instruction completes. We have already used this instruction in previous labs - this is how we set the values of variables and registers.

There are a few limitations to the MOV instruction:

  1. The source and destination operands must be the same size.
  2. Both operands can't be variables or memory locations
  3. The instruction pointer register can't be a destination (it can be read, but not overwritten)

The MOV instruction takes 2 operands. The first is the destination, where the value will be moved into. The second is the source, where the value is copied from.

Use two MOV instructions to set the value of the data1 variable to 100 and the value of the data2 variable to -50. Verify that they worked by looking at the variables' values using the debugger.

In those last instructions, a memory location (variable) is being set to an immediate value (included directly in the program itself). The MOV instruction can also be used to move values from one location to another.

Use a MOV instruction to move the value of the data1 variable into the AL register.

Look at the value of data1 using the debugger. Notice how it didn't change after the MOV instruction? MOV only copies the value into the destination - the source is left unchanged. 

There are other types of data transfer instructions that we can use. What if we want to move a value into a larger location? There are two instructions for this, based on whether the number is signed or unsigned:

  • The MOVZX (move with zero extend) instruction copies a value into a larger location than the source, and fills the rest of the new space with 0's. If the original number was a negative signed number, its value will not be the same after the copy.
  • The MOVSX (move with sign extend) instruction copies a value into a larger location than the source, and preserves the original value even if it's negative. This is only useful if the original value was a signed number.

Both of these instructions will only work if the destination is a register.

Use the MOVZX instruction to copy the value of AL into the ESI register. Verify that it's still holding the correct number using the debugger.

The XCHG (exchange) instruction swaps the source and destination instead of just performing a copy. This changes both locations. 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Fundamentals of Computer System
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education