联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2024-03-12 08:50

CSCI 2525 Assignment 3

Create the two programs described below. Upload them to Canvas prior to the

due date.

1. reorder.asm

- rearranges the values of the following array into the order shown. Use

only MOV and XCHG to accomplish the desired result. Do not use any immediate

values except in the .data section. Use only direct offset addressing to

accomplish the goal. Be as efficient as you can. Note: You will have to look in

memory to see if you have achieved your goal. You may not create other data

elements to assist with this problem.

Original Array: MyArray WORD 5767h, 2132h, 4798h

At the end of this part of the assignment, the array will be in increasing order.

This means in memory, not just the registers.

You will be using a new Irvine Library function. DumpMem.

In order to use this you need the following information.

ESI = Offset of myArray

ECX = # of elements in myArray. Use the $ directive in .data to get this

information.

EBX = unit size (good place to use TYPE instruction).

After you have the information required in ESI, ECX, and EBX, you will simply type

call DumpMem on the next line.

To be clear, it will be something like the following (where you will fill in the

xxxxxxx)

mov esi, xxxxxxx

mov ecx, xxxxxxx

mov ebx, xxxxxxx

call dumpmem

2. fibonacci.asm

- computes the following.

a. Compute fib(n) for n = 2, 3, …, 9 using an array, of the appropriate

size and type. If you so desire, you may declare a value for fib(0) and

fib(1). However, all computation of the remaining elements of the

array must be done by your program, no use of immediate values is

allowed. In other words, you must use the formula shown below

(figure 1) to determine the values of the remainder of the required

elements. Do not declare an array pre-filled with the required

elements.

b. After your array is filled with required values, store fib(5) through

fib(9) in consecutive bytes of the ebx register starting from the

lowest byte; that is, fib(5) is stored in the low byte (bl) of ebx, fib(6)

is stored in the next byte (bh), fib(7) is stored in the next byte of ebx

and fib(8) is stored in the highest byte.

Figure 1: Information on the Fibonnaci sequence

Notes for Fibonacci.asm

1. Assume fib(0)=0, fib(1)=1. These are the only two values you may directly

initialize in the .data section. You can declare them as part of the array.

2. You may use any instruction/directive/operator through chapter 4 pg 128,

including any of the arithmetic operators +, *, /, -.

3. Your program must use indirect operands in some way as discussed in

chapter 4.

4. Your program must calculate all values of the Fibonacci sequence except

Fib(0) and Fib (1).

5. You must use a loop.

Specifications for Entire Assignment

1. Your program must make calls to DumpRegs as necessary.

2. You may not use immediate values for any portion of this assignment except

where specifically allowed.

Example: mov ebx, 08050302 ;// This is not allowed

3. Part of the program will be graded based on program style. Please write clear

and logical code with sufficient commenting, whitespace, etc.


相关文章

版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp