写一个完整的8086汇编语言程序:键盘输入10个数据,存入一维数组中(字),并找出数组中最大值显示在屏幕上。
源码;Program:
;Author:Nonoas
;Date:20191106
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h ; header file for input/output
cr EQU 0dh ; carriage return character
Lf EQU 0ah ; line feed
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
prompt1 byte ".Enter a number of Array:",0
prompt2 byte cr,lf,"The max number is:",0
number byte 20 dup (?)
maxNum byte 20 dup (?)
nbrArrary WORD 100 dup (?)
count word ?
.CODE ; start of main program code
_start:
mov ecx,10
mov count,1
mov dx,count
lea ebx,nbrArrary
forCount:
itoa count,dx
output count
output prompt1
input number,20
atoi number
mov [ebx],ax
add dx,1
add ebx,2
loop forCount
mov ecx,9
lea ebx,nbrArrary
mov ax,[ebx]
forCount1:
add ebx,2
cmp [ebx],ax
jb endJudge
mov ax,[ebx]
endJudge:
loop forCount1
output prompt2
itoa maxNum,ax
output maxNum
INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code
题目二
写一个完整的8086汇编语言程序:键盘输入10个数据,存入一维数组中(双字),并找出数组中最小的偶数显示在屏幕上,若没有偶数则显示“没有偶数!”。
源码;Program:
;Author:Nonoas
;Date:20191106
.386
.MODEL FLAT
ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
INCLUDE io.h ; header file for input/output
cr EQU 0dh ; carriage return character
Lf EQU 0ah ; line feed
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
prompt1 byte ".Enter a number of Array:",0
prompt2 byte cr,lf,"The min even number is:",0
prompt3 byte cr,lf,"There is no even number",0
number byte 20 dup (?)
minNum byte 20 dup (?)
nbrArrary DWORD 100 dup (?)
count DWORD ?
.CODE ; start of main program code
_start:
mov ecx,10
mov count,1
mov edx,count
lea ebx,nbrArrary
forCount:
dtoa count,edx
output count
output prompt1
input number,20
atod number
mov [ebx],eax
add edx,1
add ebx,4
loop forCount
mov ecx,10 ;judge have even
lea ebx,nbrArrary
FIND:
mov al,[ebx]
test al,01H ;if isodd, jump to next
jnz NEXT
mov edx,[ebx] ;if iseven, save it
jmp FINDEND
NEXT:
add ebx,4
loop FIND
mov edx,0FFFFH
jmp EXIT
FINDEND: ;if find a even , jump here
mov ecx,10 ;find the min even
lea ebx,nbrArrary
FIND2:
mov al,[ebx]
test al,01H
jnz NEXT2 ;if is odd, jump to next
cmp edx,[ebx]
jb NEXT2
mov edx,[ebx]
NEXT2:
add ebx,4
loop FIND2
output prompt2
dtoa minNum,edx
output minNum
jmp endall
EXIT:
output prompt3
jmp endall
endall:
INVOKE ExitProcess, 0 ; exit with return code 0
PUBLIC _start ; make entry point public
END ; end of source code