mov ah,1 int 21h cmp al,'a' jl l cmp al,'z' jg l
mov cl,al
lea dx,crlf mov int lea dx,h2 mov ah,9
int 21h
dec mov mov int
mov mov int
inc mov
mov ah,2
int 21h
mov mov int
inc mov mov
int 21h
mov int main endp
s3 ends
end
ah,9 21H cl
dl,cl ah,2 21h dl,' ' ah,2 21h
cl
dl,cl dl,' ' ah,2 21h
cl
dl,cl ah,2 ah,4ch 21H main ;输出前导字符 ;输出该字符
;输出后导字符 6.把一个包含20个数据的数组M分成两组:正整数组P和负整数组N,分别把这两个数组中的数据的个数显示出来
s1 segment stack
dw 100h dup(?) top label word s1 ends
s2 segment
h1 db 'the positive number is: ','$' h2 db 'the negative number is: ','$' crlf db 0dh,0ah,24h
array dw 50h,-11h,61h,-22h,72h,-33h,73h,-41h,74h,21h,67h,-90h,73h,77h,-1h,-89h,-11h,61h,-22h,20h,'$' 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 si,0
l: mov dx,array[si] cmp dx,0
jl addlow ;有符号数比较用jl add si,2 cmp si,40 jz exit jmp l
addlow: inc bx add si,2
cmp si,40 jz exit jmp l
exit: lea dx,h2 mov ah,9
int 21h
mov ax,bx call print
lea dx,crlf mov ah,9 int 21h lea dx,h1 mov ah,9 int 21h
mov ax,20
sub ax,bx call print jmp atend
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
l2: pop dx mov ah,2 int 21h dec si cmp si,0 jnz l2
ret print endp
atend: mov ah,4ch int 21H
打印数字字符的子程序 ;
main endp s3 ends
end main
7.打印输出首地址为data的20个字数组中的最小偶数
s1 segment stack
dw 100h dup(?) top label word s1 ends
s2 segment
h1 db 'the min even number is: ','$'
crlf db 0dh,0ah,24h
data dw 50,-11,61,-22,72,-33,73,-41,74,21,67,-90,73,77,-1,-89,-11,61,-22,20,'$' s2 ends
s3 segment
assume cs:s3,ds:s2,ss:s1 main proc far
mov ax,s1 mov ss,ax lea sp,top mov ax,s2
mov ds,ax
mov bx,65534 ;bx存最小数,初始令最小值置为65534 mov si,0 mov cl,100
mov dl,2
l2: mov ax,data[si] cmp ax,0
jnl l4
neg ax ;如果是负数,则求补
l4: div cl
mov al,ah
mov ah,0 div dl cmp ah,0
jnz l1
cmp bx,data[si] ;比较最小值和数组中的每个数
jl l1 ;如果数组中的数大于最小值跳转到l1
mov bx,data[si] ;如果数组中的数小于最小值则将其赋给最小值 l1: add si,2
cmp si,40 jz exit
jmp l2
exit: lea dx,h1 mov ah,9 int 21h
cmp bx,0 jnl l5 neg bx
mov dl,'-' mov ah,2
int 21h
l5: mov ax,bx
call print jmp atend
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
l3: pop dx mov ah,2
调用子程序输出最小值 ;