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

2019-08-20 21:10

int 21H main endp s3 ends

end main

3.是编写一段程序,要求在长度为10的数组中,找出大于42h的无符号数的个数并存入地址为up开始区域,找出小于42h的无符号数的个数并存入地址为down的开始区域,并分别显示up、down数组的个数和数组内的数字

s1 segment stack

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

s2 segment

h1 db 'the num of up array and the up array are(prints in decimalism) :','$'

h2 db 'the num of down array and the down array are(prints in decimalism) :','$' crlf db 0dh,0ah,24h

array db 0,50h,11h,61h,22h,72h,33h,73h,41h,74h,'$' ;定义数组array

up db 10 dup(?) ;定义up数组 down db 10 dup(?) ;定义down数组 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,1

mov bp,1

repeat: cmp array[si],42h ;把array数组中小于42h的值放到down数组里,大于42h的值放到up数组里面

jb downarray mov dl,array[si] mov up[bp],dl inc si cmp si,10 jz exit1

inc bp

jmp repeat

downarray: mov dl,array[si]

mov down[di],dl inc si cmp si,10 jz exit2 inc di

jmp repeat

exit1: sub di,1 jmp exit

exit2: sub bp,1

exit: mov dx,bp ;把分配好的up数组和down数组在其有效数字后面添加'$',便于后面的输出结束 mov up[0],dl inc bp mov up[bp],'$' mov dx,di

mov down[0],dl inc di

mov down[di],'$'

mov cl,10 mov si,0 lea dx,h1 mov ah,9 int 21h

PrintUparray:

cmp up[si],'$' jz next mov al,up[si]

call print inc si

jmp PrintUparray next: lea dx,crlf mov ah,9 int 21h

lea dx,h2 int 21h xor si,si

PrintDownArray:

cmp down[si],'$' jz atend mov al,down[si] call print inc si

jmp

print proc mov rediv: mov div mov mov push inc cmp jnz

break: pop add mov int dec cmp jnz

mov mov int ret print endp

atend: mov int

main endp s3 ends

end

PrintDownArray near ;print为输出十进制输出某个数的子程序 di,0 ah,0 cl dl,ah dh,0 dx di al,0 rediv dx dl,30h ah,2 21h di di,0 break dl,' ' ah,2 21H ah,4ch 21H main 4.键盘输入一段字符串,其中小写字母以大写字母输出,其他字符不变输出

s1 segment stack

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

s2 segment

h1 db 'Please input a string:','$' h2 db 'The changed string is:','$' crlf db 0dh,0ah,24h temp db ? 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

lea dx,h1 mov ah,9 int 21h mov si,0

l: mov ah,1 int 21h cmp al,0dh jz exit cmp al,'a' jl putin cmp al,'z' jg putin sub al,20h ;把小写字符变为大写字符

putin: mov temp[si],al ;把字符放到temp数组里 inc si jmp l

exit: lea dx,crlf ;输出tmp数组

mov ah,9 int 21h lea dx,h2 mov ah,9 int 21h

inc si

mov temp[si],'$' lea dx,temp mov ah,9 int 21h

mov ah,4ch int 21H main endp s3 ends

end main

5.从键盘上就收一个小写字母,找出它的前导字符和后续字符,在顺序显示这三个字符

s1 segment stack

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

s2 segment

h1 db 'Please input a lowercase: ','$' h2 db 'The the three chars are: ','$' 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

l: lea dx,h1 mov ah,9 int 21h


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

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

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

马上注册会员

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