第1个回答 2018-04-10
CODE SEGMENT
ASSUME CS:CODE
STRR DB 'hjffhbnsdhfkjhsdQWERTYUIOPqwertyuiopkjgkldfjgljdflg',0
LEN_STRR DW ?
SUBSTRR DB 'QWERTYUIOP',0
LEN_SUBSTRR DW ?
FOUND DB 0
POS DW ?
START: PUSH CS
POP DS
PUSH CS
POP ES
MOV BYTE PTR FOUND,0
MOV WORD PTR POS,0
LEA SI,STRR
MOV CX,0
@MAIN0:
MOV AL,[SI]
CMP AL,0
JE @MAIN1
INC CX
INC SI
JMP @MAIN0
@MAIN1:
MOV LEN_STRR,CX ; 求主串长
LEA DI,SUBSTRR
MOV CX,0
@MAIN2:
MOV AL,[DI]
CMP AL,0
JE @MAIN3
INC CX
INC DI
JMP @MAIN2
@MAIN3:
MOV LEN_SUBSTRR,CX ; 求子串长
LEA SI,STRR
MOV CX,LEN_STRR
MOV DX,LEN_SUBSTRR
SUB CX,DX
MOV BX,0
@MAIN4:
PUSH CX
PUSH SI
MOV CX,DX
LEA DI,SUBSTRR
@MAIN5:
MOV AL,[SI]
CMP AL,[DI]
JE @MAIN6
JMP @MAIN7
@MAIN6:
INC SI
INC DI
LOOP @MAIN5
MOV BYTE PTR FOUND,-1
MOV WORD PTR POS, BX
JMP @MAIN8
@MAIN7:
POP SI
POP CX
INC SI
INC BX
LOOP @MAIN4
@MAIN8:
MOV AX,POS
CALL DSPAXS
MOV AL,FOUND
CBW
CALL DSPAXS
MOV AH,4CH
INT 21H
;==================================================
; 将要显示的有符号数置于 ax 中
DSPAXS PROC NEAR
PUSH AX
TEST AX,8000H
JNS @DSPAXS1
PUSH AX
PUSH DX
MOV AH,2
MOV DL,'-'
INT 21H
POP DX
POP AX
NEG AX
@DSPAXS1:
CALL DSPAX
POP AX
RET
DSPAXS ENDP
DSPAX PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSHF
XOR CX,CX
MOV BX,10
@DSPAX1:
XOR DX,DX
DIV BX
INC CX
OR DX,30H
PUSH DX
CMP AX,0
JNE @DSPAX1
MOV AH,2
@DISPAX2:
POP DX
INT 21H
LOOP @DISPAX2
MOV DL,32
INT 21H
POPF
POP DX
POP CX
POP BX
POP AX
RET
DSPAX ENDP
;==============================================
CODE ENDS
END START
第2个回答 2016-11-07
CODE SEGMENT
ASSUME CS:CODE
ORG 100H
START: JMP BBB
STRR DB 'hjffhbnsdhfkjhsdQWERTYUIOPqwertyuiopkjgkldfjgljdflg',0
LEN_STRR DW ?
SUBSTRR DB 'QWERTYUIOP',0
LEN_SUBSTRR DW ?
FOUND DB 0
POS DW ?
BBB: PUSH CS
POP DS
PUSH CS
POP ES
MOV BYTE PTR FOUND,0
MOV WORD PTR POS,0
LEA SI,STRR
MOV CX,0
@MAIN0:
MOV AL,[SI]
CMP AL,0
JE @MAIN1
INC CX
INC SI
JMP @MAIN0
@MAIN1:
MOV LEN_STRR,CX ; 求串长
LEA DI,SUBSTRR
MOV CX,0
@MAIN2:
MOV AL,[DI]
CMP AL,0
JE @MAIN3
INC CX
INC DI
JMP @MAIN2
@MAIN3:
MOV LEN_SUBSTRR,CX ; 求串长
LEA SI,STRR
MOV CX,LEN_STRR
MOV DX,LEN_SUBSTRR
SUB CX,DX
MOV BX,0
@MAIN4:
PUSH CX
PUSH SI
MOV CX,DX
LEA DI,SUBSTRR
@MAIN5:
MOV AL,[SI]
CMP AL,[DI]
JE @MAIN6
JMP @MAIN7
@MAIN6:
INC SI
INC DI
LOOP @MAIN5
MOV BYTE PTR FOUND,-1
MOV WORD PTR POS, BX
JMP @MAIN8
@MAIN7:
POP SI
POP CX
INC SI
INC BX
LOOP @MAIN4
@MAIN8:
MOV AX,POS
CALL DISPAXS
MOV AL,FOUND
CBW
CALL DISPAXS
MOV AH,4CH
INT 21H
;==================================================
; 将要显示的有符号数置于 ax 中
DISPAXS PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
PUSH DI
PUSH BP
PUSH DS
PUSH ES
PUSHF
PUSH CS
POP DS
PUSH CS
POP ES
MOV CX,6
LEA DI,DISPAXSS
@DISPAXS:
MOV BYTE PTR [DI],32
INC DI
LOOP @DISPAXS
PUSH AX
MOV DL,32
MOV AH,2
INT 21H
POP AX
MOV BYTE PTR NZS,0
MOV BYTE PTR SIGNS,0
CMP AX,0
JGE @DISPAXS0
MOV BYTE PTR SIGNS,1
NEG AX
@DISPAXS0:
PUSH AX
LEA SI,DIVARRS
LEA DI,DISPAXSS
INC DI
MOV CX,5
@DISPAXS1:
POP AX
MOV DX,0
MOV BX,[SI]
DIV BX
PUSH DX
CMP AL,0
JNE @DISPAXS2
CMP BYTE PTR NZS,1
JE @DISPAXS2
CMP CX,1
JE @DISPAXS2
MOV DL,20H
JMP @DISPAXS3
@DISPAXS2:
ADD AL,30H
MOV DL,AL
MOV BYTE PTR NZS,1
@DISPAXS3:
MOV BYTE PTR[DI],DL
INC SI
INC SI
INC DI
LOOP @DISPAXS1
POP DX
CMP BYTE PTR SIGNS,1
JNE @DISPAXS6
LEA SI,DISPAXSS
ADD SI,5
@DISPAXS4:
CMP BYTE PTR [SI],32
JE @DISPAXS5
DEC SI
JMP @DISPAXS4
@DISPAXS5:
MOV BYTE PTR [SI],'-'
@DISPAXS6:
LEA DX,DISPAXSS
MOV AH,9
INT 21H
POPF
POP ES
POP DS
POP BP
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
RET
DIVARRS DW 10000,1000,100,10,1
NZS DB 0
SIGNS DB 0
DISPAXSS DB 32,32,32,32,32,32,'$'
DISPAXS ENDP
;==============================================
CODE ENDS
END START本回答被提问者和网友采纳