>L.

 4000REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 4010DEFPROCasmbl(pass%): P%=F%

 4020[ OPT pass%

 4030.find \ clear screen and ask for text.

 4040OPT FNset_addr(pass%,messages%,msg%)

 4050LDY #msgfind%-messages%

 4060JSR print

 4070\

 4080\ set up start address for finding from

 4090OPT FNset_addr(pass%,page%,line%)

 4100\

 4110\ get text to be found.

 4120LDX #parm% MOD256

 4130LDY #parm% DIV256

 4140LDA #0

 4150JSR osword%

 4160BCC check_key

 4170\

 4180\ escape; acknowledge and end.

 4190LDA #&7E

 4200JSR osbyte%

 4210JMP osnewl%

 4220\

 4230.check_key \ check if search for keyword

 4240OPT FNinclude_keys_1(pass%)

 4250\

 4260.search \ until end of prog (&FF)..

 4270\ or cr in input string.

 4280LDY #1

 4290LDA (line%),Y

 4300CMP #&FF

 4310BNE cont

 4320\

 4330\ end of prog; set up text window

 4340LDY scnmode%

 4350LDA modes%,Y  \ set bottom of screen

 4360STA page1%+2

 4370LDY #page1%-messages%

 4380JMP print

 4390\

 4400.cont \ continue with search

 4410LDX #0

 4420LDA inbuf%,X

 4430CMP #&0D  \ cr

 4440BNE notcr

 4450RTS

 4460\

 4470.notcr \ not end of buffer

 4480LDY #3

 4490\

 4500.nxt \ search from start of input

 4510OPT FNinclude_keys_2(pass%)

 4520\

 4530.nxt1 \ unless part_match

 4540INY

 4550LDA (line%),Y

 4560CMP #&0D  \ cr

 4570BEQ newline

 4580CMP inbuf%,X

 4590BNE nxt

 4600\

 4610\ match found... continue until cr

 4620INX

 4630LDA inbuf%,X

 4640CMP #&0D  \ cr

 4650BNE nxt1

 4660\

 4670\ full match, print line_number

 4680OPT FNphy(pass%)

 4690LDY #0

 4700STY lzflag%

 4710INY

 4720LDA (line%),Y

 4730STA sums%+1

 4740INY

 4750LDA (line%),Y

 4760STA sums%+0

 4770LDX #6

 4780CLD

 4790\

 4800.sumloop1 \ calc. decimal line_number

 4810SEC: LDY #0

 4820\

 4830.sumloop2 \ loop for single digit

 4840LDA sums%+0

 4850SBC conv%+0,X

 4860PHA

 4870LDA sums%+1

 4880SBC conv%+1,X

 4890BCC nosum

 4900STA sums%+1

 4910PLA

 4920STA sums%+0

 4930INY

 4940JMP sumloop2

 4950\

 4960.nosum

 4970PLA

 4980TYA

 4990ORA lzflag%  \ don't send leading zeroes

 5000BEQ leadzero

 5010TYA

 5020ORA #&30  \ "0"

 5030STA lzflag%

 5040JSR oswrch%

 5050\

 5060.leadzero

 5070DEX

 5080DEX

 5090BPL sumloop1

 5100LDA sums%+0

 5110ORA #&30  \ "0"

 5120JSR oswrch%

 5130LDA #&20  \ space

 5140JSR oswrch%

 5150OPT FNply(pass%)

 5160\

 5170.newline \ set up next line

 5180OPT FNphy(pass%)

 5190CLC

 5200LDY #3

 5210LDA (line%),Y

 5220ADC line%

 5230STA line%

 5240OPT FNply(pass%)

 5250BCC search1

 5260INC line%+1

 5270\

 5280.search1

 5290JMP search

 5300\

 5310.print1

 5320JSR osasci%

 5330INY

 5340.print  \ print messages

 5350LDA (msg%),Y

 5360CMP #&0D  \ cr

 5370BNE print1

 5380RTS

 5390\

 5400]

 5410ENDPROC

 5420REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 5430DEFFNset_addr(pas%,addr%,stor%)

 5440REM convert addr into bytes for storing

 5450[ OPT pas%

 5460LDA #addr% MOD256

 5470STA stor%+0

 5480LDA #addr% DIV256

 5490STA stor%+1

 5500]

 5510=pas%

 5520REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 5530DEFFNphy(pas%)

 5540REM push Y onto stack

 5550[ OPT pas%

 5560TYA

 5570PHA

 5580]

 5590=pas%

 5600REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 5610DEFFNply(pas%)

 5620REM pull Y from stack

 5630[ OPT pas%

 5640PLA

 5650TAY

 5660]

 5670=pas%

 5680REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 5690DEFFNinclude_keys_1(pas%)

 5700REM check for dot, colon and @ keys

 5710REM if dot then turn next 2 into hex

 5720REM if @ add 128 to next to form keyword

 5730REM if colon use table to get electron keyword

 5740IF NOT include THEN =pas%

 5750[ OPT pas%

 5760\ check for @ (key prefix)

 5770LDA inbuf%

 5780LDX #1

 5790CMP #&40  \ "@"

 5800BNE not_key

 5810\

 5820\ convert ascii to keyword

 5830LDA inbuf%+1

 5840ORA #&80  \ char plus 128

 5850JMP save_ctrl

 5860\

 5870.not_key

 5880\ check electron keyword (colon prefix)

 5890CMP #&3A  \ colon

 5900BNE not_elk

 5910\

 5920LDA inbuf%+1

 5930AND #&DF  \ convert to upper case

 5940CMP #&40  \ "@"

 5950BCS not_low

 5960ADC #49  \ adjust for non-letters

 5970\

 5980.not_low

 5990SBC #60  \ convert to table pointer

 6000TAY

 6010LDA elktab%,Y

 6020JMP save_ctrl

 6030\

 6040.hex  \ convert A to hex nibble

 6050CLC

 6060SBC #&2F  \ "0" minus 1

 6070CMP #10   \ if not 0-9 then convert A-F

 6080BCC hexrts

 6090AND #&DF  \ upper case only

 6100SBC #7

 6110\

 6120.hexrts

 6130RTS

 6140\

 6150.not_elk

 6160\ check for dot (hex prefix)

 6170DEX

 6180CMP #&2E  \ "."

 6190BNE save_x

 6200\

 6210\ convert hex to byte

 6220LDX #2

 6230LDA inbuf%+1

 6240JSR hex

 6250ASL A

 6260ASL A

 6270ASL A

 6280ASL A

 6290STA offset%

 6300LDA inbuf%+2

 6310JSR hex

 6320ORA offset%

 6330\

 6340.save_ctrl \ save new control value

 6350STA inbuf%,X

 6360\

 6370.save_x \ set up buffer start offset

 6380STX offset%

 6390]

 6400=pas%

 6410REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 6420DEFFNinclude_keys_2(pas%)

 6430REM this saves setting offset for short version

 6440IF include [OPT pas%: LDX offset%: ] ELSE [OPT pas%: LDX #0: ]

 6450=pas%

 6460REM ~~~~~~~~~~ the end ~~~~~~~~~~~

>*SPOOL

