2.
data segment
grade db 61,73,82,90,100,45 dup(70) avg1 db ? ;平均值的商 avg2 db ? max db ?
;平均值的余数 ;最大值
min db ?;最小值 data ends code segment
assume cs:code,ds:data
mov ax,data mov ds,ax mov si,0 mov bx,0 mov cx,50 mov ax,0 cbw add bx,ax inc si start:
l1: mov al,grade[si]
loop l1 mov ax,bx mov bl,50 div bl mov avg1,al mov avg2,ah mov si,0 ;找最大值 mov cx,50 mov al,grade[0] ja next0 mov al,grade[si] loop again0 mov max,al
again0: cmp al,grade[si]
next0: inc si
mov si,0 ;找最小值
mov bl,avg2 ;平均值的余数 call sub
mov dl,23h ;\分开不同数据 mov ah,2 int 21h
mov bl,avg1 ;平均值的商 call sub mov cx,50 mov al,grade[0] jna next1 mov al,grade[si] loop again1 mov min,al
again1: cmp al,grade[si]
next1: inc si
sub proc
mov ch,2 mov cl,4 mov al,bl and al,0fh cmp al,0ah jl next2
add al,37h ;\jmp down1
mov bl,min ;最小值 call sub
mov ax,4c00h int 21h
mov dl,23h ;\分开不同数据 mov ah,2 int 21h
mov dl,23h ;\分开不同数据 mov ah,2 int 21h
mov bl,max ;最大值 call sub
again2: rol bl,cl
next2: add al,30h ;\down1: mov dl,al
mov ah,2 int 21h dec ch jnz again2
ret
sub endp code ends
end start
3.
data segment
buf db 50 ;定义缓冲区 db 40 db 40 dup(0)
crlf db 0dh,0ah,'$' ;回车换行 data ends
stack segment stack db 100 dup(0) stack ends
code segment
assume ds:data, ss:stack, cs:code start: mov ax,data
mov ds,ax lea dx,buf
;输入字符串