2020FZU汇编语言学习---实验加强题(一)

加强题(一)

在这里插入图片描述

include irvine32.inc 
.data
	dat	dword -5,-7,8,4,-8,-6,0,1
	max  dword  ?
	flag   byte  '0'
.code
main proc
	call find

	mov eax,  max	
	call writeint					;输出最小负偶数
	call crlf

	lea edx,flag
	call writestring				;输出flag的值
exit
main endp
;find子过程
find proc
xor	esi,esi
	xor   edx,edx
	mov ecx,lengthof dat
again:
	mov ebx, dat[esi*type dat]
	cmp ebx,0
	jge next						;判断是否<0
	
	mov eax,ebx
	
	and ebx, 01h				
	cmp ebx,0
	jne next				        ;判断是否为偶数
	
	inc edx
	cmp edx,1					
	ja  next1
	mov  max,eax					;找到第一个负偶数,赋值给max
next1:
        cmp eax, max
	jle next
	mov  max,eax
	mov flag,'1'				
next:
	inc esi
	loop again
ret
find endp
end main

此类题最好先写一个c++程序,如下

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[5]={-5,-7,8,4,-8,-6,0,1};
	int max,counter=0;
	for(int i=0;i<5;i++)
	{
		if(a[i]<0)
		{
			if(!(a[i]&1))
			{
				counter++;
				if(counter==1)  max=a[i];
				if(a[i]>max&&counter>1)  max=a[i];
			}
		}
	}
	cout<<max;
 } 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值