汇编 循环程序设计
发布网友
发布时间:2022-04-29 22:49
我来回答
共1个回答
热心网友
时间:2022-06-25 00:18
1、INCLUDEYLIB.H
DATASEGMENT
ARRAYDW1,2,-3,4,-5,-1,-1,-2,-2,-9
NDW?
PDW?
P1DW?
N1DW?
PSUMDW?,?
NSUMDW?,?
MESS1DB0AH,0DH,"THE AVERAGE1 IS: $"
MESS2 DB0AH,0DH,"THE AVERAGE2 IS:$"
DATAENDS
CODESEGMENT
ASSUMECS:CODE,DS:DATA
START:MOVAX,DATA
MOVDS,AX
MOVCX,10
LEABX,ARRAY
COMP:MOV AX,[BX]
CMPAX,0
JGEPP
INCN1
CWD
ADDNSUM,AX
ADCNSUM+2,DX
JMPSKIP
PP:INCP1
CWD
ADDPSUM,AX
ADCPSUM+2,DX
SKIP:ADDBX,2
LOOP COMP
NN:MOVAX,NSUM
MOVDX,NSUM+2
CMPN1,0
JEPPP
IDIVN1
MOVN,AX
LEADX,MESS2
MOVAX,N
CALLWRITEINT
PPP:MOVAX,PSUM
MOVDX,PSUM+2
CMPP1,0
JENN
IDIVP1
MOVP,AX
LEADX,MESS1
MOVAX,P
CALLWRITEINT
MOVAX,4C00H
INT21H
CODEENDS
ENDSTART
2、INCLUDEYLIB.H
DATA SEGMENT
BUFFERDW1,2,3,4,5,6,7,8,9,10,11,12
RULEDW0011010110111000B
BLOCKDW12 DUP(?)
MESSDB0AH,0DH,"THE BLOCK IS: $"
DATAENDS
CODESEGMENT
ASSUMECS:CODE,DS:DATA
START:MOVAX,DATA
MOVDS,AX
MOVCX,12
LEABX,BUFFER
LEADI,BLOCK
BEGIN:ROLRULE,1B
JCSEG1
MOVAX,[BX]
MOVDX,2
IMULDX
MOV[DI],AX
JMPCIRCLE
SEG1:MOVAX,[BX]
MOVDX,4
IMULDX
MOV[DI],AX
JMPCIRCLE
CIRCLE:ADDBX,2
ADDDI,2
LOOPBEGIN
MOVCX,12
LEADX,MESS
LEADI,BLOCK
OUTPUT:MOVAX,[DI]
CALLWRITEINT
ADDDI,2
LOOPOUTPUT
MOVAX,4C00H
INT21H
CODEENDS
ENDSTART
3、INCLUDEYLIB.H
DATASEGMENT
ADW1,4,5,8,9,12,13,16,18,19
BDW2,3,6,7,10,11,14,15,18,20
CDW20 DUP(?)
MESSDB"C = $"
DATAENDS
CODESEGMENT
ASSUMECS:CODE,DS:DATA
START:MOVAX,DATA
MOVDS,AX
LEASI,A
LEADI,B
LEABX,C
MOVCX,10
COMP:MOVAX,[SI]
CMPAX,[DI]
JGESKIP
MOV[BX],AX
MOVAX,[DI]
MOV[BX+2],AX
JMPCIRCLE
SKIP:MOVAX,[DI]
MOV[BX],AX
MOVAX,[SI]
MOV[BX+2],AX
JMPCIRCLE
CIRCLE:ADDBX,4
ADDSI,2
ADDDI,2
LOOPCOMP
MOVCX,20
LEADX,MESS
LEABX,C
OUTPUT:MOVAX,[BX]
CALLWRITEINT
ADDBX,2
LOOPOUTPUT
MOVAX,4C00H
INT21H
CODEENDS
ENDSTART
顺便问句,你是哪一班的?这是我写,可能还有点小问题,不是很完美,你修改一下吧