32位汇编语言 在一段数组中找最大数 x86 汇编语言 asm文件 irvine32 intel 汇编语言
题目:
Create a procedure named FindLargest that receives two parameters: a pointer to a signed doubleword array, and a count of the array’s length. The procedure must return the value of the largest array member in EAX. Use the PROC directive with a parameter list when declaring the procedure. Preserve all registers(except EAX) that are modified by the procedure. Write a test program that calls FindLargest and passes three different arrays of different lengths. Besure to include negative values in your arrays. Create a PROTO declaration for FindLargest.
创建一个名为FindLargest的过程,该过程接收两个参数:指向有符号双字数组的指针和数组长度的计数。该过程必须返回EAX中最大数组成员的值。在声明过程时,将PROC指令与参数列表一起使用。保留由过程修改的所有寄存器(EAX除外)。编写一个测试程序,调用FindLargest并传递三个不同长度的数组。请确保在数组中包含负值。为FindLargest创建PROTO声明。
代码:
; author: BoPang
; email: 1275189619@qq.com
; 2021/7/11
include Irvine32.inc
FIndLargest PROTO, pArray: ptr SDWORD,
arrayLength: DWORD
.data
Array SDWORD 5, 3, -2, 4, 8
;arrayLength DWORD 5
.code
main PROC
INVOKE FindLargest, ADDR Array, lengthof Array-1
call WriteDec
exit
main ENDP
FindLargest PROC,
pArray: ptr SDWORD,
arrayLength: DWORD
push esi
push ecx
;dec arrayLength
mov ecx, arrayLength
mov esi, pArray
mov eax, [esi]
ADD esi,4
L1:
mov ebx,[esi]
cmp eax, ebx;[esi]
jge A1
mov eax, ebx;[esi]
A1:
add esi,4
loop L1
pop ecx
pop esi
ret
FindLargest ENDP
END main
初学汇编语言,如有错误请多指正!
上一篇: 分别用五种汇编语言实现数组
下一篇: 百度搜狗蜘蛛池,快速提升网站收录量的方法