代写 Go (CSCI 321) Project Four: Copying a Word Array to a Double Word Array

(CSCI 321) Project Four: Copying a Word Array to a Double Word Array
Objectives:
• Implementing arrays
• Apply indexed address
• Write loop
1.实现阵列
2.应用索引地址
3、写循环
Problem Description:
Write a program that uses a loop to copy all the elements from an unsigned Word (16-bit) array into an unsigned doubleword (32-bit) array.
编写一个程序,使用循环将无符号字(16位)数组中的所有元素复制到无符号双字(32位)数组中。
Hint:
You may study the book example “Loop Instruction” on page 124 first. However, this project has three different things from the book’s example.
• You need two index register. One for the index of source, another for index of target. You can use Register ESI for index of source and Register EDI for index of target
• You will need to initialize the values of ESI and EDI as 0 since the target string is stored right after the source string in memory
• You will need to know the LENGTHOF the source array. Please see the section on the LENGTHOF operator on page 116 on how to do that.
你可以先学习第124页的“循环指令”这本书的例子。然而,这个项目与书中的例子有三个不同之处。
1.您需要两个索引寄存器。一个用于源索引,另一个用于目标索引。可以使用register esi作为源索引,使用edi作为目标索引。
2.您需要将esi和edi的值初始化为0,因为目标字符串存储在内存中源字符串之后。
3.您需要知道源数组的长度。请参阅第116页的lengthof操作部分,了解如何操作。
For example:
var1 WORD 1, 2, 3, 4, 5
count = LENGTHOF var1

How to View Output:
After Chapter Five, you will be able to write statement to print out the output on screen. So far, you need to see output in memory. After your project can be assembled and run successfully, you may do following things:
在第五章之后,您将能够编写语句在屏幕上打印输出。到目前为止,您需要在内存中看到输出。项目组装和运行成功后,可以执行以下操作:
• Click on the grey bar located on the left of side of the “invoke ExitProcess, 0” statement to set up the Break Point

• Go to Debug and click on Start Debugging
• Go to Debug -> Windows -> Memory -> Memory 1 (or: ALT + 6). You will see the memory window on the bottom of your code.
1.单击“invoke exitprocess,0”语句左侧的灰色条以设置断点。
2.转到“调试”并单击“启动调试”
3.转到Debug->Windows->Memory->Memory 1(或:Alt+6)。您将看到代码底部的内存窗口。

• In the Address field at the top of the memory window, type the & (ampersand) character, followed by the name of the array, and press Enter. For example, &myArray would be a valid address expression. The memory window will display a block of memory starting at the array’s address. See the following screenshot
4.在“内存”窗口顶部的“地址”字段中,键入&(和号)字符,后跟数组名称,然后按Enter键。例如,&myarray将是有效的地址表达式。内存窗口将显示从数组地址开始的内存块。请参见以下屏幕截图

To know that you got it right is this. Remember, the goal is to copy a 16-bit word to a 32-bit doubleword. As I have mentioned this before a doubleword is twice as big as a word, so if a word is 16-bit then a doubleword is 16*2 = 32-bits.
Now look at the above screenshot within the red lines. This is in hexadecimal number system. Now, if my array consists of an integer array of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and remember 10 decimal in hex is A….you can see that the first address in memory (0x00404000) has those values. Remember those array integers are 16 bits. Therefore, you see 01 00 02 00. Each of those values are 4-bits long, so 01 00 is 16-bits, then 02 00 is 16-bits and so one.
Now look at the second address. You are copying from a 16-bit address to a 32-bit address; therefore, 01 00 00 00 is 32-bits, then 02 00 00 00 is 32-bits, and so on and it continues on the third address.
After you check the result, press F10 to continue and finish the program execution.
知道你做对了就是这样。记住,目标是将16位字复制到32位双字。正如我之前提到的,双字是字的两倍大,所以如果一个字是16位,那么双字是16*2=32位。
现在看看上面红线内的截图。这是十六进制数字系统。现在,如果我的数组由一个1、2、3、4、5、6、7、8、9、10的整数数组组成,那么记住10个十六进制的十进制数是……,您可以看到内存中的第一个地址(0x0044000)具有这些值。记住这些数组整数是16位。因此,您可以看到01 00 02 00。每个值都是4位长,所以01 00是16位,然后02 00是16位,所以是1位。
现在看看第二个地址。您正在从16位地址复制到32位地址;因此,01 00 00 00是32位,02 00 00是32位,依此类推,它继续在第三个地址上。
检查结果后,按F10继续并完成程序执行。
Due Date:
You need to turn in YourNameProj4.asm via Blackboard. Due date will be announced on Blackboard.