汇编语言——练习题5.1

版权声明:未经本人同意,禁止转载。 https://blog.csdn.net/qq_34022601/article/details/89052182

 

题目:

将从键盘输入的N个无符号数保存到数组DAT ,找出N个无符号数中的偶数存放到数组P,统计并在终端上显示数组P的数据个数no

             DAT  DW   X1,……,XN

             P    DW   n dup (?)

             no    DW  

要求:1、求偶数数组P的功能用子程序实现

           2、画主程序及子程序流程图

                         3、熟练掌握综合程序设计方法


流程图:


代码:

INCLUDE irvine32.inc
.data
	DAT dw 5h,8h,12h,33h,64h,77h,88h,15h,22h
	;equ类似于宏定义,这里取到了数组DAT的所有字节数
	;对于dw cnt/2 为数组长度;对于dd cnt/4 为数组长度
	cnt equ ($-DAT)/2
	P dw cnt dup(?)
	no dw 0
	two dw 2
.code
start :
	mov ecx,cnt
	xor esi,esi
	xor ebx,ebx
	again:
		xor edx,edx
		xor eax,eax
		;除2  --> dl中查看余数
		mov ax,DAT[esi*2]
		div two
		cmp dl,0
		jne next
		inc no
		mov P[ebx*2],ax
		inc ebx
	next:
		inc esi
		loop again	
	xor eax,eax
	mov ax,no
	call writeint
	call crlf
	exit
end start

猜你喜欢

转载自blog.csdn.net/qq_34022601/article/details/89052182