(2)、源代码如下
结束 插入该字符 该位置后字符依次前移 该位置后字符依次后移 输入字符和位置 输入删除的位置 开始 输入字符串 插入 选择功能 删除 DATAS SEGMENT BUF DB 20 DB ? DB 20 DUP(0) DB 6 DUP(0)
STRING0 DB 'PLEASE INPUT STRINGS:',0AH,0DH,'$'
STRING1 DB 'PLEASE CHOOSE INSERT OR DELETE:',0AH,0DH,'1.INSERT',0AH,0DH, '2.DELETE',0AH,0DH,'$'
STRING2 DB 'PLEASE INPUT THE ADDRESS TO DELETE',0AH,0DH,'$' STRING3 DB 'PLEASE INPUT THE ADDRESS TO INSERT',0AH,0DH,'$'
STRING4 DB 'PLEASE INPUT THE SYMBOL TO INSERT',0AH,0DH,'$' BUF1 DB 20 DUP(0),'$' INSER DB 0,0 DELE DB 0 NUMBER DB 0 DATAS ENDS STACKS SEGMENT DB 256 DUP(0) STACKS ENDS CODES SEGMENT
assume CS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS MOV DS,AX MOV ES,AX LEA BX,STRING0
CALL OUTPUTSTR ;输出字符串0 CALL INPUTSTR ;输入字符串 CALL HUICHE MOV AL,[BUF+1] MOV NUMBER,AL LEA BX,STRING1
CALL OUTPUTSTR ;输出字符串1 MOV AH,01H ;输入1或2 INT 21H CMP AL,'1' CALL HUICHE JZ IN1
LEA BX,STRING2 ;为2,执行删除操作 CALL OUTPUTSTR MOV AH,01H INT 21H AND AL,0FH MOV [DELE],AL CALL HUICHE CALL DELETE CALL MOVE1 LEA BX,BUF1 CALL OUTPUTSTR CALL HUICHE JMP FINAL IN1:
LEA BX,STRING3 ;执行插入操作 CALL OUTPUTSTR
MOV AH,01H INT 21H SUB AL,30H MOV [INSER],AL CALL HUICHE AND AL,0FH LEA BX,STRING4 CALL OUTPUTSTR MOV AH,01H INT 21H
MOV [INSER+1],AL CALL HUICHE CALL INSERT CALL MOVE1 LEA BX,BUF1 CALL OUTPUTSTR FINAL: MOV AH,4CH INT 21H
INPUTSTR PROC NEAR ;输入函数 LEA DX,BUF MOV AH,0AH