Lab2

.pdf

School

University of Guelph *

*We aren’t endorsed by this school

Course

2030

Subject

Computer Science

Date

Feb 20, 2024

Type

pdf

Pages

23

Uploaded by harikrishans995

Report
Lab Number 2 1 Overview In this lab, we will continue our exploration of the 68000’s ISA by considering some of its data types, data-movement instructions, and arithmetic instructions. Objectives Upon completion of this lab you will be able to: § Understand how data-movement and arithmetic instructions (MOVE, SWAP, ADD, SUB, MUL, DIV, and EXT) function with different size data, and § Understand how the flags in the condition-code register (CCR) are updated based on the result produced by different program instructions execution. Preparation Prior to commencing with the lab, you should review your course notes and perform the following reading assignments from your textbook (if you have not already done so): Section 2.2.1 (Byte, Word, Longword Operations) Section 3.2.1 (MOVE, LEA) Section 3.2.2 (ADD, SUB, MULS, MULU, DIVU, DIVS, EXT) Section 3.2.4 (SWAP) Section 2.2.5 (Condition Code Bits) Data Types and Operations CIS*2030 Lab Number 2 Name: _______________________________________________ Mark: _____________/70
Lab Number 2 2 Introduction Now that we know how to edit, assemble, run and debug an assembly-language program using Easy68K, we will employ this knowledge as we explore the mechanics of some of the more commonly used data-movement and arithmetic instructions that are part the ISA of the 68000. Part 1: Effects of different data types when moving data between registers Step 1 Review the MOVE instruction described on page 316 of your textbook along with the examples given in Section 2.2.1. Step 2 Download the sample program called Lab2a.X68 from the course website. Step 3 Start Easy68K. Once running, load the file Lab2a.X68 using the File->Open File menu choice. You should see something similar to below. (Remember to properly comment your code.)
Lab Number 2 3 Step 3 Assemble the program, and then invoke the Easy68K simulator. Before running the program, set a breakpoint at the MOVE.B D1,D2 instruction on line 18. This can be done by using your mouse to click on the green dot on the left-hand-side of the window. The green dot will turn red, as illustrated below. Now when you run the program, the simulator will execute all of the instructions up to the MOVE instruction on line 18. Step 4 Run the program. When prompted in the console window to enter a decimal number, enter the following value: 305419896 10 . Step 5 The simulator should now be stopped at the breakpoint on line 18. What are the 32-bit hexadecimal values in data register D1 through D5 ? Record these values in the second column (labeled “Before”) of the table below. [2 points]
Lab Number 2 4 Register Before After D1 D2 D3 D4 D5 Step 6 Now run the program to completion by pressing the run button. Once the program finishes executing, fill in the third column of the table above (labeled “After”) with the new 32-bit hexadecimal values. Questions Now answer the following questions related to the previous program: 1. Why do data registers D2 and D3 contain different values even though according to the code they appear to be “copies” of D1 ? Be precise. [1 point] 2. Do data registers D3 and D5 contain the same or different values? If they contain the same values, explain why this is given that the assembly-language instructions on lines 19 and 21, respectively, of the listing file appear to be different from one another. Does the assembler make a size assumption? [2 points]
Lab Number 2 5 Part 2: Initializing registers using constant values It is common practice to initialize registers prior to using them. For example, in the previous program, data register D1 was initialized with a 32-bit value entered by the user using the keyboard at runtime. Another common way to initialize registers prior to their first use is by using a MOVE instruction in combination with the immediate addressing to copy a constant value (specified at assemble time) into the register. Recall from class, an immediate (or constant) value can be specified in an instruction that supports immediate addressing by placing a # before the numeric value. Moreover, numeric values can be specified either in hexadecimal, binary, or decimal by preceding the number with a $, %, or nothing, respectively. During the assembly process, the constant value is stored as part of the machine instruction using one (or two) extension word(s). Step 1 Download the sample program called Lab2b.X68 from the course website. Step 2 Start Easy68K. Once running, load the file Lab2b.X68 using the File->Open File menu choice. You should see something similar to below. (Remember to properly comment your code.)
Lab Number 2 6 This program shows how the previous program (Lab2a.X68) can be adapted so that data register D1 is now initialized with the decimal value 305419896 10 using a MOVE instruction. The # before the decimal value tells the assembler that the value is a constant specified by the programmer, and that the value is expressed in decimal versus binary (%) or hexadecimal ($). Notice that in this program the value to be loaded into D1 is known at assembly time, whereas the value loaded into D1 in the previous program was not known until runtime. Step 3 Assemble the program. Line 11 of the listing file shows the machine code generated for the MOVE instruction used to initialize data register D1. What does the hexadecimal value 12345678 in the machine code represent? [1 point] Step 4 Now run the program to completion by pressing the run button. Examine the results produced by the program and confirm to yourself that the program produces the same results as the previous program (Lab2a.X68). Questions Now answer the following questions related to the previous program: 3. Explain why the assembler instruction MOVE.L #305419896,D1 uses a .L suffix rather than a .W or .B suffix. [1 point]
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help