Program Requirements:
First enter a number n (0<n<=100), and then enter n unsigned number K (0<=k<=65535) to find the maximum value of the n number and output
The test instance guarantees that after each number is entered, it will end with a carriage return
Code:
1 ;Program Requirements: First enter a number n (0<n<=100), and then enter n unsigned number K (0<=k<=65535), find the maximum value of the n number and output2 ;the instance guarantees that each number entered ends with a carriage return3 4Stack SEGMENT Stack'STACK'5STAK DW theDUP (?)6 STACK ENDS7 8 DATA SEGMENT9 max_num DW?Ten DATA ENDS One A CODE SEGMENT -AssumeCS:CODE,DS:DATA,SS:STACK - MAIN PROC the START: MOVAx,data - MOVDs,ax - PagerINPUT - MOVCx,bx;The number of cycles is BX, assigned to CX + XORAx,ax;AX-0, save maximum value - next_l: PagerINPUT + CMPAX,BX A JA Jump at MOVAX,BX - Jump :LOOP next_l - MOVMax_num,ax - MOVBx,max_num - PagerOUTPUT - MOVah,4ch in INT21H - MAIN ENDP to +INPUT PROC;Inlet parameter: No Exit parameter: BX (therefore cannot exceed 65535) - PUSHAX the PUSHCX * PUSHDX $ PUSHSI;Save MultiplierPanax Notoginseng XORBX,BX - XORcx,cx the XORDX,DX + MOVSI,Ten A NEXT: MOVAH, on the INT21H;receive the number of the keyboard + CMPAl,0dh;determine if it is a carriage return - JZDone;JZ: equals then jumps $ CMPAL,'0' $ JBERROR1;JB: Less then jump - CMPAL,'9' - JAERROR1;JA: Greater than the jump the SUBal,30h;converts ASCII characters into corresponding numbers - MOVCl,alWuyi MOVAX,BX the MULSI - ADDax,cx Wu MOVBx,ax - JMPNEXT;continue to receive next data About ERROR1: MOVBX,0FFFFH $ JMPEXIT - Done : MOVdl,0ah - MOVAH, Geneva - INT21H;Output Enter A MOVDL,0DH + MOVAH, Geneva the INT21H - EXIT: POPSI $ POPDX the POPCX the POPAX the RET ;subroutine returns the INPUT ENDP - inOUTPUT PROC near;Inlet parameter: BX exit parameter: None the PUSHAx;Protection Registers the PUSHBX About PUSHCX the PUSHDX the PUSHSI the MOVSI,Ten ;The si is the divisor + XORcx,cx - MOVAx,bx;inlet parameters in BX the NEXT1: MOVDx0 ;DX Storage Remainder, clear 0Bayi DIVSI;Ax and DX consist of 32 bits divided by 16 bits of SI, the quotient is saved in Microsoft Dynamics AX, the remainder is saved in DX the PUSHDX the INCCX;CX++,CX How many bits are recorded? - CMPAx0 - jnzNEXT1;JNZ does not equal the jump the OUTP: POPDx;remainder out of stack the ADDdl,30h the MOVAH,2 the INT21H - LOOP OUTP the POPSI;Recovery Register the POPDX the POPCX94 POPBX the POPAX the RET ;subroutine returns the OUTPUT ENDP98 CODE ENDS AboutEND START
03_ assembly language (n number to find maximum value)