24个汇编实例小程序(6)

2019-08-20 21:10

mov bx,0

l5: cmp data[si],'$' ;小于平均值的数的个数放到bx中 jz exit2

cmp ax,data[si] jz l6 jl l6 inc bx

l6: add si,2 jmp l5

exit2: mov ah,4ch int 21H

main endp s3 ends

end main

14.一直数组A包含15个互不相等的整数,数组B包含20个互不相等的整数。试编制一个程序,把既在A中又在B中出现的整数存放于数组C中并显示C中的数值

;两层循环比较得出两个数组中相同的数值 s1 segment stack

dw 100h dup(?) top label word s1 ends

s2 segment

a dw 1h,2h,3h,4h,5h,6h,7h,8h,9h,10h,11h,12h,13h,14h,15h,'$' b dw 21h,22h,23h,24h,25h,6h,18h,19h,10h,11h,12h,34h,14h,53h,31h,32h,33h,36h,7h,67h,'$' c dw 16 dup('$')

crlf db 0dh,0ah,24h s2 ends

s3 segment

assume cs:s3,ds:s2,ss:s3 main proc far mov ax,s1 mov ss,ax lea sp,top mov ax,s2 mov ds,ax

mov si,0 mov di,0 mov bp,0

l4: cmp di,40 jz l2 jmp l3

l2: add si,2 cmp si,30 jz exit mov di,0

l3: mov ax,a[si] mov bx,b[di] cmp ax,bx jnz l mov c[bp],ax add bp,2

l: add di,2 jmp l4

exit: mov bp,0

l6: cmp c[bp],'$' jz atend mov ax,c[bp] call print add bp,2 mov dl,' ' mov ah,2 int 21h jmp l6

print proc near

mov cl,10 mov si,0

repeat: div cl

mov dl,ah add dl,30h

mov dh,0 push dx inc si mov ah,0

cmp al,0 jnz repeat

l5: pop dx mov ah,2 int 21h dec si cmp si,0 jnz l5

ret print endp

atend: mov ah,4ch int 21H

main endp s3 ends

end main

15.设在A、B和D单元中分别存放着三个数。若三个数都不是0,则求出三个数的和并存放在S单元,若其中有一个数为0,则把其它两个单元也清零。请编写此程序

s1 segment stack

dw 100h dup(?) top label word s1 ends

s2 segment

a dw 1h,'$' b dw -11h,'$' d dw 0h,'$' s dw 2 dup('$')

crlf db 0dh,0ah,24h s2 ends

s3 segment

assume cs:s3,ds:s2,ss:s3 main proc far mov ax,s1

mov ss,ax lea sp,top mov ax,s2 mov ds,ax mov ax,a[0] mov bx,b[0] mov dx,d[0] cmp ax,0 jz l cmp bx,0 jz l cmp dx,0 jz l mov cx,0 cmp ax,0 jnl add_ax neg ax ;减法需先求补 sub cx,ax jmp l2

add_ax: add cx,ax l2: cmp bx,0 jnl add_bx neg bx sub cx,bx jmp l3

add_bx: add cx,bx l3: cmp dx,0 jnl add_dx neg dx sub cx,dx jmp l4

add_dx: add cx,dx l4: mov s[0],cx jmp exit

l: mov a[0],0 mov b[0],0 mov d[0],0

exit: mov ah,4ch int 21H

main endp s3 ends

end main

16.从键盘输入一系列字符(以回车键结束),并按字母、数字和其他字符分类计数,最后显示这三类的计数结果

s1 segment stack

dw 100h dup(?) top label word s1 ends

s2 segment

letter db 'the number of letter: ','$' digit db 'the number of digit: ','$'

others db 'the number of other chars: ','$' crlf db 0dh,0ah,24h s2 ends

s3 segment

assume cs:s3,ds:s2,ss:s3 main proc far mov ax,s1 mov ss,ax lea sp,top mov ax,s2 mov ds,ax mov bx,0 mov cx,0 mov dx,0

repeat: mov ah,1 int 21h cmp al,0dh jz exit cmp al,30h jb count_others cmp al,'z' jnb count_others cmp al,39h jb count_digit cmp al,'A'


24个汇编实例小程序(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:人行横洞施工方案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: