(2)、源代码
DATAS SEGMENT buf4 DB 460 dup('$') bp4 DW 20 dup(0) mark DB '@@' num2 DW 20 num3 DW 19 temp DW 0 DATAS ENDS
STACKS SEGMENT
STACKS ENDS
CODES SEGMENT
ASSUME DS:DATAS,SS:STACKS,CS:CODES START: main proc far MOV AX,DATAS MOV DS,AX MOV ES,AX MOV AX,STACKS MOV SS,AX LEA SI,buf4 LEA DI,bp4 MOV CX,20 L1: MOV AL,20 MOV DS:[SI],AL MOV DX,SI ADD DX,2 MOV ES:[DI],DX INC DI INC DI
CALL gets ADD SI,23 loop L1 L2: LEA SI,bp4 MOV AX,19 MOV num3,AX L3:
MOV DI,DS:[SI+2] MOV temp,SI MOV AX,DS:[SI] MOV SI,AX MOV CX,20 repe cmpsb js skip MOV SI,temp MOV AX,DS:[SI] xchg AX,DS:[SI+2] MOV DS:[SI],AX skip: MOV SI,temp INC SI
INC SI MOV CX,num3 dec CX MOV num3,CX INC CX loop L3 MOV CX,num2 dec CX MOV num2,CX INC CX loop L2 CALL newline LEA DI,bp4 MOV CX,20 L4: MOV temp,CX MOV SI,ES:[DI] CALL puts CALL newline INC DI INC DI MOV CX,temp