;›; FREE.ACT›;›; Free Memory in Editor›;›; Copyright 1984 by Action Computer Services›; All Rights Reserved›;››; last modified March 8, 1984››; Adds command [CS]? to editor.›; This command will print out how›; much memory is left in the editor's›; command line.››DEFINE STRING = "CHAR ARRAY"›DEFINE JMP = "$4C" ; JMP addr16››TYPE INSTR=[BYTE op CARD addr]›INSTR nextCmd, mvec=$4F5›››PROC CToStr=$B10F(CARD n)››; version 3.0 ROM:›;PROC CmdMsg=$A929(STRING msg)››; version 3.1 ROM:›;PROC CmdMsg=$A932(STRING msg)››; version 3.2-3.6 ROM:›PROC CmdMsg=$A938(STRING msg)›››PROC Free()› CHAR curCh=$4A2› CARD count› STRING numbuf(0)=$550› CARD ARRAY next›› IF curCh#$E6 THEN ; not [CS]?› [JMP nextCmd]› FI›› count = 0› next = $80 ; AFbase› DO› next = next^› IF next=0 THEN EXIT FI› count = count + next(1)› OD› CToStr(count)› CmdMsg(numbuf)›RETURN››; only code generated before Init is›; allocated space. Init will be›; garbage collected (well kind of).››PROC Init()› CARD codeBlock, bsize, csize, nBlock› CARD POINTER cur, next› CARD ARRAY codeBase=$491››; link in our routine› nextCmd.op = mvec.op› nextCmd.addr = mvec.addr› mvec.op = JMP› mvec.addr = Free››; allocate our routine so it won't›; go away.› codeBlock = codeBase^ - 4› next = $80 ; AFbase› DO› cur = next› next = next^› UNTIL next=0 OR next=codeBlock OD›› IF next=0 THEN› PutE()› PrintE("ýI can't allocate space for your code")› PrintE("You better Boot and try again!")› RETURN› FI››; assume we can split block› csize = @codeBlock-codeBlock› nBlock = next^› bsize = next(1) - csize› next = @codeBlock› cur^ = next› next^ = nBlock› next(1) = bsize› codeBase^ = @codeBlock›RETURN››