在内存中一串数值,判断数值是否大于42H并统计个数
程序运行:
代码:
datas segmentidata equ 100hnums db idata dup(41h,42h,43h,42h,41h,43h,30h)count dw $-numsup dw 0down dw 0upNumber db 'up:$'downNumber db 0dh,0ah,'down:$'datas endsstacks segmentstacks endscodes segmentmain proc farassume cs:codes,ds:datas,ss:stacksstart:push ds sub ax,axpush axmov ax,datas ;初始化dsmov ds,axmov cx,countmov bx,0s:cmp nums[bx],42hja upAdd ;如果muns[bx]>42h,则跳到up++jb downAdd ;如果muns[bx]<42h,则跳到down++jmp s1upAdd:inc up ;up++jmp s1downAdd: inc down ;down++s1:inc bxloop s ;输出up提示lea dx,upNumbermov ah,9int 21h;输出upmov ax,up call print;输出down提示lea dx,downNumbermov ah,9int 21h;输出downmov ax,down call print retmain endpprint proc nearmov bx,10s: mov dx,0 div bxadd dx,30hpush dxinc cxcmp ax,0jnz ss1: pop dxmov ah,2int 21hloop s1ret
print endpcodes endsend main