.MODEL SMALL .STACK 100h .CODE ASSUME es:@code ASSUME ds:@code NEXT EQU Read EQU 1 Stx EQU <2> Etx EQU <2> BEGIN MACRO CALL Enter ENDM ; Start ;-------------------------------------------------------------------- MOV AX,CS MOV ES,AX MOV DS,AX MOV SI,offset InBuf MOV DI,offset OutBuf BEGIN ; Just call the first entry MetaL: DW WeaveSp DW GoTo ; and then loop DW MetaL Error: RETF ; Nothing matched Object DB 0 InBuf DB '|^|x:. ' DB ' |1:. ' DB ' |0:. ' DB ' |str:|BX^xxxxxx01.' DB ' |BP^xxxxxx10.' DB ' . ' DB ' . ' DB 'BP ' DB 100 dup(0) ; The threader is the heart of the language ;-------------------------------------------------------------------- Leave: POP BX Self: ENTER: MOV BP,SP Inherit: THREAD: POP BX ADD BX,2 PUSH BX JMP [BX-2] GoTo: ;-------------------------------------------------------------------- POP BX MOV BX,[BX] PUSH BX NEXT WeaveSp: ;-------------------------------------------------------------------- CMP BYTE PTR [SI]," " JNE WeaveMatch INC SI NEXT WeaveMatch: ;-------------------------------------------------------------------- CLD CMP BYTE PTR [SI],Stx JNE WeaveEntry INC SI MOV AX,OFFSET MethodMatch STOSW JMP @F MMatch1: STOSB @@: LODSB CMP AL,Etx JNE MMatch1 XOR AL,AL STOSB NEXT Match: MethodMatch: CMP OBJECT,Read JE ReadMatch PUSH DI PUSH SI MOV DI,[BP+00] CALL RunMATCH MOV [BP+00],DI JC @F POP AX ; Succeed POP DI NEXT @@: POP SI ; Fail POP DI POP AX NEXT ReadMatch: ; BEGIN ; DW SelfInhertParms ; DW OutUnderline ; DW OutString ; DW OutEndUnderline ; DW End RunMATCH: CLD XOR CX,CX DEC CX REPZ CMPSB CMP BYTE PTR [DI-1],0 JZ @F XOR AX,AX REPNZ SCASB STC RET @@: DEC SI CLC RET WeaveEntry: ;-------------------------------------------------------------------- CMP BYTE PTR [SI],"|" JNE WeavePeriod CMP BP,SP JNZ @F SUB BP,4 @@: INC SI MOV AX,OFFSET RunEntry STOSW MOV BX,OFFSET LinkEntry POP AX PUSH AX PUSH DI PUSH BX PUSH AX ADD DI,2 NEXT LinkEntry: DW LEntry1 LEntry1: CMP BP,SP JNE @F ;if BP,SP insync ADD BP,4 ; keep it that way @@: POP BX POP BX MOV [BX],DI NEXT Entry: RunEntry: CMP BP,SP JNZ @F SUB BP,2 @@: POP BX MOV CX,[BX] ADD BX,2 PUSH CX PUSH BX NEXT ReadEntry: ; Con: LeftMargin Indent to CurPos ; Disp '|' ; . db ' ' WeavePeriod: ;-------------------------------------------------------------------- CMP BYTE PTR [SI],'.' JNE WeaveDefine INC SI MOV AX,OFFSET Leave STOSW JMP LEAVE ReadPeriod: ; Con: LeftMargin Outdent to Prev ; CrLf ; Disp '.' ; . DB 0 WeaveDefine: ;-------------------------------------------------------------------- CMP BYTE PTR [SI],":" JNE WeaveROL INC SI MOV AX,OFFSET RunDefine STOSW MOV AL,0E8h STOSB MOV AX,OFFSET Enter STOSW NEXT Define: RunDefine: POP AX STOSW NEXT ReadDefine: ; Con: Disp ':' ; . WeaveROL: CMP BYTE PTR [SI],11h JNE WeaveSTC INC SI MOV AX,OFFSET RunROL STOSW NEXT RunROL: ROL BYTE PTR [DI],1 NEXT WeaveSTC: CMP BYTE PTR [SI],17h JNE WeaveCLC INC SI MOV AX,OFFSET RunSTC STOSW NEXT RunSTC: STC ROL BYTE PTR [DI],1 NEXT WeaveCLC: CMP BYTE PTR [SI],12h JNE Continue INC SI MOV AX,OFFSET RunCLC STOSW NEXT RunCLC: CLC ROL BYTE PTR [DI],1 NEXT DB 0Eh DUP(11h) Continue: OutBuf DB 100 DUP(0) END