Summary of the knowledge points of Beijing self-study North University boarding (2)

xiaoxiao2021-03-06  15

Output string functions Prompt proc MoV AH, 09H INT 21h RetPROMPT ENDP

Output Enter Transfer Function CRLF Proc MoV DL, 0DH MOV AH, 2 INT 21H MOV DL, 0AH MOV AH, 2 INT 21H RETCRLF ENDP

Output Space Fingers BLANK Proc Mov DL, 20H MOV AH, 2 INT 21h Retblank Endp

Binary input functions; input range 0 ~ 111111111111111111111111111111111111111111111111111111111111111193336388 , 0 MOV AX, BX MOV CX, 2 MUL CX Add BX, AX JMP Acceptinbexit: Pop CX Retinberr: Lea DX, 'Bad Format ... $' Call Prompt JMP Inbstartinb Endp

Eight input functions; range: 0-177777inq Proc Push CX

POP CX Retinq Endp

Imperial input function; range: 0-65535ind Proc Push Cxindstart: MOV BX, 0accept: MOV AH, 1 INT 21H CMP Al, 0DH JE INDEXIT CMP AL, 30H JL INDERR CMP AL, 39H JA INDERR SUB AL, 30H MOV AH , 0 XCHG AX, BX MOV CX, 10 MUL CX Add BX, AX JMP AcceptIndexit: Pop CX Retinderr: MOV DX, Offset 'Bad Format ... $' Call Prompt JMP Indstartind Endp

Hexadecimal input function; range: 0-0ffHinh Proc Push CXINHSTART: MOV BX, 0ACCEPT: MOV AH, 1 INT 21H CMP Al, 0DH JE INTET CMP AL, 30H JL Inherr CMP Al, 66H; 'F' JA Inherr CMP Al, 39H; '9' JL Num CMP Al, 41H; 'A' JL Inherr CMP Al, 46H; 'F' Ja LowerCase Sub Al, 7H; 'A' - ':' = 7h JMP Numlowercase: CMP Al 61h; 'a' jl inherr CMP Al, 66h; 'F' Ja Inherr Sub Al, 27h; 'A' - ':' = 27hnum: And Ax, 0FH XCHG AX, BX MOV CX, 16; MOV CX, 4 Mul CX; SHL AX ADD BX, AX JMP Acceptinhexit: POP CX Retinherr: Lea DX, 'Bad Format ... $' Call Prompt Jmp Inhstartinh Endp

; Binary output function; range: 0-111111111111111; Call: The number to be output is placed in the BX into Outb Proc Push Cx Mov Nozero, 0; Like A Boolean Variable Mov Cl, 16NextBit: Mov DL, 0 Test BX, 8000H JE DISP MOV NOZERO, 1 MOV DL, 1DISP: CMP Nozero, 0 JE Continue Add DL, 30H MOV AH, 2 INT 21HCONTINUE: SHL BX, 1 LOOP NEXTBIT CMP NOZERO, 0 JNE OUTBEXIT MOV DL, 30H; OUTPUT '0' BECAUSE The Number In BX is Zero Mov AH, 2 INT 21HOUTBEXIT: POP CX Retoutb Endp; Outer-Binary Output Function; Scope: 0-177777; Call: The number to be output is incorporated in BX

Decimal output function; range: 0-65535; Call: The number to be output is placed in the BX into Outd Proc Push Cx Mov Nozero, 0; Like a Boolean Variable Mov CX, 10000 Call Decdiv Mov CX, 1000 Call Decdiv Mov CX, 100 Call Decdiv Mov CX, 10 Call Decdiv Mov CX, 1 Call Decdiv Cmp Nozero, 0 Jne Outdexit Mov DL, 30H MOV AH, 2 INT 21HOUTDEXIT: POP CX Ret; --- Sub Proc ---; Call: Demand In BX incoming, divisor is incorporated in CX; RET: Merchants, Wait BXDecdiv PROC MOV AX, BX MOV DX, 0 DIV CMP DL, DX MOV DL, Al CMP DL, 0 JNE DISPDIGIT CMP Nozero, 0 JNE DISPDIT JMP DecdiveXitdispdigit: Mov Nozero, 1 Add DL, 30H MOV AH, 2 INT 21HDECDIVEXIT: RETDECDIV ENDP; --- Sub Proc --- Outd Endp

Hexadecimal output function; range: 0-0ffH (or 0-0ffH); output hexadecimal uppercase letters (AF representation); call: The number to be output is in the BX in the Outh Proc Push CX MOV Ch, 4 MOV Nozero, 0; Like a Boolean Variablenext4bits: MOV CL, 4 ROL BX, CL MOV Al, BL And Al, 0FH CMP AL, 10 JL Dispdigit Add Al, 7h; If DISP 'AF', SHOULD Add 27HDispdigit : CMP Al, 0 Jne Dispnozero Cmp Nozero, 0 Je Continuedispnozero: Mov Nozero, 1 Add Al, 30H MOV DL, Al Mov AH, 2 INT 21HCONTINUE: DEC CH JNZ NEXT4BITS CMP NOZERO, 0 JNE OUTHEXIT MOV DL, 30H MOV AH, 2 INT 21WoutHexit: POP CX Retouth Endp

Bubble Sort Function (Sort In DW Array <2 BYTES> Bubble Proc Push CX MOV CX, Count; Notice: Count = Nums.Length-1outLoop: Mov Di, Cx Mov Si, 0Inloop: Mov AX, NUMS [Si] CMP AX, NUMS [Si 2]; NUMS [Si 1], IF Sort In 8 Byte Jae Incontinue XCHG AX, NUMS [Si 2]; NUMS [Si 1], IF Sort in 8 byte XCHG AX, NUMS [Si] Incontinue: Add Si, 2; Add Si, 1, IF Sort in 8 byte loop Outloop Pop Cx Retbubble Endp; Find the smallest ASCII code; Call: Find ASCII string code in BUFF RET: The minimum ASCII code found will be placed in Minascii to return GETMIN Proc Push Cx Lea Si, Buff 2 MOV CL, NUM 1 and CX, 0FH MOV BL, [Si] Next: Inc Si Cmp BL, [Si ] Jle Continue Mov BL, [Si] Continue: Loop Next Mov Minascii, Bl Pop Cx Retgetmin Endp

Statistics Non-Character and Number of Number; Call: The statistics of the ASCII string are placed in BUFF; RET: The statistics will be placed in SUM Return to Count Proc Push CX MOV CL, BUFF 1 Lea Si, BUFF 2 MOV SUM, 0NEXT: MOV AL, [Si] CMP Al, '0'; 30H JB YES CMP Al, '9'; 39H JB NO CMP AL, 'A'; 41H JB YES CMP Al, 'Z'; 5AH JB NO CMP Al, 'A'; 61H JB YES CMP Al, 'Z'; 7AH JM NO JMP YESYES: Inc Byte Ptr Sumno: Inc Si Loop Next Pop Cx Retcount Endp

转载请注明原文地址:https://www.9cbs.com/read-46154.html

New Post(0)