欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

用子程序结构求给定的8个数中最小偶数,并在屏幕上显示最小偶数。

程序员文章站 2022-06-07 09:07:01
...

用子程序结构求给定的8个数中最小偶数,并在屏幕上显示最小偶数。
10,11,-20,-35,24,125,88,-90
(1) 附上程序

data  segment 
num  db 10,11,-20,-35,24,125,88,-90 
a db 126 
d db 10
y db (?)
x db (?)
data ends 
code segment
assume cs:code,ds:data 
main proc far 
    push ds 
	sub ax,ax
	push ax 
	mov ax,data
	mov ds,ax 
	call min 
 call print1
	ret 
main endp 
min proc 
	push ax 
	push cx 
	push si 
	lea si,num 
	mov cx,10
 l1 : mov al,[si] 
 test al,01h
	jnz a1 
 cmp al,a 
 jge a1 
 mov a,al
 a1 :inc si 
	loop l1 
	pop si 
	pop cx 
	pop ax 
	ret 
min endp 
max proc 
	push ax 
	push cx 
	push si 
	lea si,num 
	mov cx,10
 l2 : mov al,[si] 
 test al,01h
 jz a2 
	cmp al,a 
 jle a2 
 mov a,al
  a2 :inc si 
	loop l2 
	pop si 
	pop cx 
	pop ax 
	ret 
max endp 

print1 proc 
          mov ah,02h
          mov dl,2dh
          int 21h
          mov al,a
          mov ah,00h
          dec al
          not al
          div d
          mov y,ah
          and al,0fh
          add al,30h
          mov ah,02h
          mov dl,al
          int 21h
          mov al,y
         and al,0fh
         add al,30h
         mov ah,02h
         mov dl,al
         int 21h
         mov dl, 0dh
         mov ah,2
         int 21h
         mov  dl, 0ah
         mov ah,2
         int 21h
        ret 
print1 endp
print2 proc 
          mov al,a
          mov ah,00h
          div d
          mov y,ah
          div d
          mov x,ah
          and al,0fh
          add al,30h
          mov ah,02h
          mov dl,al
          int 21h
         mov al,x
         and al,0fh
         add al,30h
         mov ah,02h
         mov dl,al
         int 21h
         mov al,y
         and al,0fh
         add al,30h
         mov ah,02h
         mov dl,al
         int 21h
print2 endp 
 code ends 
          end main

(2) 结果截图
用子程序结构求给定的8个数中最小偶数,并在屏幕上显示最小偶数。

相关标签: 汇编语言 汇编