题目一

写一个完整的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 characterLf EQU 0ah ; line feed
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
prompt1 byte ".Enter a number of Array:",0prompt2 byte cr,lf,"The max number is:",0number 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,nbrArraryforCount: itoa count,dx output count output prompt1 input number,20 atoi number mov [ebx],ax add dx,1 add ebx,2loop 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 0PUBLIC _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 characterLf EQU 0ah ; line feed
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for dataprompt1 byte ".Enter a number of Array:",0prompt2 byte cr,lf,"The min even number is:",0prompt3 byte cr,lf,"There is no even number",0number 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,nbrArraryforCount: dtoa count,edx output count output prompt1 input number,20 atod number mov [ebx],eax add edx,1 add ebx,4loop forCount
mov ecx,10 ;judge have even lea ebx,nbrArraryFIND: mov al,[ebx] test al,01H ;if isodd, jump to next jnz NEXT mov edx,[ebx] ;if iseven, save it jmp FINDENDNEXT: add ebx,4loop FIND
mov edx,0FFFFH jmp EXITFINDEND: ;if find a even , jump here
mov ecx,10 ;find the min even lea ebx,nbrArraryFIND2: 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 0PUBLIC _start ; make entry point public
END ; end of source code

 

 

【8086汇编(实验)】循环结构_8086汇编