汇编语言——练习题2.1
题目:
统计正数(负数)的个数
内容:DAT开始的单元中存放N个字节有符号数,统计正数的个数存入T0单元中;负数的个数存入T1单元中;
Dat DB X1,……,XN
T0 DB ?
T1 DB ?
要求:熟练掌握分支程序设计方法
INCLUDE irvine32.inc
.data
DAT db 32,-10,26,17,44,61,-9,0,44
cnt equ ($-DAT)
t0 db 0
t1 db 0
.code
start :
xor eax,eax
xor esi,esi;
mov ecx,cnt
again:
mov al,DAT[esi]
cmp al,0
je next
cmp al,0
jg next_cmp
inc t1
jmp next
next_cmp:
inc t0
next:
inc esi
loop again
xor eax,eax
mov al,t0
call writeint
call crlf
mov al,t1
call writeint
call crlf
exit
end start