分别选择确定,取消,检测是否有正确的返回值,实验测试如下:
(3) 对第二个小实验进行编译链接
(4) 对第二个小实验进行检测,看是否正确,测试结果如下:
结论:经过上述测试,实验结果与理论值相符,正确
实验四
实验内容:把数组中的n个双字型元素按从大到小(从小到大)的顺序排
列。增加一个交换标志,在排序完成时不再执行多余的外层循环。 熟悉WINDBG调试环境。使用WINDBG观察内存变量,并观察结果。
流程图
开始 EAX =arr[ESI*4] EBX =arr[ESI*4+4] ECX = n-1 EAX>EBX? flag fla1 Flag=1 arr[ESI*4]=EBX ECX>0? arr[ESI*4+4]=EAX flag= 1 flag==1? ESI= 0 flag= 0 ESI=ESI+1 ESI .386 .model flat,stdcall option casemap:none 结束 ECX =ECX-1 includelib msvcrt.lib printf PROTO C:dword,:vararg scanf PROTO C:dword,:vararg .data input_single_num byte '%d',0 output_single_num byte '%d ',0 output_single_num_crlf byte '%d',0ah,0 numberOfElements dword ? number dword 128 dup(?) .code getInput proc local index, temp, numberOfEle:dword invoke scanf,offset input_single_num, offset numberOfElements push ecx mov ecx,numberOfElements mov numberOfEle,ecx mov index,0 input: push eax mov eax,4 mul index mov temp,eax add temp,offset number pop eax invoke scanf, offset input_single_num, temp mov ecx,numberOfEle dec numberOfEle inc index loop input pop ecx ret getInput endp bubbleSort proc local flag:byte pusha mov flag,0 ;Get the number of elements, and save it at ecx mov ecx,numberOfElements dec ecx loop_out: xor esi,esi loop_in: mov eax,number[esi*4] mov ebx,number[esi*4+4] cmp eax,ebx jg control mov flag,1 mov number[esi*4],ebx mov number[esi*4+4],eax control: inc esi cmp esi,ecx jb loop_in test flag,1 jz endloop mov flag,0 loop loop_out endloop: popa ret bubbleSort endp output proc pusha mov ecx,numberOfElements dec ecx dec ecx xor esi,esi isover: push ecx invoke printf, offset output_single_num, number[esi*4] pop ecx cmp esi,ecx inc esi jb isover invoke printf, offset output_single_num_crlf, number[esi*4] popa ret output endp start: 百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库汇编语言程序设计实验报告(4)在线全文阅读。
相关推荐: