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

2019-08-20 21:10

mov ah,4ch int 21H

main endp

skiplines proc near

mov bx,ax repeat: cmp bx,0 jz exit

lea dx,crlf mov ah,9 int 21h

dec bx jmp repeat

exit: ret

skiplines endp

s3 ends

end main

19.设有10个学生成绩分别是76, 69,84,73,88,99,63,100和80。试编写一个子程序统计60-69分,70-79分,80-89分,90-99分和100分的人数,并分别放到S6,S7,S8,S9,S10单元中

s1 segment stack

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

s2 segment

score dw 76,69,84,90,73,88,99,63,100,80,'$' s6 dw 0,'$' s7 dw 0,'$' s8 dw 0,'$' s9 dw 0,'$' s10 dw 0,'$' 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

repeat: cmp si,20 jz exit mov ax,score[si] cmp ax,100 jnz l mov bx,s10[0] inc bx mov s10[0],bx jmp l5 ;必须跳转到si加二那里

l: cmp ax,90 jb l2 mov bx,s9[0] inc bx mov s9[0],bx jmp l5

l2: cmp ax,80 jb l3 mov bx,s8[0] inc bx mov s8[0],bx jmp l5

l3: cmp ax,70 jb l4 mov bx,s7[0] inc bx mov s7[0],bx jmp l5

l4: mov bx,s6[0] inc bx mov s6[0],bx

l5: add si,2

jmp repeat

exit: mov ah,4ch int 21h

mainendp s3 ends

end main

20.编写子程序嵌套结构的程序,把整数分别用二进制和八进制显示出来

s1 segment stack

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

s2 segment

data dw 16h,32h,'$' ;要显示的两个数字 crlf db 0dh,0ah,24h,'$' s2 ends

s3 segment

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

repeat: cmp si,4 jz exit mov bx,data[si] call pairs

call print_crlf add si,2 jmp repeat

exit: mov ah,4ch int 21h

bando endp

pairs proc near mov cx,10h

l: rol bx,1 ;以二进制数输出—— jc print_one mov dl,'0' jmp print_zero

print_one: mov dl,'1'

print_zero: mov ah,2 int 21h loop l mov dl,' ' mov ah,2 int 21h mov dh,0 mov ch,4 mov cl,3 mov dl,bl and dl,7d add dl,30h push dx

rotate: ror bx,cl mov dl,bl and dl,7d add dl,30h push dx dec ch cmp ch,0 jnz rotate ror bx,1 mov dl,bl and dl,1 add dl,30h

;——以二进制数输出 ;以八进制数输出—— mov ah,2 int 21h

print: cmp ch,5 jz atend pop dx mov ah,2 int 21h inc ch jmp print ;——以八进制数输出

atend: ret

pairs endp

print_crlf proc near lea dx,crlf mov ah,9 int 21h ret

print_crlf endp

s3 ends

end bando

21.在D盘根目录建立一个文件abc.txt,第一次向文件写入“123456”六个字符,第二次增加“abcdefg”几个字符

s1 segment stack

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

s2 segment fn db 'd:\\abc.txt',0 fh dw ? buff1 db '1','2','3','4','5','6','$' buff2 db 'a','b','c','d','e','f','$' s2 ends

s3 segment

assume cs:s3,ds:s2,ss:s3


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

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

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

马上注册会员

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