⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exam04.asm

📁 设从DATA开始的字节单元存入10个无符号数据
💻 ASM
字号:
sdata	segment
data	dw 10 dup(0h)
infor	db 0dh,0ah,'the max number is : '
max	dw 0h
	db 0dh,0ah,'the min number is : '
min	dw 0h
	db '$'
sdata	ends
code	segment
	assume	ds:sdata,cs:code
start:	mov ax,sdata		;initialize register
	mov ds,ax
	mov cx,0ah
	lea si,byte ptr data+19
	mov cx,0ah		;loop times
lopt:	call getnum		;get your enter number
	loop lopt		;get 10 numbers
	lea si,word ptr data
	mov ax,[si]
	mov bx,ax
	mov cx,0ah
lop1:	cmp [si],ax		;get the maximum
	jl  small
	mov ax,[si]		;if bigger replace ax
gohome1:inc si
	inc si
	mov dx,[si]
godorm:	loop lop1
	xchg ah,al		;put the maximum from
	mov max,ax		;register to memory
	xchg bh,bl		;the minimum
	mov min,bx
	mov ah,09h		;echo information
	lea dx,infor
	int 21h
over:	mov ah,4ch		;return to dos
	int 21h		
small:  cmp [si],bx		;get the minimum
	jg  gohome1		;if big the do not replace
	mov bx,[si]
	inc si
	inc si
	jmp godorm
getnum	proc			;child programme to get number
	push cx			;protect loop time
	mov cx,02h
lop2:	mov ah,08h		;use int 21h of 01 function
	int 21h			;to echo and get one character
	call ifecho
	loop lop2
	mov ah,02h		;echo 回车
	mov dl,0dh
	int 21h
	mov ah,02h		;echo 换行
	mov dl,0ah
	int 21h
	pop cx			;recover loop time
	ret
getnum	endp
ifecho	proc			;judge if your enter item 
	cmp al,1bh
	je  over
	cmp al,30h		;match to the require
	jl gohome
	cmp al,39h		
	jle display_digital	;is digital
	cmp al,41h
	jl gohome
	cmp al,46h
	jle display_letter	;is letter
	cmp al,61h
	jl gohome
	cmp al,66h
	jle display_letter	;is letter
gohome:	inc cx
gobed:	ret
ifecho	endp
display_digital:		;display the digital and
	mov ah,02h		;store it to memory
	mov dl,al
	int 21h	
	mov [si],al
	dec si
	jmp gobed
display_letter:			;display the letter between
	mov ah,02h		;a-f or A-F,and write in memory
	mov dl,al
	int 21h
	cmp al,60h
	jl  pass
	sub al,20h
pass:	mov [si],al
	dec si
	jmp gobed
code	ends
	end start

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -