【8086汇编(实验)】循环结构
题目一写一个完整的8086汇编语言程序:键盘输入10个数据,存入一维数组中(字),并找出数组中最大值显示在屏幕上。源码
[*]
;Program:;Author:Nonoas;Date:20191106.386.MODEL FLATExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORDINCLUDE io.h ; header file for input/outputcr EQU 0dh ; carriage return characterLf EQU 0ah ; line feed.STACK4096 ; reserve 4096-byte stack.DATA ; reserve storage for dataprompt1 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 ,ax add dx,1 add ebx,2loop forCount mov ecx,9 lea ebx,nbrArrary mov ax,forCount1: add ebx,2 cmp ,ax jb endJudge mov ax,endJudge: loop forCount1 output prompt2 itoa maxNum,ax output maxNum INVOKEExitProcess, 0; exit with return code 0PUBLIC _start ; make entry point publicEND ; end of source code题目二写一个完整的8086汇编语言程序:键盘输入10个数据,存入一维数组中(双字),并找出数组中最小的偶数显示在屏幕上,若没有偶数则显示“没有偶数!”。
源码
[*]
;Program:;Author:Nonoas;Date:20191106.386.MODEL FLATExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORDINCLUDE io.h ; header file for input/outputcr EQU 0dh ; carriage return characterLf EQU 0ah ; line feed.STACK4096 ; 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 ,eax add edx,1 add ebx,4loop forCount mov ecx,10 ;judge have even lea ebx,nbrArraryFIND: mov al, test al,01H ;if isodd, jump to next jnz NEXT mov edx, ;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, test al,01H jnz NEXT2 ;if is odd, jump to next cmp edx, jb NEXT2 mov edx,NEXT2: add ebx,4 loop FIND2 output prompt2 dtoa minNum,edx output minNum jmp endallEXIT: output prompt3 jmp endallendall: INVOKEExitProcess, 0; exit with return code 0PUBLIC _start ; make entry point publicEND ; end of source code
文档来源:51CTO技术博客https://blog.51cto.com/beiwangshan/2988125
页:
[1]