汇编学习之找最大值

1.从键盘输入10个整数,并存放在内存中,求这10整数 最大值,并在屏幕中输出最大值

2. 在内存存放有两组整数中,分别求两组整数最大值,并在屏幕中输出各自最大值

1.

Include Irvine32.inc

.data


max dd ?

.code
main PROC
	mov ebx,0
	call readint
	mov max,eax
	again:cmp ebx,8
	ja final
	call readint
	cmp eax,max
	jb next
	mov max,eax
	next:add ebx,1
	jmp again
	final:
	mov eax,max
	call writeint
	exit
main ENDP
END main

2.

Include Irvine32.inc

.data
message byte " ",0
arr1 dd 32,44,55,1,10,2,5
arr2 dd 34,555,1,42,52,11,22
.code
main PROC
	mov ebx,0
	mov eax,arr1[0]
	again:cmp ebx,6
	ja final
	cmp eax,arr1[ebx*4]
	ja next
	mov eax,arr1[ebx*4]
	next:add ebx,1
	jmp again
	final:call writeint

	mov edx,offset message
	call WriteString

	mov ebx,0
	mov eax,arr2[0]
	again2:cmp ebx,6
	ja final2
	cmp eax,arr2[ebx*4]
	ja next2
	mov eax,arr2[ebx*4]
	next2:add ebx,1
	jmp again2
	final2:call writeint
	exit
main ENDP
END main

你可能感兴趣的:(汇编)