Home » Archimedes archive » Archimedes World » AW-1994-06-Disc2.adf » Disk2Jun94 » !AWJune94/Goodies/Zap/!Zap/3rdParty/UtilsSrc

!AWJune94/Goodies/Zap/!Zap/3rdParty/UtilsSrc

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Archimedes World » AW-1994-06-Disc2.adf » Disk2Jun94
Filename: !AWJune94/Goodies/Zap/!Zap/3rdParty/UtilsSrc
Read OK:
File size: 650B bytes
Load address: 0000
Exec address: 0000
File contents
    1REM E-Template
    2REM
    3REM Template program for creating Zap modes.
    4REM The module will be saved to work_directory$
    5REM You should run Zap first to ensure Zap$Dir and ZapWork$Dir
    6REM are set up.
    7
    8REM directory to save module
    9work_directory$="<ZapMod$Dir>"
   10
   11REM name of mode
   12mode_name$="Utils"
   13
   14REM authors name
   15mode_author$="Paul Moore"
   16
   17REM version number of module
   18ver$="0.03"
   19
   20REM mode number you want to be
   21REM you MUST not hard wire this in as I may have allocated it
   22REM to someone else!
   23REM mode_number=15
   24
   25REM mode to base this mode on (text)
   26REM mode_basemode=0
   27
   28REM define a proc error to print line number even if running
   29REM under wimp.
   30ON ERROR PROCerror
   31
   32REM reserve space for code / workspace
   33REM default of 64k
   34code_size%=&10000
   35DIM code% code_size%
   36L%=code%+code_size%
   37
   38REM load the library defining zap's variables
   39LIBRARY "<ZapWork$Dir>.Docs.E-Library"
   40
   41REM define zaps constants (call E-Library)
   42PROCdefine_zap_variables
   43
   44REM define any variables in our workspace
   45PROCset_up_variables
   46
   47REM assemble the code
   48PROCassemble_code
   49
   50REM save the module
   51SYS "OS_File",&0A,work_directory$+".Zap"+mode_name$,&FFA,0,code%,code%+length%
   52PRINT "Zap";mode_name$+" module created and saved"
   53
   54END
   55
   56REM define any variables we want to store in the module workspace
   57
   58DEF PROCset_up_variables
   59
   60REM buflen% = length of OS command buffer
   61REM parmct% = number of argsub parameters
   62buflen% = 255
   63
   64FOR pass=%1100 TO %1110 STEP 2:P%=0:O%=code%:[OPTpass
   65
   66.search_parm        EQUD 0
   67.cmd_buf            FNres(buflen%)
   68
   69]:NEXT
   70variable_size%=P%
   71ENDPROC
   72
   73REM assemble the main code
   74
   75DEF PROCassemble_code
   76
   77REM define flags
   78
   79Iflag%=1<<27
   80Vflag%=1<<28
   81Cflag%=1<<29
   82
   83REM define register numbers (for macros)
   84
   85R0=0:R1=1:R2=2:R3=3:R4=4:R5=5:R6=6:R7=7:R8=8:R9=9:R10=10
   86R11=11:R12=12:R13=13:R14=14:R15=15:PC=15
   87
   88FOR pass=%1100 TO %1110 STEP 2:P%=0:O%=code%
   89[OPTpass
   90
   91.Module_header
   92.Start_code           EQUD 0
   93.Initialisation_code  EQUD initialise_code
   94.Finalisation_code    EQUD finalise_code
   95.Service_call_handler EQUD 0
   96.Title_string         EQUD title_string
   97.Help_string          EQUD help_string
   98.Command_keyword_tab  EQUD 0
   99.SWI_chunk_number     EQUD 0
  100.SWI_handler_code     EQUD 0
  101.SWI_decoding_table   EQUD 0
  102.SWI_decoding_code    EQUD 0
  103
  104\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  105\ TITLES AND COMMAND TABLES                                    \
  106\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  107
  108.help_string
  109FNS("Zap"+mode_name$+CHR$9+ver$+" ("+FNdate+") � "+mode_author$)
  110
  111.title_string
  112FNS("Zap"+mode_name$)
  113
  114\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  115\ INITIALISE AND FINALISE                                      \
  116\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  117
  118.initialise_code
  119FNJSR
  120MOV R0,#6
  121LDR R3,var_size
  122SWI "XOS_Module"              \ claim varable workspace
  123FNRTSVS
  124MOV R11,R2                    \ claimed block (R11 from now on)
  125STR R11,[R12]                 \ save as my workspace pointer
  126STR R11,workspace_address     \ save it in the module for
  127MOV R0,#18                    \ accessing commands.
  128ADR R1,zap_title
  129SWI "XOS_Module"              \ find zap
  130FNRTSVS                       \ not found
  131MOV R12,R4                    \ zap workspace
  132ADR R0,key_command_table      \ add table of commands
  133FNcall(Zap_AddCommands)
  134FNRTSVS
  135MOV R1,#0
  136MOV R2,R11
  137LDR R3,var_size
  138FNcall(Zap_FillWords)         \ clear workspace to zeros
  139FNRTS
  140
  141.var_size
  142EQUD variable_size%
  143
  144.zap_title
  145FNS("Zap")
  146
  147.workspace_address
  148EQUD 0
  149
  150\X R11=module workspace |
  151
  152.get_workspace
  153LDR R11,workspace_address
  154MOV PC,R14
  155
  156.finalise_code
  157FNJSR
  158MOV R0,#7
  159LDR R2,[R12]
  160SWI "XOS_Module"              \ free workspace
  161FNRTSVS
  162MOV R0,#0
  163STR R0,[R12]                  \ null private word
  164FNRTS
  165
  166\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  167\ Command table                                             \
  168\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  169
  170.key_command_table
  171EQUD key_command_table
  172EQUD 0                        \ service call code
  173FNcom("FILTERSEL",filtersel)
  174FNcom("WINLEFT",winleft)
  175FNcom("WINRIGHT",winright)
  176FNcom("WINUP",winup)
  177FNcom("WINDOWN",windown)
  178FNcom("DELWORDLEFT",delwordleft)
  179FNcom("DELWORDRIGHT",delwordright)
  180FNcom("SEARCHWORD",searchword)
  181FNcom("FW",fw)
  182FNcom("BW",bw)
  183EQUD 0                        \ end
  184
  185\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  186\ Word movement commands                                       \
  187\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  188EQUD (1<<12)
  189.fw
  190STMFD R13!,{R14}
  191LDR R0,[R10,#c_off]
  192
  193TEQ R1,#0
  194.fw01
  195BLNE fwd_word
  196SUBNES R1,R1,#1
  197BNE fw01
  198
  199FNcall(Zap_JumptoOffset)
  200LDMFD R13!,{PC}
  201
  202\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  203EQUD (1<<12)
  204.bw
  205STMFD R13!,{R14}
  206LDR R0,[R10,#c_off]
  207
  208TEQ R1,#0
  209.bw01
  210BLNE back_word
  211SUBNES R1,R1,#1
  212BNE bw01
  213
  214FNcall(Zap_JumptoOffset)
  215LDMFD R13!,{PC}
  216
  217\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  218\ Word deletion commands                                       \
  219\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  220EQUD 0
  221
  222.delwordleft
  223STMFD R13!,{R14}
  224
  225LDR R3,[R10,#c_off]
  226MOV R0,R3
  227
  228TEQ R1,#0
  229.dwl01
  230BLNE back_word
  231SUBNES R1,R1,#1
  232BNE dwl01
  233
  234\\\ R0 = start of block, R3 = end of block
  235
  236MOV R1,R0
  237SUB R2,R3,R0
  238FNcall(Zap_StartOp)
  239BVS dwl02
  240MOV R0,#2
  241FNcall(Zap_Command)
  242BVS dwl02
  243FNcall(Zap_StopOp)
  244
  245.dwl02
  246LDMFD R13!,{PC}
  247
  248\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  249EQUD (1<<12)
  250
  251.delwordright
  252STMFD R13!,{R14}
  253
  254LDR R3,[R10,#c_off]
  255MOV R0,R3
  256
  257TEQ R1,#0
  258.dwr01
  259BLNE fwd_word
  260SUBNES R1,R1,#1
  261BNE dwr01
  262
  263\\\ R3 = start of block, R0 = end of block
  264
  265MOV R1,R3
  266SUB R2,R0,R3
  267FNcall(Zap_StartOp)
  268BVS dwr02
  269MOV R0,#2
  270FNcall(Zap_Command)
  271BVS dwr02
  272FNcall(Zap_StopOp)
  273
  274.dwr02
  275LDMFD R13!,{PC}
  276
  277\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  278\ Word search commands                                         \
  279\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  280EQUD (2<<3)+(1<<12)
  281
  282.searchword
  283STMFD R13!,{R14}
  284BL get_workspace
  285MOV R2,R0
  286
  287TEQ R1,#0
  288BEQ sw02
  289.sw01
  290LDR R0,[R2],#4
  291FNSTR(R0,search_parm)
  292BL search_rtn
  293BVS sw02
  294SUBS R1,R1,#1
  295BNE sw01
  296
  297.sw02
  298LDMFD R13!,{PC}
  299
  300\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  301.search_rtn
  302STMFD R13!,{R1-R7,R14}
  303
  304LDR R7,[R10,#c_off]     \ R7 = current cursor offset
  305
  306MOV R0,R7
  307BL getc_off
  308BL wordchar
  309BCC sr_err
  310
  311.sr01
  312TEQ R0,#0
  313BEQ sr02
  314SUB R0,R0,#1
  315BL getc_off
  316BL wordchar
  317BCS sr01
  318ADD R0,R0,#1
  319.sr02
  320
  321MOV R5,R0               \ R5 = start of word
  322
  323LDR R2,[R9,#f_len]      \ R2 = file length
  324MOV R0,R7
  325.sr03
  326CMP R0,R2
  327MOVHS R0,R2
  328BHS sr04
  329ADD R0,R0,#1
  330BL getc_off
  331BL wordchar
  332BCS sr03
  333.sr04
  334
  335MOV R6,R0               \ R6 = end of word + 1
  336SUB R4,R6,R5            \ R4 = length of word
  337
  338ADD R0,R4,#1
  339FNcall(Zap_Claim)
  340LDMVSFD R13!,{R1-R7,PC}
  341MOV R7,R0               \ R7 = heap block
  342
  343LDR R0,[R9,#f_splito]
  344CMP R5,R0
  345CMPLT R0,R6
  346BLT sr05
  347
  348\ Word is in one part
  349LDR R1,[R9,#f_ptr]
  350ADD R1,R1,R5
  351MOV R2,R7
  352MOV R3,R4
  353FNcall(Zap_MoveBytes)
  354BVS err_free
  355B sr06
  356
  357\ Word is in two parts
  358.sr05
  359LDR R1,[R9,#f_ptr]
  360ADD R1,R1,R5
  361MOV R2,R7
  362SUB R3,R0,R5
  363STMFD R13!,{R1-R3}
  364FNcall(Zap_MoveBytes)
  365BVS err_free
  366LDMFD R13!,{R1-R3}
  367
  368LDR R0,[R9,#f_splits]
  369ADD R1,R1,R0
  370ADD R1,R1,R3
  371ADD R2,R2,R3
  372SUB R3,R4,R3
  373FNcall(Zap_MoveBytes)
  374BVS err_free
  375.sr06
  376
  377\ Word is now on heap. Zero-terminate it
  378MOV R0,#0
  379STRB R0,[R7,R4]
  380
  381\ Work out what type of search we want
  382\  0 = to buffer
  383\ +1 = from here, forward        ie, next match
  384\ -1 = from here, backward       ie, previous match
  385\ +2 = from start, forward       ie, first match
  386\ -2 = from start, backward      ie, last match
  387\ others are errors
  388
  389FNLDR(R0,search_parm)
  390CMP R0,#0
  391MOVEQ R1,#1               \ To buffer for type 0
  392MOVNE R1,#2               \ Otherwise, get file offset in R0
  393
  394MOVPL R4,#1               \ Forwards, unless type < 0
  395MOVMI R4,#0               \ when backwards
  396
  397MOVPL R3,R6               \ For forward search, start at word end
  398MOVMI R3,R5               \ For backward search, start at word start
  399
  400RSBMI R0,R0,#0            \ Get the absolute value of the type
  401CMP R0,#1
  402MOVNE R3,#0               \ From start, unless abs(type) = 1
  403
  404\ Do the search
  405MOV R0,R7
  407MOV R5,#0
  408FNcall(Zap_Search)
  409BVS err_free
  410
  411\ If we got a throwback buffer, stop now
  412CMP R1,#1
  413LDMEQFD R13!,{R1-R7,PC}
  414
  415CMP R0,#0
  416BMI sr_notfound
  417
  418FNcall(Zap_GotoOffset)
  419BVS err_free
  420
  421MOV R0,R7
  422FNcall(Zap_Free)
  423
  424LDMFD R13!,{R1-R7,PC}
  425
  426.err_free
  427MOV R1,R0
  428MOV R0,R7
  429FNcall(Zap_Free)
  430MOV R0,R1
  431LDMFD R13!,{R1-R7,R14}
  432ORRS PC,R14,#Vflag%
  433
  434.sr_notfound
  435MOV R0,R7
  436FNcall(Zap_Free)
  437ADR R0,sr_no
  438LDMFD R13!,{R1-R7,R14}
  439ORRS PC,R14,#Vflag%
  440
  441.sr_err
  442ADR R0,sr_error
  443LDMFD R13!,{R1-R7,R14}
  444ORRS PC,R14,#Vflag%
  445
  446.sr_error
  447EQUD 0
  448FNS("Not in a word")
  449
  450.sr_no
  451EQUD 0
  452FNS("Not found")
  453
  454\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  455\ Subroutines                                                  \
  456\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  457\ Move one word forward in file
  458\ (In) R0 = file offset, (Out) R0 = new file offset
  459.fwd_word
  460STMFD R13!,{R1-R2,R14}
  461LDR R2,[R9,#f_len]
  462
  463CMP R0,R2
  464MOVHS R0,R2
  465BHS fw_eof
  466
  467.fw01
  468BL getc_off
  469BL wordchar
  470BCC fw02
  471ADD R0,R0,#1
  472CMP R0,R2
  473BHS fw_eof
  474B fw01
  475
  476.fw02
  477ADD R0,R0,#1
  478CMP R0,R2
  479BHS fw_eof
  480BL getc_off
  481BL wordchar
  482BCC fw02
  483
  484.fw_eof
  485LDMFD R13!,{R1-R2,PC}^
  486
  487\ Move one word backward in file
  488\ (In) R0 = file offset, (Out) R0 = new file offset
  489.back_word
  490STMFD R13!,{R1,R14}
  491
  492.bw01
  493SUBS R0,R0,#1
  494BMI bw_eof
  495
  496BL getc_off
  497BL wordchar
  498BCC bw01
  499
  500.bw02
  501SUBS R0,R0,#1
  502BMI bw_eof
  503BL getc_off
  504BL wordchar
  505BCS bw02
  506
  507.bw_eof
  508ADD R0,R0,#1
  509LDMFD R13!,{R1,PC}^
  510
  511\ Get a character from a file buffer
  512\ (In) R0=file offset (Out) R1=char
  513.getc_off
  514STMFD R13!,{R0,R14}
  515
  516LDR R1,[R9,#f_splito]
  517CMP R0,R1
  518LDRCS R1,[R9,#f_splits]
  519ADDCS R0,R0,R1
  520LDR R1,[R9,#f_ptr]
  521LDRB R1,[R1,R0]
  522
  523LDMFD R13!,{R0,PC}^
  524
  525\ Check whether a character is a word constituent
  526\ (In) R1=char (Out) CS=Word, CC=NonWord
  527.wordchar
  528STMFD R13!,{R0-R2,R14}
  529ADR R0,wordtab
  530MOV R2,R1,LSR #5
  531LDR R0,[R0,R2,ASL #2]
  532AND R1,R1,#&1F
  533ADD R1,R1,#1
  534MOVS R0,R0,LSR R1
  535LDMFD R13!,{R0-R2,PC}
  536
  537\ Word characters (A-Z,a-z,0-9,_)
  538.wordtab
  539EQUD &00000000        \ &00-&1F
  540EQUD &03FF0000        \ &20-&3F (0-9)
  541EQUD &87FFFFFE        \ &40-&5F (A-Z and _)
  542EQUD &07FFFFFE        \ &60-&7F (a-z)
  543EQUD &00000000        \ &80-&9F
  544EQUD &00000000        \ &A0-&BF
  545EQUD &00000000        \ &C0-&DF
  546EQUD &00000000        \ &E0-&FF
  547
  548\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  549\ Window Movement Commands                                     \
  550\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  551EQUD (2<<3)+(1<<12)
  552
  553.winleft
  554STMFD R13!,{R14}
  555
  556BL getarg
  557
  558LDR R0,[R8,#w_minx]
  559SUB R0,R0,R2
  560STR R0,[R8,#w_minx]
  561
  562LDR R0,[R8,#w_maxx]
  563SUB R0,R0,R2
  564STR R0,[R8,#w_maxx]
  565
  566MOV R0,#1
  567MOV R1,R8
  568FNcall(Zap_OpenWindow)
  569
  570LDMFD R13!,{PC}
  571
  572\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  573EQUD (2<<3)+(1<<12)
  574
  575.winright
  576STMFD R13!,{R14}
  577
  578BL getarg
  579
  580LDR R0,[R8,#w_minx]
  581ADD R0,R0,R2
  582STR R0,[R8,#w_minx]
  583
  584LDR R0,[R8,#w_maxx]
  585ADD R0,R0,R2
  586STR R0,[R8,#w_maxx]
  587
  588MOV R0,#1
  589MOV R1,R8
  590FNcall(Zap_OpenWindow)
  591
  592LDMFD R13!,{PC}
  593
  594\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  595EQUD (2<<3)+(1<<12)
  596
  597.winup
  598STMFD R13!,{R14}
  599
  600BL getarg
  601
  602LDR R0,[R8,#w_miny]
  603ADD R0,R0,R2
  604STR R0,[R8,#w_miny]
  605
  606LDR R0,[R8,#w_maxy]
  607ADD R0,R0,R2
  608STR R0,[R8,#w_maxy]
  609
  610MOV R0,#1
  611MOV R1,R8
  612FNcall(Zap_OpenWindow)
  613
  614LDMFD R13!,{PC}
  615
  616\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  617EQUD (2<<3)+(1<<12)
  618
  619.windown
  620STMFD R13!,{R14}
  621
  622BL getarg
  623
  624LDR R0,[R8,#w_miny]
  625SUB R0,R0,R2
  626STR R0,[R8,#w_miny]
  627
  628LDR R0,[R8,#w_maxy]
  629SUB R0,R0,R2
  630STR R0,[R8,#w_maxy]
  631
  632MOV R0,#1
  633MOV R1,R8
  634FNcall(Zap_OpenWindow)
  635
  636LDMFD R13!,{PC}
  637
  638\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  639\ (In)  R0=list of words, R1=number in list
  640\ (Out) R2=sum of list, R0,R1,R3 corrupted
  641\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  642.getarg
  643
  644MOV R2,#0
  645.L01
  646SUBS R1,R1,#1
  647LDRPL R3,[R0],#4
  648ADDPL R2,R2,R3
  649BPL L01
  650MOVS PC,R14
  651
  652\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  653\ Filter Selection Command                                     \
  654\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  655EQUD 1+(3<<3)+(1<<6)
  656
  657\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  658\ (Uses) R7=command string, R6=heap block
  659\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  660.filtersel
  661FNJSR
  662
  663\\ Are we being asked for a prompt string?
  664TEQ R2,#6
  665BEQ add_prompt
  666
  667\\ Remember the minibuffer contents for later
  668MOV R7,R0
  669
  670\\ Get the selected area to a heap block
  671FNcall(Zap_ReadSel)           \ (Out) R2=len, R3=block
  672BVS error_ret
  673TEQ R3,#0
  674BEQ error_nosel               \ Error if there isn't one
  675
  676\\ Save the selected area to a temporary file
  677ADR R1,file_in
  678BL save                       \ (In) R1=filename, R2=len, R3=block
  679BVS error_ret
  680
  681\\ Free the heap block
  682MOV R0,R3
  683FNcall(Zap_Free)              \ (In) R0=block
  684BVS error_ret
  685
  686\\ Filter the file
  687MOV R0,R7
  688ADR R1,file_in
  689ADR R2,file_out
  690BL filter_file                \ (In) R0=command, R1=input, R2=output
  691BVS error_ret
  692
  693\\ Find the length of the replacement file
  694ADR R1,file_out
  695BL get_len                    \ (In) R1=file (Out) R0=len
  696BVS error_ret
  697MOV R4,R0                     \ Save filesize in R4 for later
  698
  699\\ Get the necessary space on Zap's heap
  700FNcall(Zap_Claim)             \ (In) R0=size (Out) R0=block
  701BVS error_ret
  702MOV R3,R0                     \ Save block addr in R3 for later
  703
  704\\ Load the replacement file
  705ADR R1,file_out
  706BL load_file                  \ (In) R0=block, R1=file
  707BVS error_ret
  708
  709\\ Get the file offset and length of the selection
  710FNcall(Zap_GetSel)            \ (Out) CC, R1=offset, R2=len
  711BCS error_nosel               \ Error if there isn't one - cannot happen
  712BVS error_ret
  713
  714\\ Replace the selection with the changed text
  715FNcall(Zap_StartOp)
  716BVS error_ret
  717FNcall(Zap_ReplaceArea)       \ (In) R1=offset, R2=len, R3=block, R4=blklen
  718BVS error_ret
  719FNcall(Zap_StopOp)
  720BVS error_ret
  721
  722\\ Free the heap block, and delete the temporary files
  723MOV R0,R3
  724FNcall(Zap_Free)              \ (In) R0=block
  725BVS error_ret
  726
  727ADR R1,file_in                \ (In) R1=file
  728BL delete
  729ADR R1,file_out               \ (In) R1=file
  730BL delete
  731
  732\\ Finished
  733FNRTS
  734
  735\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  736\ Error returns                                                \
  737\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  738.error_nosel
  739ADR R0,error_noselection
  740\ Fall through!
  741
  742.error_ret
  743FNRTV
  744
  745.error_noselection
  746EQUD 0
  747FNS("No selection")
  748
  749\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  750\ Input and output filenames for command                       \
  751\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  752
  753.file_in
  754FNS("<Wimp$ScrapDir>.Zap-In")
  755
  756.file_out
  757FNS("<Wimp$ScrapDir>.Zap-Out")
  758
  759\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  760\ Add a prompt to the minibuffer (tail called from command)    \
  761\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  762
  763.add_prompt
  764ADR R0,prompt_string
  765FNcall(Zap_MiniPrompt)
  766FNRTS
  767
  768.prompt_string
  769FNS("Filter: ")
  770
  771\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  772\ Save data to a file                                          \
  773\ (In) R1 = filename, R2 = len, R3 = addr                      \
  774\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  775
  776.save
  777STMFD R13!,{R1-R5,R14}
  778MOV R4,R3          \ start addr
  779ADD R5,R3,R2       \ end addr
  780MOV R0,#10         \ save file
  781LDR R2,file_txt    \ filetype
  782SWI "XOS_File"
  783LDMFD R13!,{R1-R5,PC}
  784
  785.file_txt
  786EQUD &FFF
  787
  788\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  789\ Get the length of a file                                     \
  790\ (In) R1 = file (Out) R0 = length                             \
  791\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  792
  793.get_len
  794STMFD R13!,{R1-R6,R14}
  795MOV R0,#17
  796SWI "XOS_File"
  797MOVVC R0,R4
  798LDMFD R13!,{R1-R6,PC}
  799
  800\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  801\ Delete a file                                                \
  802\ (In) R1 = file                                               \
  803\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  804
  805.delete
  806STMFD R13!,{R1-R5,R14}
  807MOV R0,#6
  808SWI "XOS_File"
  809LDMFD R13!,{R1-R5,PC}
  810
  811\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  812\ Load a file                                                  \
  813\ (In) R0 = address, R1 = file                                 \
  814\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  815
  816.load_file
  817STMFD R13!,{R1-R7,R14}
  818MOV R2,R0           \ address to load to
  819MOV R0,#16          \ load file
  820MOV R3,#0           \ load to given address
  821SWI "XOS_File"
  822LDMFD R13!,{R1-R7,PC}
  823
  824\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  825\ Filter file_in to file_out                                   \
  826\ (In) R0=command, R1=input, R2=output                         \
  827\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  828
  829.filter_file
  830STMFD R13!,{R0-R2,R14}
  831
  832\ The parameter list is on the stack
  833MOV R3,R13
  834
  835\ Claim some space for the command buffer from Zap
  836MOV R0,#buflen%
  837FNcall(Zap_Claim)
  838ADDVS R13,R13,#4                \ On an error, we don't restore R0!
  839LDMVSFD R13!,{R1-R2,PC}
  840
  841MOV R2,#buflen%
  842MOV R1,R0
  843ADR R0,cmd_template
  844BL argsub
  845
  846\ Save the address of the heap block
  847MOV R2,R0
  848
  849\ Drop R0 from the stack, as we intend to corrupt it
  850ADD R13,R13,#4
  851
  852\ Start the child task
  853SWI "XWimp_StartTask"
  854BVS error_starttask
  855TEQ R0,#0
  856ADRNE R0,error_livetask
  857BNE error_starttask
  858
  859\ Free the heap block
  860MOV R0,R2
  861FNcall(Zap_Free)
  862
  863LDMFD R13!,{R1-R2,PC}
  864
  865\ Error in starting the child task
  866.error_starttask
  867MOV R1,R0                       \ Preserve the error pointer
  868
  869MOV R0,R2
  870FNcall(Zap_Free)                \ Free the heap block (ignore errors here)
  871
  872MOV R0,R1
  873LDMFD R13!,{R1-R2,R14}
  874ORRS PC,R14,#Vflag%
  875
  876\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  877.error_livetask
  878EQUD 0
  879FNS("Filter task has not completed")
  880
  881\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  882
  883.cmd_template
  884FNS("%0 < %1 > %2 2> Null:")
  885
  886\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  887\ Substitute args into a string                                \
  888\ (In) R0 = template, R1 = output buffer, R2 = output buffer   \
  889\      length, R3 = parameter list                             \
  890\ (Out) R0 = output buffer, R1 = null at end of output         \
  891\                                                              \
  892\ Copies the template into the output buffer, replacing %n by  \
  893\ the contents of the nth parameter in the list at R3. %% is   \
  894\ replaced by a single %                                       \
  895\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  896
  897.argsub
  898STMFD R13!,{R1-R5,R14}
  899
  900\ Main loop - load and store bytes
  901.L11
  902\ Buffer overflow?
  903TEQ R2,#0
  904BEQ Lerr_overflow
  905
  906LDRB R4,[R0]
  907
  908\ Argument substitution?
  909TEQ R4,#ASC"%"
  910BEQ Lpct
  911
  912\ Basic case - add to output string
  913.Lbas
  914STRB R4,[R1],#1
  915ADD R0,R0,#1
  916SUB R2,R2,#1
  917
  918\ At end?
  919TEQ R4,#0
  920BNE L11
  921
  922SUB R1,R1,#1                    \ Back up to the null
  923LDMFD R13!,{R0,R2-R5,PC}        \ Restore, but restore saved R1 to R0
  924
  925\ Argument substitution
  926.Lpct
  927LDRB R4,[R0,#1]!
  928TEQ R4,#ASC"%"                  \ %% => %
  929BEQ Lbas
  930
  931\ Check that we have %0 - %9
  932CMP R4,#ASC"0"
  933BLT Lerr_invalid
  934CMP R4,#ASC"9"
  935BGT Lerr_invalid
  936
  937ADD R0,R0,#1                    \ R0 -> next unread template char
  938
  939SUB R4,R4,#ASC"0"
  940LDR R5,[R3,R4,LSL #2]
  941
  942\ Copy [R5] into [R1]
  943.L12
  944LDRB R4,[R5],#1
  945TEQ R4,#0
  946BEQ L11                         \ Done - go back to main loop
  947
  948TEQ R2,#0
  949BEQ Lerr_overflow
  950
  951STRB R4,[R1],#1
  952SUB R2,R2,#1
  953B L12
  954
  955.Lerr_overflow
  956ADR R0,error_overflow
  957LDMFD R13!,{R1-R5,R14}
  958ORRS PC,R14,#Vflag%
  959
  960.Lerr_invalid
  961ADR R0,error_invalid
  962LDMFD R13!,{R1-R5,R14}
  963ORRS PC,R14,#Vflag%
  964
  965.error_overflow
  966EQUD 0
  967FNS("Overflow")
  968
  969.error_invalid
  970EQUD 0
  971FNS("Invalid template")
  972
  973\\\\\\\\\\ End Of Assembly \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  974
  975]
  976
  977NEXT pass
  978length%=P%
  979ENDPROC
  980
  981DEF FNS(A$)    :[OPTpass:EQUS A$+CHR$0:ALIGN:]:=""
  982DEF FNRES(n%)  :[OPTpass:EQUS STRING$(n%,CHR$0):ALIGN:]:=""
  983DEF FNSS(A$)   :[OPTpass:SWI "XOS_WriteS":EQUS A$+CHR$0:ALIGN:]:=""
  984DEF FNJSR      :[OPTpass:STMFD   R13!,{R14}:]:=""
  985DEF FNRTV      :[OPTpass:LDMFD   R13!,{R14}:ORRS PC,R14,#Vflag%:]:=""
  986DEF FNRTC      :[OPTpass:LDMFD   R13!,{R14}:BICS PC,R14,#Vflag%:]:=""
  987DEF FNRTS      :[OPTpass:LDMFD   R13!,{PC} :]:=""
  988DEF FNRTSNE    :[OPTpass:LDMNEFD R13!,{PC}:]:=""
  989DEF FNRTSEQ    :[OPTpass:LDMEQFD R13!,{PC}:]:=""
  990DEF FNRTSCS    :[OPTpass:LDMCSFD R13!,{PC}:]:=""
  991DEF FNRTSCC    :[OPTpass:LDMCCFD R13!,{PC}:]:=""
  992DEF FNRTSVS    :[OPTpass:LDMVSFD R13!,{PC}:]:=""
  993DEF FNRTSVC    :[OPTpass:LDMVCFD R13!,{PC}:]:=""
  994DEF FNRTSLS    :[OPTpass:LDMLSFD R13!,{PC}:]:=""
  995DEF FNRTSHI    :[OPTpass:LDMHIFD R13!,{PC}:]:=""
  996DEF FNRTSMI    :[OPTpass:LDMMIFD R13!,{PC}:]:=""
  997DEF FNRTSLE    :[OPTpass:LDMLEFD R13!,{PC}:]:=""
  998DEF FNRTSGE    :[OPTpass:LDMGEFD R13!,{PC}:]:=""
  999DEF FNRTSLT    :[OPTpass:LDMLTFD R13!,{PC}:]:=""
 1000DEF FNRTSS     :[OPTpass:LDMFD   R13!,{PC}^:]:=""
 1001DEF FNRTSSNE   :[OPTpass:LDMNEFD R13!,{PC}^:]:=""
 1002DEF FNRTSSEQ   :[OPTpass:LDMEQFD R13!,{PC}^:]:=""
 1003DEF FNRTSSCC   :[OPTpass:LDMCCFD R13!,{PC}^:]:=""
 1004DEF FNRTSSCS   :[OPTpass:LDMCSFD R13!,{PC}^:]:=""
 1005DEF FNmem(x%)  :w%=O%-code%:P%=P%+x%:O%=O%+x%:[OPTpass:ALIGN:]:=w%
 1006DEF FNres(x%)  :P%=P%+x%:O%=O%+x%:[OPTpass:ALIGN:]:=""
 1007DEF FNnewl     :[OPTpass:SWI "XOS_NewLine":]:=""
 1008
 1009DEF FNdate      DIM date% 64:?date%=3:SYS "OS_Word",&0E,date%
 1010SYS "OS_ConvertDateAndTime",date%,date%+16,32,"%DY %M3 19%YR" TO A%,B%
 1011?B%=13:=$A%
 1012
 1013REM This modules workspace is at R11!!
 1014
 1015DEF FNADR(s%,x%)  :[OPTpass:ADD   s%,R11,#x%:]:=""
 1016
 1017DEF FNLDR(s%,x%)  :[OPTpass:LDR   s%,[R11,#x%]:]:=""
 1018DEF FNLDREQ(s%,x%):[OPTpass:LDREQ s%,[R11,#x%]:]:=""
 1019DEF FNLDRNE(s%,x%):[OPTpass:LDRNE s%,[R11,#x%]:]:=""
 1020DEF FNLDRCS(s%,x%):[OPTpass:LDRCS s%,[R11,#x%]:]:=""
 1021DEF FNLDRCC(s%,x%):[OPTpass:LDRCC s%,[R11,#x%]:]:=""
 1022
 1023DEF FNSTR(s%,x%)  :[OPTpass:STR   s%,[R11,#x%]:]:=""
 1024DEF FNSTREQ(s%,x%):[OPTpass:STREQ s%,[R11,#x%]:]:=""
 1025DEF FNSTRNE(s%,x%):[OPTpass:STRNE s%,[R11,#x%]:]:=""
 1026DEF FNSTRVS(s%,x%):[OPTpass:STRVS s%,[R11,#x%]:]:=""
 1027
 1028DEF FNMOV(s%,x%)
 1029REM perform MOV s%,#x% on second pass only (variable may not exist)
 1030IF (pass AND 2)<>0 THEN
 1031 [OPTpass:MOV s%,#x%:]
 1032ELSE
 1033 [OPTpass:MOV s%,#0:]
 1034ENDIF
 1035=""
 1036
 1037DEF FNTEQ(s%,x%)
 1038REM perform TEQ s%,#x% on second pass only (variable may not exist)
 1039IF (pass AND 2)<>0 THEN
 1040 [OPTpass:TEQ s%,#x%:]
 1041ELSE
 1042 [OPTpass:TEQ s%,#0:]
 1043ENDIF
 1044=""
 1045
 1046DEF PROCerror
 1047REPORT:PRINT" at line ";ERL
 1048END
 1049
 1050DEF FNerr(a%,T$)
 1051[OPTpass:ADD R0,PC,#0:ORRS PC,R14,#Vflag%:EQUD a%:FNS(T$):]:=""
 1052
 1053DEF FNcom(T$,a%)
 1054[OPTpass:EQUS T$:EQUB 0:]
 1055!O%=0     :REM zero next four bytes
 1056[OPTpass:ALIGN:EQUD a%:]:=""
 1057
 1058REM Call zap at entry offset a% Entry R0-R11=args R12=zap workspace
 1059DEF FNcall(a%)
 1060[OPTpass
 1061LDR R14,[R12]                 \ get start of zap table
 1062ADD R14,R14,#a%               \ get address of sub
 1063STMFD R13!,{R14}              \ save address on stack
 1064MOV R14,PC                    \ return address (with flags)
 1065LDMFD R13!,{PC}               \ call the sub
 1066]:=""
 1067
� E-Template
�
.� Template program for creating Zap modes.
1� The module will be saved to work_directory$
@� You should run Zap first to ensure Zap$Dir and ZapWork$Dir
� are set up.

� directory to save module
	"work_directory$="<ZapMod$Dir>"


� name of mode
mode_name$="Utils"


� authors name
mode_author$="Paul Moore"

� version number of module
ver$="0.03"

 � mode number you want to be
?� you MUST not hard wire this in as I may have allocated it
� to someone else!
� mode_number=15

&� mode to base this mode on (text)
� mode_basemode=0

>� define a proc error to print line number even if running
� under wimp.
� � �error

 (� reserve space for code / workspace
!� default of 64k
"code_size%=&10000
#� code% code_size%
$L%=code%+code_size%
%
&/� load the library defining zap's variables
'%ț "<ZapWork$Dir>.Docs.E-Library"
(
),� define zaps constants (call E-Library)
*�define_zap_variables
+
,+� define any variables in our workspace
-�set_up_variables
.
/� assemble the code
0�assemble_code
1
2� save the module
3Qș "OS_File",&0A,work_directory$+".Zap"+mode_name$,&FFA,0,code%,code%+length%
42� "Zap";mode_name$+" module created and saved"
5
6�
7
8C� define any variables we want to store in the module workspace
9
:� �set_up_variables
;
<+� buflen% = length of OS command buffer
=+� parmct% = number of argsub parameters
>buflen% = 255
?
@3� pass=%1100 � %1110 � 2:P%=0:O%=code%:[OPTpass
A
B.search_parm        EQUD 0
C%.cmd_buf            �res(buflen%)
D
E]:�
Fvariable_size%=P%
G�
H
I� assemble the main code
J
K� �assemble_code
L
M� define flags
N
OIflag%=1<<27
PVflag%=1<<28
QCflag%=1<<29
R
S*� define register numbers (for macros)
T
U<R0=0:R1=1:R2=2:R3=3:R4=4:R5=5:R6=6:R7=7:R8=8:R9=9:R10=10
V,R11=11:R12=12:R13=13:R14=14:R15=15:PC=15
W
X*� pass=%1100 � %1110 � 2:P%=0:O%=code%
Y[OPTpass
Z
[.Module_header
\ .Start_code           EQUD 0
]..Initialisation_code  EQUD initialise_code
^,.Finalisation_code    EQUD finalise_code
_ .Service_call_handler EQUD 0
`+.Title_string         EQUD title_string
a*.Help_string          EQUD help_string
b .Command_keyword_tab  EQUD 0
c .SWI_chunk_number     EQUD 0
d .SWI_handler_code     EQUD 0
e .SWI_decoding_table   EQUD 0
f .SWI_decoding_code    EQUD 0
g
hD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
iB\ TITLES � COMMAND TABLES                                    \
jD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
k
l.help_string
m?�S("Zap"+mode_name$+�9+ver$+" ("+�date+") � "+mode_author$)
n
o.title_string
p�S("Zap"+mode_name$)
q
rD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
sB\ INITIALISE � FINALISE                                      \
tD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
u
v.initialise_code
w�JSR
x
MOV R0,#6
yLDR R3,var_size
z;SWI "XOS_Module"              \ claim varable workspace
{
�RTSVS
|CMOV R11,R2                    \ claimed block (R11 from now on)
}@STR R11,[R12]                 \ save as my workspace pointer
~=STR R11,workspace_address     \ save it in the module for
7MOV R0,#18                    \ accessing commands.
�ADR R1,zap_title
�,SWI "XOS_Module"              \ find zap
�,�RTSVS                       \ not found
�1MOV R12,R4                    \ zap workspace
�9ADR R0,key_command_table      \ add table of commands
��call(Zap_AddCommands)
�
�RTSVS
�
MOV R1,#0
�MOV R2,R11
�LDR R3,var_size
�;�call(Zap_FillWords)         \ clear workspace to zeros
��RTS
�
�
.var_size
�EQUD variable_size%
�
�.zap_title
�
�S("Zap")
�
�.workspace_address
�
EQUD 0
�
�\X R11=module workspace |
�
�.get_workspace
�LDR R11,workspace_address
�MOV PC,R14
�
�.finalise_code
��JSR
�
MOV R0,#7
�LDR R2,[R12]
�2SWI "XOS_Module"              \ free workspace
�
�RTSVS
�
MOV R0,#0
�5STR R0,[R12]                  \ null private word
��RTS
�
�A\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�A\ Command table                                             \
�A\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�
�.key_command_table
�EQUD key_command_table
�5EQUD 0                        \ service call code
��com("FILTERSEL",filtersel)
��com("WINLEFT",winleft)
��com("WINRIGHT",winright)
��com("WINUP",winup)
��com("WINDOWN",windown)
�#�com("DELWORDLEFT",delwordleft)
�%�com("DELWORDRIGHT",delwordright)
�!�com("SEARCHWORD",searchword)
��com("FW",fw)
��com("BW",bw)
�'EQUD 0                        \ end
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�D\ Word movement commands                                       \
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�EQUD (1<<12)
�.fw
�STMFD R13!,{R14}
�LDR R0,[R10,#c_off]
�
�
TEQ R1,#0
�	.fw01
�BLNE fwd_word
�SUBNES R1,R1,#1
�BNE fw01
�
��call(Zap_JumptoOffset)
�LDMFD R13!,{PC}
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�EQUD (1<<12)
�.bw
�STMFD R13!,{R14}
�LDR R0,[R10,#c_off]
�
�
TEQ R1,#0
�	.bw01
�BLNE back_word
�SUBNES R1,R1,#1
�BNE bw01
�
��call(Zap_JumptoOffset)
�LDMFD R13!,{PC}
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�D\ Word deletion commands                                       \
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�
EQUD 0
�
�.delwordleft
�STMFD R13!,{R14}
�
�LDR R3,[R10,#c_off]
�
MOV R0,R3
�
�
TEQ R1,#0
�
.dwl01
�BLNE back_word
�SUBNES R1,R1,#1
�
BNE dwl01
�
�.\\\ R0 = start of block, R3 = end of block
�
�
MOV R1,R0
�SUB R2,R3,R0
��call(Zap_StartOp)
�
BVS dwl02
�
MOV R0,#2
��call(Zap_Command)
�
BVS dwl02
��call(Zap_StopOp)
�
�
.dwl02
�LDMFD R13!,{PC}
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�EQUD (1<<12)
�
�.delwordright
�STMFD R13!,{R14}
�
�LDR R3,[R10,#c_off]
�
MOV R0,R3


TEQ R1,#0

.dwr01
BLNE fwd_word
SUBNES R1,R1,#1

BNE dwr01

.\\\ R3 = start of block, R0 = end of block

	
MOV R1,R3

SUB R2,R0,R3
�call(Zap_StartOp)

BVS dwr02


MOV R0,#2
�call(Zap_Command)

BVS dwr02
�call(Zap_StopOp)


.dwr02
LDMFD R13!,{PC}

D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
D\ Word search commands                                         \
D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
EQUD (2<<3)+(1<<12)

.searchword
STMFD R13!,{R14}
BL get_workspace

MOV R2,R0


TEQ R1,#0
 BEQ sw02
!	.sw01
"LDR R0,[R2],#4
#�STR(R0,search_parm)
$BL search_rtn
%BVS sw02
&SUBS R1,R1,#1
'BNE sw01
(
)	.sw02
*LDMFD R13!,{PC}
+
,D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
-.search_rtn
.STMFD R13!,{R1-R7,R14}
/
08LDR R7,[R10,#c_off]     \ R7 = current cursor offset
1
2
MOV R0,R7
3BL getc_off
4BL wordchar
5BCC sr_err
6
7	.sr01
8
TEQ R0,#0
9BEQ sr02
:SUB R0,R0,#1
;BL getc_off
<BL wordchar
=BCS sr01
>ADD R0,R0,#1
?	.sr02
@
A0MOV R5,R0               \ R5 = start of word
B
C.LDR R2,[R9,#f_len]      \ R2 = file length
D
MOV R0,R7
E	.sr03
F
CMP R0,R2
GMOVHS R0,R2
HBHS sr04
IADD R0,R0,#1
JBL getc_off
KBL wordchar
LBCS sr03
M	.sr04
N
O2MOV R6,R0               \ R6 = end of word + 1
P1SUB R4,R6,R5            \ R4 = length of word
Q
RADD R0,R4,#1
S�call(Zap_Claim)
TLDMVSFD R13!,{R1-R7,PC}
U-MOV R7,R0               \ R7 = heap block
V
WLDR R0,[R9,#f_splito]
X
CMP R5,R0
YCMPLT R0,R6
ZBLT sr05
[
\\ Word is in one part
]LDR R1,[R9,#f_ptr]
^ADD R1,R1,R5
_
MOV R2,R7
`
MOV R3,R4
a�call(Zap_MoveBytes)
bBVS err_free
c
B sr06
d
e\ Word is in two parts
f	.sr05
gLDR R1,[R9,#f_ptr]
hADD R1,R1,R5
i
MOV R2,R7
jSUB R3,R0,R5
kSTMFD R13!,{R1-R3}
l�call(Zap_MoveBytes)
mBVS err_free
nLDMFD R13!,{R1-R3}
o
pLDR R0,[R9,#f_splits]
qADD R1,R1,R0
rADD R1,R1,R3
sADD R2,R2,R3
tSUB R3,R4,R3
u�call(Zap_MoveBytes)
vBVS err_free
w	.sr06
x
y,\ Word is now on heap. Zero-terminate it
z
MOV R0,#0
{STRB R0,[R7,R4]
|
}*\ Work out what type of search we want
~\  0 = to buffer
3\ +1 = from here, forward        ie, next match
�7\ -1 = from here, backward       ie, previous match
�4\ +2 = from start, forward       ie, first match
�3\ -2 = from start, backward      ie, last match
�\ others are errors
�
��LDR(R0,search_parm)
�
CMP R0,#0
�1�Q R1,#1               \ To buffer for type 0
�@MOVNE R1,#2               \ Otherwise, get file offset in R0
�
�9MOVPL R4,#1               \ Forwards, unless type < 0
�.MOVMI R4,#0               \ when backwards
�
�EMOVPL R3,R6               \ For forward search, start at word end
�HMOVMI R3,R5               \ For backward search, start at word start
�
�BRSBMI R0,R0,#0            \ Get the absolute value of the type
�
CMP R0,#1
�@MOVNE R3,#0               \ From start, unless abs(type) = 1
�
�\ Do the search
�
MOV R0,R7
�
MOV R5,#0
��call(Zap_Search)
�BVS err_free
�
�,\ If we got a throwback buffer, stop now
�
CMP R1,#1
�LDMEQFD R13!,{R1-R7,PC}
�
�
CMP R0,#0
�BMI sr_notfound
�
��call(Zap_GotoOffset)
�BVS err_free
�
�
MOV R0,R7
��call(Zap_Free)
�
�LDMFD R13!,{R1-R7,PC}
�
�
.err_free
�
MOV R1,R0
�
MOV R0,R7
��call(Zap_Free)
�
MOV R0,R1
�LDMFD R13!,{R1-R7,R14}
��RS PC,R14,#Vflag%
�
�.sr_notfound
�
MOV R0,R7
��call(Zap_Free)
�ADR R0,sr_no
�LDMFD R13!,{R1-R7,R14}
��RS PC,R14,#Vflag%
�
�.sr_err
�ADR R0,sr_error
�LDMFD R13!,{R1-R7,R14}
��RS PC,R14,#Vflag%
�
�
.sr_error
�
EQUD 0
��S("Not in a word")
�
�
.sr_no
�
EQUD 0
��S("Not found")
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�D\ Subroutines                                                  \
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�#\ Move one word forward in file
�7\ (In) R0 = file offset, (Out) R0 = new file offset
�
.fwd_word
�STMFD R13!,{R1-R2,R14}
�LDR R2,[R9,#f_len]
�
�
CMP R0,R2
�MOVHS R0,R2
�BHS fw_eof
�
�	.fw01
�BL getc_off
�BL wordchar
�BCC fw02
�ADD R0,R0,#1
�
CMP R0,R2
�BHS fw_eof
�
B fw01
�
�	.fw02
�ADD R0,R0,#1
�
CMP R0,R2
�BHS fw_eof
�BL getc_off
�BL wordchar
�BCC fw02
�
�.fw_eof
�LDMFD R13!,{R1-R2,PC}^
�
�$\ Move one word backward in file
�7\ (In) R0 = file offset, (Out) R0 = new file offset
�.back_word
�STMFD R13!,{R1,R14}
�
�	.bw01
�SUBS R0,R0,#1
�BMI bw_eof
�
�BL getc_off
�BL wordchar
�BCC bw01
�
�	.bw02
�SUBS R0,R0,#1
�BMI bw_eof
�BL getc_off
�BL wordchar
�BCS bw02
�
�.bw_eof
�ADD R0,R0,#1
�LDMFD R13!,{R1,PC}^
�
�(\ Get a character from a file buffer
'\ (In) R0=file offset (Out) R1=char

.getc_off
STMFD R13!,{R0,R14}

LDR R1,[R9,#f_splito]

CMP R0,R1
LDRCS R1,[R9,#f_splits]
ADDCS R0,R0,R1
LDR R1,[R9,#f_ptr]
	LDRB R1,[R1,R0]


LDMFD R13!,{R0,PC}^


5\ Check whether a character is a word constituent
,\ (In) R1=char (Out) CS=Word, CC=NonWord

.wordchar
STMFD R13!,{R0-R2,R14}
ADR R0,wordtab
MOV R2,R1,LSR #5
LDR R0,[R0,R2,ASL #2]
� R1,R1,#&1F
ADD R1,R1,#1
MOVS R0,R0,LSR R1
LDMFD R13!,{R0-R2,PC}

%\ Word characters (A-Z,a-z,0-9,_)
.wordtab
#EQUD &00000000        \ &00-&1F
)EQUD &03FF0000        \ &20-&3F (0-9)
/EQUD &87FFFFFE        \ &40-&5F (A-Z and _)
)EQUD &07FFFFFE        \ &60-&7F (a-z)
#EQUD &00000000        \ &80-&9F
 #EQUD &00000000        \ &A0-&BF
!#EQUD &00000000        \ &C0-&DF
"#EQUD &00000000        \ &E0-&FF
#
$D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
%D\ Window Movement Commands                                     \
&D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'EQUD (2<<3)+(1<<12)
(
).winleft
*STMFD R13!,{R14}
+
,
BL getarg
-
.LDR R0,[R8,#w_minx]
/SUB R0,R0,R2
0STR R0,[R8,#w_minx]
1
2LDR R0,[R8,#w_maxx]
3SUB R0,R0,R2
4STR R0,[R8,#w_maxx]
5
6
MOV R0,#1
7
MOV R1,R8
8�call(Zap_OpenWindow)
9
:LDMFD R13!,{PC}
;
<D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
=EQUD (2<<3)+(1<<12)
>
?
.winright
@STMFD R13!,{R14}
A
B
BL getarg
C
DLDR R0,[R8,#w_minx]
EADD R0,R0,R2
FSTR R0,[R8,#w_minx]
G
HLDR R0,[R8,#w_maxx]
IADD R0,R0,R2
JSTR R0,[R8,#w_maxx]
K
L
MOV R0,#1
M
MOV R1,R8
N�call(Zap_OpenWindow)
O
PLDMFD R13!,{PC}
Q
RD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
SEQUD (2<<3)+(1<<12)
T
U
.winup
VSTMFD R13!,{R14}
W
X
BL getarg
Y
ZLDR R0,[R8,#w_miny]
[ADD R0,R0,R2
\STR R0,[R8,#w_miny]
]
^LDR R0,[R8,#w_maxy]
_ADD R0,R0,R2
`STR R0,[R8,#w_maxy]
a
b
MOV R0,#1
c
MOV R1,R8
d�call(Zap_OpenWindow)
e
fLDMFD R13!,{PC}
g
hD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
iEQUD (2<<3)+(1<<12)
j
k.windown
lSTMFD R13!,{R14}
m
n
BL getarg
o
pLDR R0,[R8,#w_miny]
qSUB R0,R0,R2
rSTR R0,[R8,#w_miny]
s
tLDR R0,[R8,#w_maxy]
uSUB R0,R0,R2
vSTR R0,[R8,#w_maxy]
w
x
MOV R0,#1
y
MOV R1,R8
z�call(Zap_OpenWindow)
{
|LDMFD R13!,{PC}
}
~D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/\ (In)  R0=list of words, R1=number in list
�.\ (Out) R2=sum of list, R0,R1,R3 corrupted
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�.getarg
�
�
MOV R2,#0
�.L01
�SUBS R1,R1,#1
�LDRPL R3,[R0],#4
�ADDPL R2,R2,R3
�BPL L01
�MOVS PC,R14
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�D\ Filter Selection Command                                     \
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�EQUD 1+(3<<3)+(1<<6)
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�-\ (Uses) R7=command string, R6=heap block
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�.filtersel
��JSR
�
�.\\ Are we being asked for a prompt string?
�
TEQ R2,#6
�BEQ add_prompt
�
�1\\ Remember the minibuffer contents for later
�
MOV R7,R0
�
�,\\ Get the selected area to a heap block
�9�call(Zap_ReadSel)           \ (Out) R2=len, R3=block
�BVS error_ret
�
TEQ R3,#0
�<BEQ error_nosel               \ Error if there isn't one
�
�1\\ Save the selected area to a temporary file
�ADR R1,file_in
�FBL save                       \ (In) R1=filename, R2=len, R3=block
�BVS error_ret
�
�\\ Free the heap block
�
MOV R0,R3
�0�call(Zap_Free)              \ (In) R0=block
�BVS error_ret
�
�\\ Filter the file
�
MOV R0,R7
�ADR R1,file_in
�ADR R2,file_out
�HBL filter_file                \ (In) R0=command, R1=input, R2=output
�BVS error_ret
�
�.\\ Find the length of the replacement file
�ADR R1,file_out
�=BL get_len                    \ (In) R1=file (Out) R0=len
�BVS error_ret
�AMOV R4,R0                     \ Save filesize in R4 for later
�
�,\\ Get the necessary space on Zap's heap
�>�call(Zap_Claim)             \ (In) R0=size (Out) R0=block
�BVS error_ret
�CMOV R3,R0                     \ Save block addr in R3 for later
�
� \\ Load the replacement file
�ADR R1,file_out
�:BL load_file                  \ (In) R0=block, R1=file
�BVS error_ret
�
�6\\ Get the file offset and length of the selection
�>�call(Zap_GetSel)            \ (Out) CC, R1=offset, R2=len
�LBCS error_nosel               \ Error if there isn't one - cannot happen
�BVS error_ret
�
�2\\ Replace the selection with the changed text
��call(Zap_StartOp)
�BVS error_ret
�N�call(Zap_ReplaceArea)       \ (In) R1=offset, R2=len, R3=block, R4=blklen
�BVS error_ret
��call(Zap_StopOp)
�BVS error_ret
�
�:\\ Free the heap block, and delete the temporary files
�
MOV R0,R3
�0�call(Zap_Free)              \ (In) R0=block
�BVS error_ret
�
�0ADR R1,file_in                \ (In) R1=file
�
BL delete
�0ADR R1,file_out               \ (In) R1=file
�
BL delete
�
�\\ Finished
��RTS
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�D\ Error returns                                                \
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�.error_nosel
�ADR R0,error_noselection
�\ Fall through!
�
�.error_ret
��RTV
�
�.error_noselection
�
EQUD 0
��S("No selection")
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�D\ Input and output filenames for command                       \
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�
�.file_in
� �S("<Wimp$ScrapDir>.Zap-In")
�
�
.file_out
�!�S("<Wimp$ScrapDir>.Zap-Out")
�
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�D\ Add a prompt to the minibuffer (tail called from command)    \
�D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�
�.add_prompt
�ADR R0,prompt_string
��call(Zap_MiniPrompt)
��RTS
�
.prompt_string
�S("Filter: ")

D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
D\ Save data to a file                                          \
D\ (In) R1 = filename, R2 = len, R3 = addr                      \
D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

	.save
	STMFD R13!,{R1-R5,R14}

#MOV R4,R3          \ start addr
!ADD R5,R3,R2       \ end addr
"MOV R0,#10         \ save file

!LDR R2,file_txt    \ filetype
SWI "XOS_File"
LDMFD R13!,{R1-R5,PC}


.file_txt

EQUD &FFF

D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
D\ Get the length of a file                                     \
D\ (In) R1 = file (Out) R0 = length                             \
D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

.get_len
STMFD R13!,{R1-R6,R14}
MOV R0,#17
SWI "XOS_File"
MOVVC R0,R4
LDMFD R13!,{R1-R6,PC}

 D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
!D\ Delete a file                                                \
"D\ (In) R1 = file                                               \
#D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
$
%.delete
&STMFD R13!,{R1-R5,R14}
'
MOV R0,#6
(SWI "XOS_File"
)LDMFD R13!,{R1-R5,PC}
*
+D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
,D\ Load a file                                                  \
-D\ (In) R0 = address, R1 = file                                 \
.D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/
0.load_file
1STMFD R13!,{R1-R7,R14}
2,MOV R2,R0           \ address to load to
3#MOV R0,#16          \ load file
4/MOV R3,#0           \ load to given address
5SWI "XOS_File"
6LDMFD R13!,{R1-R7,PC}
7
8D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
9D\ Filter file_in to file_out                                   \
:D\ (In) R0=command, R1=input, R2=output                         \
;D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
<
=.filter_file
>STMFD R13!,{R0-R2,R14}
?
@(\ The parameter list is on the stack
AMOV R3,R13
B
C6\ Claim some space for the command buffer from Zap
DMOV R0,#buflen%
E�call(Zap_Claim)
FGADDVS R13,R13,#4                \ On an error, we don't restore R0!
GLDMVSFD R13!,{R1-R2,PC}
H
IMOV R2,#buflen%
J
MOV R1,R0
KADR R0,cmd_template
L
BL argsub
M
N(\ Save the address of the heap block
O
MOV R2,R0
P
Q8\ Drop R0 from the stack, as we intend to corrupt it
RADD R13,R13,#4
S
T\ Start the child task
USWI "XWimp_StartTask"
VBVS error_starttask
W
TEQ R0,#0
XADRNE R0,error_livetask
YBNE error_starttask
Z
[\ Free the heap block
\
MOV R0,R2
]�call(Zap_Free)
^
_LDMFD R13!,{R1-R2,PC}
`
a&\ Error in starting the child task
b.error_starttask
c@MOV R1,R0                       \ Preserve the error pointer
d
e
MOV R0,R2
fM�call(Zap_Free)                \ Free the heap block (ignore errors here)
g
h
MOV R0,R1
iLDMFD R13!,{R1-R2,R14}
j�RS PC,R14,#Vflag%
k
lD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
m.error_livetask
n
EQUD 0
o'�S("Filter task has not completed")
p
qD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
r
s.cmd_template
t�S("%0 < %1 > %2 2> Null:")
u
vD\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
wD\ Substitute args into a string                                \
xD\ (In) R0 = template, R1 = output buffer, R2 = output buffer   \
yD\      length, R3 = parameter list                             \
zD\ (Out) R0 = output buffer, R1 = null at end of output         \
{D\                                                              \
|D\ Copies the template into the output buffer, replacing %n by  \
}D\ the contents of the nth parameter in the list at R3. %% is   \
~D\ replaced by a single %                                       \
D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�
�.argsub
�STMFD R13!,{R1-R5,R14}
�
�&\ Main loop - load and store bytes
�.L11
�\ Buffer overflow?
�
TEQ R2,#0
�BEQ Lerr_overflow
�
�LDRB R4,[R0]
�
�\ Argument substitution?
�TEQ R4,#�"%"
�BEQ Lpct
�
�'\ Basic case - add to output string
�	.Lbas
�STRB R4,[R1],#1
�ADD R0,R0,#1
�SUB R2,R2,#1
�
�
\ At end?
�
TEQ R4,#0
�BNE L11
�
�9SUB R1,R1,#1                    \ Back up to the null
�ILDMFD R13!,{R0,R2-R5,PC}        \ Restore, but restore saved R1 to R0
�
�\ Argument substitution
�	.Lpct
�LDRB R4,[R0,#1]!
�+TEQ R4,#�"%"                  \ %% => %
�BEQ Lbas
�
� \ Check that we have %0 - %9
�CMP R4,#�"0"
�BLT Lerr_invalid
�CMP R4,#�"9"
�BGT Lerr_invalid
�
�EADD R0,R0,#1                    \ R0 -> next unread template char
�
�SUB R4,R4,#�"0"
�LDR R5,[R3,R4,LSL #2]
�
�\ Copy [R5] into [R1]
�.L12
�LDRB R4,[R5],#1
�
TEQ R4,#0
�ABEQ L11                         \ Done - go back to main loop
�
�
TEQ R2,#0
�BEQ Lerr_overflow
�
�STRB R4,[R1],#1
�SUB R2,R2,#1
�	B L12
�
�.Lerr_overflow
�ADR R0,error_overflow
�LDMFD R13!,{R1-R5,R14}
��RS PC,R14,#Vflag%
�
�.Lerr_invalid
�ADR R0,error_invalid
�LDMFD R13!,{R1-R5,R14}
��RS PC,R14,#Vflag%
�
�.error_overflow
�
EQUD 0
��S("Overflow")
�
�.error_invalid
�
EQUD 0
��S("Invalid template")
�
�@\\\\\\\\\\ End Of Assembly \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
�
�]
�
�
� pass
�length%=P%
��
�
�0� �S(A$)    :[OPTpass:EQUS A$+�0:ALIGN:]:=""
�2� �RES(n%)  :[OPTpass:EQUS �n%,�0):ALIGN:]:=""
�A� �SS(A$)   :[OPTpass:SWI "XOS_WriteS":EQUS A$+�0:ALIGN:]:=""
�2� �JSR      :[OPTpass:STMFD   R13!,{R14}:]:=""
�E� �RTV      :[OPTpass:LDMFD   R13!,{R14}:�RS PC,R14,#Vflag%:]:=""
�F� �RTC      :[OPTpass:LDMFD   R13!,{R14}:BICS PC,R14,#Vflag%:]:=""
�2� �RTS      :[OPTpass:LDMFD   R13!,{PC} :]:=""
�1� �RTSNE    :[OPTpass:LDMNEFD R13!,{PC}:]:=""
�1� �RTSEQ    :[OPTpass:LDMEQFD R13!,{PC}:]:=""
�1� �RTSCS    :[OPTpass:LDMCSFD R13!,{PC}:]:=""
�1� �RTSCC    :[OPTpass:LDMCCFD R13!,{PC}:]:=""
�1� �RTSVS    :[OPTpass:LDMVSFD R13!,{PC}:]:=""
�1� �RTSVC    :[OPTpass:LDMVCFD R13!,{PC}:]:=""
�1� �RTSLS    :[OPTpass:LDMLSFD R13!,{PC}:]:=""
�1� �RTSHI    :[OPTpass:LDMHIFD R13!,{PC}:]:=""
�1� �RTSMI    :[OPTpass:LDMMIFD R13!,{PC}:]:=""
�1� �RTSLE    :[OPTpass:LDMLEFD R13!,{PC}:]:=""
�1� �RTSGE    :[OPTpass:LDMGEFD R13!,{PC}:]:=""
�1� �RTSLT    :[OPTpass:LDMLTFD R13!,{PC}:]:=""
�2� �RTSS     :[OPTpass:LDMFD   R13!,{PC}^:]:=""
�2� �RTSSNE   :[OPTpass:LDMNEFD R13!,{PC}^:]:=""
�2� �RTSSEQ   :[OPTpass:LDMEQFD R13!,{PC}^:]:=""
�2� �RTSSCC   :[OPTpass:LDMCCFD R13!,{PC}^:]:=""
�2� �RTSSCS   :[OPTpass:LDMCSFD R13!,{PC}^:]:=""
�C� �mem(x%)  :w%=O%-code%:P%=P%+x%:O%=O%+x%:[OPTpass:ALIGN:]:=w%
�7� �res(x%)  :P%=P%+x%:O%=O%+x%:[OPTpass:ALIGN:]:=""
�1� �newl     :[OPTpass:SWI "XOS_NewLine":]:=""
�
�;� �date      � date% 64:?date%=3:ș "OS_Word",&0E,date%
�Hș "OS_ConvertDateAndTime",date%,date%+16,32,"%DY %M3 19%YR" � A%,B%
�?B%=13:=$A%
�
�(� This modules workspace is at R11!!
�
�3� �ADR(s%,x%)  :[OPTpass:ADD   s%,R11,#x%:]:=""
�
�5� �LDR(s%,x%)  :[OPTpass:LDR   s%,[R11,#x%]:]:=""
�5� �LDREQ(s%,x%):[OPTpass:LDREQ s%,[R11,#x%]:]:=""
�5� �LDRNE(s%,x%):[OPTpass:LDRNE s%,[R11,#x%]:]:=""
�5� �LDRCS(s%,x%):[OPTpass:LDRCS s%,[R11,#x%]:]:=""
�5� �LDRCC(s%,x%):[OPTpass:LDRCC s%,[R11,#x%]:]:=""
�
�5� �STR(s%,x%)  :[OPTpass:STR   s%,[R11,#x%]:]:=""
5� �STREQ(s%,x%):[OPTpass:STREQ s%,[R11,#x%]:]:=""
5� �STRNE(s%,x%):[OPTpass:STRNE s%,[R11,#x%]:]:=""
5� �STRVS(s%,x%):[OPTpass:STRVS s%,[R11,#x%]:]:=""

� �MOV(s%,x%)
E� perform MOV s%,#x% on second pass only (variable may not exist)
� (pass � 2)<>0 �
 [OPTpass:MOV s%,#x%:]
�
	 [OPTpass:MOV s%,#0:]

�
=""


� �TEQ(s%,x%)
E� perform TEQ s%,#x% on second pass only (variable may not exist)
� (pass � 2)<>0 �
 [OPTpass:TEQ s%,#x%:]
�
 [OPTpass:TEQ s%,#0:]
�
=""

� �error
�:�" at line ";�
�

� �err(a%,T$)
A[OPTpass:ADD R0,PC,#0:�RS PC,R14,#Vflag%:EQUD a%:�S(T$):]:=""

� �com(T$,a%)
[OPTpass:EQUS T$:EQUB 0:]
%!O%=0     :� zero next four bytes
  [OPTpass:ALIGN:EQUD a%:]:=""
!
"E� Call zap at entry offset a% Entry R0-R11=args R12=zap workspace
#� �call(a%)
$[OPTpass
%:LDR R14,[R12]                 \ get start of zap table
&6ADD R14,R14,#a%               \ get address of sub
'9STMFD R13!,{R14}              \ save address on stack
(?MOV R14,PC                    \ return address (with flags)
)0LDMFD R13!,{PC}               \ call the sub
*	]:=""
+
�
00000000  0d 00 01 10 f4 20 45 2d  54 65 6d 70 6c 61 74 65  |..... E-Template|
00000010  0d 00 02 05 f4 0d 00 03  2e f4 20 54 65 6d 70 6c  |.......... Templ|
00000020  61 74 65 20 70 72 6f 67  72 61 6d 20 66 6f 72 20  |ate program for |
00000030  63 72 65 61 74 69 6e 67  20 5a 61 70 20 6d 6f 64  |creating Zap mod|
00000040  65 73 2e 0d 00 04 31 f4  20 54 68 65 20 6d 6f 64  |es....1. The mod|
00000050  75 6c 65 20 77 69 6c 6c  20 62 65 20 73 61 76 65  |ule will be save|
00000060  64 20 74 6f 20 77 6f 72  6b 5f 64 69 72 65 63 74  |d to work_direct|
00000070  6f 72 79 24 0d 00 05 40  f4 20 59 6f 75 20 73 68  |ory$...@. You sh|
00000080  6f 75 6c 64 20 72 75 6e  20 5a 61 70 20 66 69 72  |ould run Zap fir|
00000090  73 74 20 74 6f 20 65 6e  73 75 72 65 20 5a 61 70  |st to ensure Zap|
000000a0  24 44 69 72 20 61 6e 64  20 5a 61 70 57 6f 72 6b  |$Dir and ZapWork|
000000b0  24 44 69 72 0d 00 06 11  f4 20 61 72 65 20 73 65  |$Dir..... are se|
000000c0  74 20 75 70 2e 0d 00 07  04 0d 00 08 1e f4 20 64  |t up.......... d|
000000d0  69 72 65 63 74 6f 72 79  20 74 6f 20 73 61 76 65  |irectory to save|
000000e0  20 6d 6f 64 75 6c 65 0d  00 09 22 77 6f 72 6b 5f  | module..."work_|
000000f0  64 69 72 65 63 74 6f 72  79 24 3d 22 3c 5a 61 70  |directory$="<Zap|
00000100  4d 6f 64 24 44 69 72 3e  22 0d 00 0a 04 0d 00 0b  |Mod$Dir>".......|
00000110  12 f4 20 6e 61 6d 65 20  6f 66 20 6d 6f 64 65 0d  |.. name of mode.|
00000120  00 0c 16 6d 6f 64 65 5f  6e 61 6d 65 24 3d 22 55  |...mode_name$="U|
00000130  74 69 6c 73 22 0d 00 0d  04 0d 00 0e 12 f4 20 61  |tils"......... a|
00000140  75 74 68 6f 72 73 20 6e  61 6d 65 0d 00 0f 1d 6d  |uthors name....m|
00000150  6f 64 65 5f 61 75 74 68  6f 72 24 3d 22 50 61 75  |ode_author$="Pau|
00000160  6c 20 4d 6f 6f 72 65 22  0d 00 10 04 0d 00 11 1e  |l Moore"........|
00000170  f4 20 76 65 72 73 69 6f  6e 20 6e 75 6d 62 65 72  |. version number|
00000180  20 6f 66 20 6d 6f 64 75  6c 65 0d 00 12 0f 76 65  | of module....ve|
00000190  72 24 3d 22 30 2e 30 33  22 0d 00 13 04 0d 00 14  |r$="0.03".......|
000001a0  20 f4 20 6d 6f 64 65 20  6e 75 6d 62 65 72 20 79  | . mode number y|
000001b0  6f 75 20 77 61 6e 74 20  74 6f 20 62 65 0d 00 15  |ou want to be...|
000001c0  3f f4 20 79 6f 75 20 4d  55 53 54 20 6e 6f 74 20  |?. you MUST not |
000001d0  68 61 72 64 20 77 69 72  65 20 74 68 69 73 20 69  |hard wire this i|
000001e0  6e 20 61 73 20 49 20 6d  61 79 20 68 61 76 65 20  |n as I may have |
000001f0  61 6c 6c 6f 63 61 74 65  64 20 69 74 0d 00 16 16  |allocated it....|
00000200  f4 20 74 6f 20 73 6f 6d  65 6f 6e 65 20 65 6c 73  |. to someone els|
00000210  65 21 0d 00 17 14 f4 20  6d 6f 64 65 5f 6e 75 6d  |e!..... mode_num|
00000220  62 65 72 3d 31 35 0d 00  18 04 0d 00 19 26 f4 20  |ber=15.......&. |
00000230  6d 6f 64 65 20 74 6f 20  62 61 73 65 20 74 68 69  |mode to base thi|
00000240  73 20 6d 6f 64 65 20 6f  6e 20 28 74 65 78 74 29  |s mode on (text)|
00000250  0d 00 1a 15 f4 20 6d 6f  64 65 5f 62 61 73 65 6d  |..... mode_basem|
00000260  6f 64 65 3d 30 0d 00 1b  04 0d 00 1c 3e f4 20 64  |ode=0.......>. d|
00000270  65 66 69 6e 65 20 61 20  70 72 6f 63 20 65 72 72  |efine a proc err|
00000280  6f 72 20 74 6f 20 70 72  69 6e 74 20 6c 69 6e 65  |or to print line|
00000290  20 6e 75 6d 62 65 72 20  65 76 65 6e 20 69 66 20  | number even if |
000002a0  72 75 6e 6e 69 6e 67 0d  00 1d 11 f4 20 75 6e 64  |running..... und|
000002b0  65 72 20 77 69 6d 70 2e  0d 00 1e 0e ee 20 85 20  |er wimp...... . |
000002c0  f2 65 72 72 6f 72 0d 00  1f 04 0d 00 20 28 f4 20  |.error...... (. |
000002d0  72 65 73 65 72 76 65 20  73 70 61 63 65 20 66 6f  |reserve space fo|
000002e0  72 20 63 6f 64 65 20 2f  20 77 6f 72 6b 73 70 61  |r code / workspa|
000002f0  63 65 0d 00 21 14 f4 20  64 65 66 61 75 6c 74 20  |ce..!.. default |
00000300  6f 66 20 36 34 6b 0d 00  22 15 63 6f 64 65 5f 73  |of 64k..".code_s|
00000310  69 7a 65 25 3d 26 31 30  30 30 30 0d 00 23 16 de  |ize%=&10000..#..|
00000320  20 63 6f 64 65 25 20 63  6f 64 65 5f 73 69 7a 65  | code% code_size|
00000330  25 0d 00 24 17 4c 25 3d  63 6f 64 65 25 2b 63 6f  |%..$.L%=code%+co|
00000340  64 65 5f 73 69 7a 65 25  0d 00 25 04 0d 00 26 2f  |de_size%..%...&/|
00000350  f4 20 6c 6f 61 64 20 74  68 65 20 6c 69 62 72 61  |. load the libra|
00000360  72 79 20 64 65 66 69 6e  69 6e 67 20 7a 61 70 27  |ry defining zap'|
00000370  73 20 76 61 72 69 61 62  6c 65 73 0d 00 27 25 c8  |s variables..'%.|
00000380  9b 20 22 3c 5a 61 70 57  6f 72 6b 24 44 69 72 3e  |. "<ZapWork$Dir>|
00000390  2e 44 6f 63 73 2e 45 2d  4c 69 62 72 61 72 79 22  |.Docs.E-Library"|
000003a0  0d 00 28 04 0d 00 29 2c  f4 20 64 65 66 69 6e 65  |..(...),. define|
000003b0  20 7a 61 70 73 20 63 6f  6e 73 74 61 6e 74 73 20  | zaps constants |
000003c0  28 63 61 6c 6c 20 45 2d  4c 69 62 72 61 72 79 29  |(call E-Library)|
000003d0  0d 00 2a 19 f2 64 65 66  69 6e 65 5f 7a 61 70 5f  |..*..define_zap_|
000003e0  76 61 72 69 61 62 6c 65  73 0d 00 2b 04 0d 00 2c  |variables..+...,|
000003f0  2b f4 20 64 65 66 69 6e  65 20 61 6e 79 20 76 61  |+. define any va|
00000400  72 69 61 62 6c 65 73 20  69 6e 20 6f 75 72 20 77  |riables in our w|
00000410  6f 72 6b 73 70 61 63 65  0d 00 2d 15 f2 73 65 74  |orkspace..-..set|
00000420  5f 75 70 5f 76 61 72 69  61 62 6c 65 73 0d 00 2e  |_up_variables...|
00000430  04 0d 00 2f 17 f4 20 61  73 73 65 6d 62 6c 65 20  |.../.. assemble |
00000440  74 68 65 20 63 6f 64 65  0d 00 30 12 f2 61 73 73  |the code..0..ass|
00000450  65 6d 62 6c 65 5f 63 6f  64 65 0d 00 31 04 0d 00  |emble_code..1...|
00000460  32 15 f4 20 73 61 76 65  20 74 68 65 20 6d 6f 64  |2.. save the mod|
00000470  75 6c 65 0d 00 33 51 c8  99 20 22 4f 53 5f 46 69  |ule..3Q.. "OS_Fi|
00000480  6c 65 22 2c 26 30 41 2c  77 6f 72 6b 5f 64 69 72  |le",&0A,work_dir|
00000490  65 63 74 6f 72 79 24 2b  22 2e 5a 61 70 22 2b 6d  |ectory$+".Zap"+m|
000004a0  6f 64 65 5f 6e 61 6d 65  24 2c 26 46 46 41 2c 30  |ode_name$,&FFA,0|
000004b0  2c 63 6f 64 65 25 2c 63  6f 64 65 25 2b 6c 65 6e  |,code%,code%+len|
000004c0  67 74 68 25 0d 00 34 32  f1 20 22 5a 61 70 22 3b  |gth%..42. "Zap";|
000004d0  6d 6f 64 65 5f 6e 61 6d  65 24 2b 22 20 6d 6f 64  |mode_name$+" mod|
000004e0  75 6c 65 20 63 72 65 61  74 65 64 20 61 6e 64 20  |ule created and |
000004f0  73 61 76 65 64 22 0d 00  35 04 0d 00 36 05 e0 0d  |saved"..5...6...|
00000500  00 37 04 0d 00 38 43 f4  20 64 65 66 69 6e 65 20  |.7...8C. define |
00000510  61 6e 79 20 76 61 72 69  61 62 6c 65 73 20 77 65  |any variables we|
00000520  20 77 61 6e 74 20 74 6f  20 73 74 6f 72 65 20 69  | want to store i|
00000530  6e 20 74 68 65 20 6d 6f  64 75 6c 65 20 77 6f 72  |n the module wor|
00000540  6b 73 70 61 63 65 0d 00  39 04 0d 00 3a 17 dd 20  |kspace..9...:.. |
00000550  f2 73 65 74 5f 75 70 5f  76 61 72 69 61 62 6c 65  |.set_up_variable|
00000560  73 0d 00 3b 04 0d 00 3c  2b f4 20 62 75 66 6c 65  |s..;...<+. bufle|
00000570  6e 25 20 3d 20 6c 65 6e  67 74 68 20 6f 66 20 4f  |n% = length of O|
00000580  53 20 63 6f 6d 6d 61 6e  64 20 62 75 66 66 65 72  |S command buffer|
00000590  0d 00 3d 2b f4 20 70 61  72 6d 63 74 25 20 3d 20  |..=+. parmct% = |
000005a0  6e 75 6d 62 65 72 20 6f  66 20 61 72 67 73 75 62  |number of argsub|
000005b0  20 70 61 72 61 6d 65 74  65 72 73 0d 00 3e 11 62  | parameters..>.b|
000005c0  75 66 6c 65 6e 25 20 3d  20 32 35 35 0d 00 3f 04  |uflen% = 255..?.|
000005d0  0d 00 40 33 e3 20 70 61  73 73 3d 25 31 31 30 30  |..@3. pass=%1100|
000005e0  20 b8 20 25 31 31 31 30  20 88 20 32 3a 50 25 3d  | . %1110 . 2:P%=|
000005f0  30 3a 4f 25 3d 63 6f 64  65 25 3a 5b 4f 50 54 70  |0:O%=code%:[OPTp|
00000600  61 73 73 0d 00 41 04 0d  00 42 1e 2e 73 65 61 72  |ass..A...B..sear|
00000610  63 68 5f 70 61 72 6d 20  20 20 20 20 20 20 20 45  |ch_parm        E|
00000620  51 55 44 20 30 0d 00 43  25 2e 63 6d 64 5f 62 75  |QUD 0..C%.cmd_bu|
00000630  66 20 20 20 20 20 20 20  20 20 20 20 20 a4 72 65  |f            .re|
00000640  73 28 62 75 66 6c 65 6e  25 29 0d 00 44 04 0d 00  |s(buflen%)..D...|
00000650  45 07 5d 3a ed 0d 00 46  15 76 61 72 69 61 62 6c  |E.]:...F.variabl|
00000660  65 5f 73 69 7a 65 25 3d  50 25 0d 00 47 05 e1 0d  |e_size%=P%..G...|
00000670  00 48 04 0d 00 49 1c f4  20 61 73 73 65 6d 62 6c  |.H...I.. assembl|
00000680  65 20 74 68 65 20 6d 61  69 6e 20 63 6f 64 65 0d  |e the main code.|
00000690  00 4a 04 0d 00 4b 14 dd  20 f2 61 73 73 65 6d 62  |.J...K.. .assemb|
000006a0  6c 65 5f 63 6f 64 65 0d  00 4c 04 0d 00 4d 12 f4  |le_code..L...M..|
000006b0  20 64 65 66 69 6e 65 20  66 6c 61 67 73 0d 00 4e  | define flags..N|
000006c0  04 0d 00 4f 10 49 66 6c  61 67 25 3d 31 3c 3c 32  |...O.Iflag%=1<<2|
000006d0  37 0d 00 50 10 56 66 6c  61 67 25 3d 31 3c 3c 32  |7..P.Vflag%=1<<2|
000006e0  38 0d 00 51 10 43 66 6c  61 67 25 3d 31 3c 3c 32  |8..Q.Cflag%=1<<2|
000006f0  39 0d 00 52 04 0d 00 53  2a f4 20 64 65 66 69 6e  |9..R...S*. defin|
00000700  65 20 72 65 67 69 73 74  65 72 20 6e 75 6d 62 65  |e register numbe|
00000710  72 73 20 28 66 6f 72 20  6d 61 63 72 6f 73 29 0d  |rs (for macros).|
00000720  00 54 04 0d 00 55 3c 52  30 3d 30 3a 52 31 3d 31  |.T...U<R0=0:R1=1|
00000730  3a 52 32 3d 32 3a 52 33  3d 33 3a 52 34 3d 34 3a  |:R2=2:R3=3:R4=4:|
00000740  52 35 3d 35 3a 52 36 3d  36 3a 52 37 3d 37 3a 52  |R5=5:R6=6:R7=7:R|
00000750  38 3d 38 3a 52 39 3d 39  3a 52 31 30 3d 31 30 0d  |8=8:R9=9:R10=10.|
00000760  00 56 2c 52 31 31 3d 31  31 3a 52 31 32 3d 31 32  |.V,R11=11:R12=12|
00000770  3a 52 31 33 3d 31 33 3a  52 31 34 3d 31 34 3a 52  |:R13=13:R14=14:R|
00000780  31 35 3d 31 35 3a 50 43  3d 31 35 0d 00 57 04 0d  |15=15:PC=15..W..|
00000790  00 58 2a e3 20 70 61 73  73 3d 25 31 31 30 30 20  |.X*. pass=%1100 |
000007a0  b8 20 25 31 31 31 30 20  88 20 32 3a 50 25 3d 30  |. %1110 . 2:P%=0|
000007b0  3a 4f 25 3d 63 6f 64 65  25 0d 00 59 0c 5b 4f 50  |:O%=code%..Y.[OP|
000007c0  54 70 61 73 73 0d 00 5a  04 0d 00 5b 12 2e 4d 6f  |Tpass..Z...[..Mo|
000007d0  64 75 6c 65 5f 68 65 61  64 65 72 0d 00 5c 20 2e  |dule_header..\ .|
000007e0  53 74 61 72 74 5f 63 6f  64 65 20 20 20 20 20 20  |Start_code      |
000007f0  20 20 20 20 20 45 51 55  44 20 30 0d 00 5d 2e 2e  |     EQUD 0..]..|
00000800  49 6e 69 74 69 61 6c 69  73 61 74 69 6f 6e 5f 63  |Initialisation_c|
00000810  6f 64 65 20 20 45 51 55  44 20 69 6e 69 74 69 61  |ode  EQUD initia|
00000820  6c 69 73 65 5f 63 6f 64  65 0d 00 5e 2c 2e 46 69  |lise_code..^,.Fi|
00000830  6e 61 6c 69 73 61 74 69  6f 6e 5f 63 6f 64 65 20  |nalisation_code |
00000840  20 20 20 45 51 55 44 20  66 69 6e 61 6c 69 73 65  |   EQUD finalise|
00000850  5f 63 6f 64 65 0d 00 5f  20 2e 53 65 72 76 69 63  |_code.._ .Servic|
00000860  65 5f 63 61 6c 6c 5f 68  61 6e 64 6c 65 72 20 45  |e_call_handler E|
00000870  51 55 44 20 30 0d 00 60  2b 2e 54 69 74 6c 65 5f  |QUD 0..`+.Title_|
00000880  73 74 72 69 6e 67 20 20  20 20 20 20 20 20 20 45  |string         E|
00000890  51 55 44 20 74 69 74 6c  65 5f 73 74 72 69 6e 67  |QUD title_string|
000008a0  0d 00 61 2a 2e 48 65 6c  70 5f 73 74 72 69 6e 67  |..a*.Help_string|
000008b0  20 20 20 20 20 20 20 20  20 20 45 51 55 44 20 68  |          EQUD h|
000008c0  65 6c 70 5f 73 74 72 69  6e 67 0d 00 62 20 2e 43  |elp_string..b .C|
000008d0  6f 6d 6d 61 6e 64 5f 6b  65 79 77 6f 72 64 5f 74  |ommand_keyword_t|
000008e0  61 62 20 20 45 51 55 44  20 30 0d 00 63 20 2e 53  |ab  EQUD 0..c .S|
000008f0  57 49 5f 63 68 75 6e 6b  5f 6e 75 6d 62 65 72 20  |WI_chunk_number |
00000900  20 20 20 20 45 51 55 44  20 30 0d 00 64 20 2e 53  |    EQUD 0..d .S|
00000910  57 49 5f 68 61 6e 64 6c  65 72 5f 63 6f 64 65 20  |WI_handler_code |
00000920  20 20 20 20 45 51 55 44  20 30 0d 00 65 20 2e 53  |    EQUD 0..e .S|
00000930  57 49 5f 64 65 63 6f 64  69 6e 67 5f 74 61 62 6c  |WI_decoding_tabl|
00000940  65 20 20 20 45 51 55 44  20 30 0d 00 66 20 2e 53  |e   EQUD 0..f .S|
00000950  57 49 5f 64 65 63 6f 64  69 6e 67 5f 63 6f 64 65  |WI_decoding_code|
00000960  20 20 20 20 45 51 55 44  20 30 0d 00 67 04 0d 00  |    EQUD 0..g...|
00000970  68 44 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |hD\\\\\\\\\\\\\\|
00000980  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000009b0  5c 5c 0d 00 69 42 5c 20  54 49 54 4c 45 53 20 80  |\\..iB\ TITLES .|
000009c0  20 43 4f 4d 4d 41 4e 44  20 54 41 42 4c 45 53 20  | COMMAND TABLES |
000009d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000009f0  20 20 20 5c 0d 00 6a 44  5c 5c 5c 5c 5c 5c 5c 5c  |   \..jD\\\\\\\\|
00000a00  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00000a30  5c 5c 5c 5c 5c 5c 5c 5c  0d 00 6b 04 0d 00 6c 10  |\\\\\\\\..k...l.|
00000a40  2e 68 65 6c 70 5f 73 74  72 69 6e 67 0d 00 6d 3f  |.help_string..m?|
00000a50  a4 53 28 22 5a 61 70 22  2b 6d 6f 64 65 5f 6e 61  |.S("Zap"+mode_na|
00000a60  6d 65 24 2b bd 39 2b 76  65 72 24 2b 22 20 28 22  |me$+.9+ver$+" ("|
00000a70  2b a4 64 61 74 65 2b 22  29 20 a9 20 22 2b 6d 6f  |+.date+") . "+mo|
00000a80  64 65 5f 61 75 74 68 6f  72 24 29 0d 00 6e 04 0d  |de_author$)..n..|
00000a90  00 6f 11 2e 74 69 74 6c  65 5f 73 74 72 69 6e 67  |.o..title_string|
00000aa0  0d 00 70 18 a4 53 28 22  5a 61 70 22 2b 6d 6f 64  |..p..S("Zap"+mod|
00000ab0  65 5f 6e 61 6d 65 24 29  0d 00 71 04 0d 00 72 44  |e_name$)..q...rD|
00000ac0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00000b00  0d 00 73 42 5c 20 49 4e  49 54 49 41 4c 49 53 45  |..sB\ INITIALISE|
00000b10  20 80 20 46 49 4e 41 4c  49 53 45 20 20 20 20 20  | . FINALISE     |
00000b20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000b40  20 5c 0d 00 74 44 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  | \..tD\\\\\\\\\\|
00000b50  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00000b80  5c 5c 5c 5c 5c 5c 0d 00  75 04 0d 00 76 14 2e 69  |\\\\\\..u...v..i|
00000b90  6e 69 74 69 61 6c 69 73  65 5f 63 6f 64 65 0d 00  |nitialise_code..|
00000ba0  77 08 a4 4a 53 52 0d 00  78 0d 4d 4f 56 20 52 30  |w..JSR..x.MOV R0|
00000bb0  2c 23 36 0d 00 79 13 4c  44 52 20 52 33 2c 76 61  |,#6..y.LDR R3,va|
00000bc0  72 5f 73 69 7a 65 0d 00  7a 3b 53 57 49 20 22 58  |r_size..z;SWI "X|
00000bd0  4f 53 5f 4d 6f 64 75 6c  65 22 20 20 20 20 20 20  |OS_Module"      |
00000be0  20 20 20 20 20 20 20 20  5c 20 63 6c 61 69 6d 20  |        \ claim |
00000bf0  76 61 72 61 62 6c 65 20  77 6f 72 6b 73 70 61 63  |varable workspac|
00000c00  65 0d 00 7b 0a a4 52 54  53 56 53 0d 00 7c 43 4d  |e..{..RTSVS..|CM|
00000c10  4f 56 20 52 31 31 2c 52  32 20 20 20 20 20 20 20  |OV R11,R2       |
00000c20  20 20 20 20 20 20 20 20  20 20 20 20 20 5c 20 63  |             \ c|
00000c30  6c 61 69 6d 65 64 20 62  6c 6f 63 6b 20 28 52 31  |laimed block (R1|
00000c40  31 20 66 72 6f 6d 20 6e  6f 77 20 6f 6e 29 0d 00  |1 from now on)..|
00000c50  7d 40 53 54 52 20 52 31  31 2c 5b 52 31 32 5d 20  |}@STR R11,[R12] |
00000c60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000c70  5c 20 73 61 76 65 20 61  73 20 6d 79 20 77 6f 72  |\ save as my wor|
00000c80  6b 73 70 61 63 65 20 70  6f 69 6e 74 65 72 0d 00  |kspace pointer..|
00000c90  7e 3d 53 54 52 20 52 31  31 2c 77 6f 72 6b 73 70  |~=STR R11,worksp|
00000ca0  61 63 65 5f 61 64 64 72  65 73 73 20 20 20 20 20  |ace_address     |
00000cb0  5c 20 73 61 76 65 20 69  74 20 69 6e 20 74 68 65  |\ save it in the|
00000cc0  20 6d 6f 64 75 6c 65 20  66 6f 72 0d 00 7f 37 4d  | module for...7M|
00000cd0  4f 56 20 52 30 2c 23 31  38 20 20 20 20 20 20 20  |OV R0,#18       |
00000ce0  20 20 20 20 20 20 20 20  20 20 20 20 20 5c 20 61  |             \ a|
00000cf0  63 63 65 73 73 69 6e 67  20 63 6f 6d 6d 61 6e 64  |ccessing command|
00000d00  73 2e 0d 00 80 14 41 44  52 20 52 31 2c 7a 61 70  |s.....ADR R1,zap|
00000d10  5f 74 69 74 6c 65 0d 00  81 2c 53 57 49 20 22 58  |_title...,SWI "X|
00000d20  4f 53 5f 4d 6f 64 75 6c  65 22 20 20 20 20 20 20  |OS_Module"      |
00000d30  20 20 20 20 20 20 20 20  5c 20 66 69 6e 64 20 7a  |        \ find z|
00000d40  61 70 0d 00 82 2c a4 52  54 53 56 53 20 20 20 20  |ap...,.RTSVS    |
00000d50  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000d60  20 20 20 5c 20 6e 6f 74  20 66 6f 75 6e 64 0d 00  |   \ not found..|
00000d70  83 31 4d 4f 56 20 52 31  32 2c 52 34 20 20 20 20  |.1MOV R12,R4    |
00000d80  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000d90  5c 20 7a 61 70 20 77 6f  72 6b 73 70 61 63 65 0d  |\ zap workspace.|
00000da0  00 84 39 41 44 52 20 52  30 2c 6b 65 79 5f 63 6f  |..9ADR R0,key_co|
00000db0  6d 6d 61 6e 64 5f 74 61  62 6c 65 20 20 20 20 20  |mmand_table     |
00000dc0  20 5c 20 61 64 64 20 74  61 62 6c 65 20 6f 66 20  | \ add table of |
00000dd0  63 6f 6d 6d 61 6e 64 73  0d 00 85 1a a4 63 61 6c  |commands.....cal|
00000de0  6c 28 5a 61 70 5f 41 64  64 43 6f 6d 6d 61 6e 64  |l(Zap_AddCommand|
00000df0  73 29 0d 00 86 0a a4 52  54 53 56 53 0d 00 87 0d  |s).....RTSVS....|
00000e00  4d 4f 56 20 52 31 2c 23  30 0d 00 88 0e 4d 4f 56  |MOV R1,#0....MOV|
00000e10  20 52 32 2c 52 31 31 0d  00 89 13 4c 44 52 20 52  | R2,R11....LDR R|
00000e20  33 2c 76 61 72 5f 73 69  7a 65 0d 00 8a 3b a4 63  |3,var_size...;.c|
00000e30  61 6c 6c 28 5a 61 70 5f  46 69 6c 6c 57 6f 72 64  |all(Zap_FillWord|
00000e40  73 29 20 20 20 20 20 20  20 20 20 5c 20 63 6c 65  |s)         \ cle|
00000e50  61 72 20 77 6f 72 6b 73  70 61 63 65 20 74 6f 20  |ar workspace to |
00000e60  7a 65 72 6f 73 0d 00 8b  08 a4 52 54 53 0d 00 8c  |zeros.....RTS...|
00000e70  04 0d 00 8d 0d 2e 76 61  72 5f 73 69 7a 65 0d 00  |......var_size..|
00000e80  8e 17 45 51 55 44 20 76  61 72 69 61 62 6c 65 5f  |..EQUD variable_|
00000e90  73 69 7a 65 25 0d 00 8f  04 0d 00 90 0e 2e 7a 61  |size%.........za|
00000ea0  70 5f 74 69 74 6c 65 0d  00 91 0d a4 53 28 22 5a  |p_title.....S("Z|
00000eb0  61 70 22 29 0d 00 92 04  0d 00 93 16 2e 77 6f 72  |ap").........wor|
00000ec0  6b 73 70 61 63 65 5f 61  64 64 72 65 73 73 0d 00  |kspace_address..|
00000ed0  94 0a 45 51 55 44 20 30  0d 00 95 04 0d 00 96 1d  |..EQUD 0........|
00000ee0  5c 58 20 52 31 31 3d 6d  6f 64 75 6c 65 20 77 6f  |\X R11=module wo|
00000ef0  72 6b 73 70 61 63 65 20  7c 0d 00 97 04 0d 00 98  |rkspace |.......|
00000f00  12 2e 67 65 74 5f 77 6f  72 6b 73 70 61 63 65 0d  |..get_workspace.|
00000f10  00 99 1d 4c 44 52 20 52  31 31 2c 77 6f 72 6b 73  |...LDR R11,works|
00000f20  70 61 63 65 5f 61 64 64  72 65 73 73 0d 00 9a 0e  |pace_address....|
00000f30  4d 4f 56 20 50 43 2c 52  31 34 0d 00 9b 04 0d 00  |MOV PC,R14......|
00000f40  9c 12 2e 66 69 6e 61 6c  69 73 65 5f 63 6f 64 65  |...finalise_code|
00000f50  0d 00 9d 08 a4 4a 53 52  0d 00 9e 0d 4d 4f 56 20  |.....JSR....MOV |
00000f60  52 30 2c 23 37 0d 00 9f  10 4c 44 52 20 52 32 2c  |R0,#7....LDR R2,|
00000f70  5b 52 31 32 5d 0d 00 a0  32 53 57 49 20 22 58 4f  |[R12]...2SWI "XO|
00000f80  53 5f 4d 6f 64 75 6c 65  22 20 20 20 20 20 20 20  |S_Module"       |
00000f90  20 20 20 20 20 20 20 5c  20 66 72 65 65 20 77 6f  |       \ free wo|
00000fa0  72 6b 73 70 61 63 65 0d  00 a1 0a a4 52 54 53 56  |rkspace.....RTSV|
00000fb0  53 0d 00 a2 0d 4d 4f 56  20 52 30 2c 23 30 0d 00  |S....MOV R0,#0..|
00000fc0  a3 35 53 54 52 20 52 30  2c 5b 52 31 32 5d 20 20  |.5STR R0,[R12]  |
00000fd0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000fe0  5c 20 6e 75 6c 6c 20 70  72 69 76 61 74 65 20 77  |\ null private w|
00000ff0  6f 72 64 0d 00 a4 08 a4  52 54 53 0d 00 a5 04 0d  |ord.....RTS.....|
00001000  00 a6 41 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |..A\\\\\\\\\\\\\|
00001010  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00001040  0d 00 a7 41 5c 20 43 6f  6d 6d 61 6e 64 20 74 61  |...A\ Command ta|
00001050  62 6c 65 20 20 20 20 20  20 20 20 20 20 20 20 20  |ble             |
00001060  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00001080  5c 0d 00 a8 41 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\...A\\\\\\\\\\\|
00001090  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000010c0  5c 5c 0d 00 a9 04 0d 00  aa 16 2e 6b 65 79 5f 63  |\\.........key_c|
000010d0  6f 6d 6d 61 6e 64 5f 74  61 62 6c 65 0d 00 ab 1a  |ommand_table....|
000010e0  45 51 55 44 20 6b 65 79  5f 63 6f 6d 6d 61 6e 64  |EQUD key_command|
000010f0  5f 74 61 62 6c 65 0d 00  ac 35 45 51 55 44 20 30  |_table...5EQUD 0|
00001100  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001110  20 20 20 20 20 20 20 20  5c 20 73 65 72 76 69 63  |        \ servic|
00001120  65 20 63 61 6c 6c 20 63  6f 64 65 0d 00 ad 1f a4  |e call code.....|
00001130  63 6f 6d 28 22 46 49 4c  54 45 52 53 45 4c 22 2c  |com("FILTERSEL",|
00001140  66 69 6c 74 65 72 73 65  6c 29 0d 00 ae 1b a4 63  |filtersel).....c|
00001150  6f 6d 28 22 57 49 4e 4c  45 46 54 22 2c 77 69 6e  |om("WINLEFT",win|
00001160  6c 65 66 74 29 0d 00 af  1d a4 63 6f 6d 28 22 57  |left).....com("W|
00001170  49 4e 52 49 47 48 54 22  2c 77 69 6e 72 69 67 68  |INRIGHT",winrigh|
00001180  74 29 0d 00 b0 17 a4 63  6f 6d 28 22 57 49 4e 55  |t).....com("WINU|
00001190  50 22 2c 77 69 6e 75 70  29 0d 00 b1 1b a4 63 6f  |P",winup).....co|
000011a0  6d 28 22 57 49 4e 44 4f  57 4e 22 2c 77 69 6e 64  |m("WINDOWN",wind|
000011b0  6f 77 6e 29 0d 00 b2 23  a4 63 6f 6d 28 22 44 45  |own)...#.com("DE|
000011c0  4c 57 4f 52 44 4c 45 46  54 22 2c 64 65 6c 77 6f  |LWORDLEFT",delwo|
000011d0  72 64 6c 65 66 74 29 0d  00 b3 25 a4 63 6f 6d 28  |rdleft)...%.com(|
000011e0  22 44 45 4c 57 4f 52 44  52 49 47 48 54 22 2c 64  |"DELWORDRIGHT",d|
000011f0  65 6c 77 6f 72 64 72 69  67 68 74 29 0d 00 b4 21  |elwordright)...!|
00001200  a4 63 6f 6d 28 22 53 45  41 52 43 48 57 4f 52 44  |.com("SEARCHWORD|
00001210  22 2c 73 65 61 72 63 68  77 6f 72 64 29 0d 00 b5  |",searchword)...|
00001220  11 a4 63 6f 6d 28 22 46  57 22 2c 66 77 29 0d 00  |..com("FW",fw)..|
00001230  b6 11 a4 63 6f 6d 28 22  42 57 22 2c 62 77 29 0d  |...com("BW",bw).|
00001240  00 b7 27 45 51 55 44 20  30 20 20 20 20 20 20 20  |..'EQUD 0       |
00001250  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001260  20 5c 20 65 6e 64 0d 00  b8 04 0d 00 b9 44 5c 5c  | \ end.......D\\|
00001270  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000012a0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 0d 00  |\\\\\\\\\\\\\\..|
000012b0  ba 44 5c 20 57 6f 72 64  20 6d 6f 76 65 6d 65 6e  |.D\ Word movemen|
000012c0  74 20 63 6f 6d 6d 61 6e  64 73 20 20 20 20 20 20  |t commands      |
000012d0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000012f0  20 5c 0d 00 bb 44 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  | \...D\\\\\\\\\\|
00001300  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00001330  5c 5c 5c 5c 5c 5c 0d 00  bc 10 45 51 55 44 20 28  |\\\\\\....EQUD (|
00001340  31 3c 3c 31 32 29 0d 00  bd 07 2e 66 77 0d 00 be  |1<<12).....fw...|
00001350  14 53 54 4d 46 44 20 52  31 33 21 2c 7b 52 31 34  |.STMFD R13!,{R14|
00001360  7d 0d 00 bf 17 4c 44 52  20 52 30 2c 5b 52 31 30  |}....LDR R0,[R10|
00001370  2c 23 63 5f 6f 66 66 5d  0d 00 c0 04 0d 00 c1 0d  |,#c_off]........|
00001380  54 45 51 20 52 31 2c 23  30 0d 00 c2 09 2e 66 77  |TEQ R1,#0.....fw|
00001390  30 31 0d 00 c3 11 42 4c  4e 45 20 66 77 64 5f 77  |01....BLNE fwd_w|
000013a0  6f 72 64 0d 00 c4 13 53  55 42 4e 45 53 20 52 31  |ord....SUBNES R1|
000013b0  2c 52 31 2c 23 31 0d 00  c5 0c 42 4e 45 20 66 77  |,R1,#1....BNE fw|
000013c0  30 31 0d 00 c6 04 0d 00  c7 1b a4 63 61 6c 6c 28  |01.........call(|
000013d0  5a 61 70 5f 4a 75 6d 70  74 6f 4f 66 66 73 65 74  |Zap_JumptoOffset|
000013e0  29 0d 00 c8 13 4c 44 4d  46 44 20 52 31 33 21 2c  |)....LDMFD R13!,|
000013f0  7b 50 43 7d 0d 00 c9 04  0d 00 ca 44 5c 5c 5c 5c  |{PC}.......D\\\\|
00001400  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00001430  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 0d 00 cb 10  |\\\\\\\\\\\\....|
00001440  45 51 55 44 20 28 31 3c  3c 31 32 29 0d 00 cc 07  |EQUD (1<<12)....|
00001450  2e 62 77 0d 00 cd 14 53  54 4d 46 44 20 52 31 33  |.bw....STMFD R13|
00001460  21 2c 7b 52 31 34 7d 0d  00 ce 17 4c 44 52 20 52  |!,{R14}....LDR R|
00001470  30 2c 5b 52 31 30 2c 23  63 5f 6f 66 66 5d 0d 00  |0,[R10,#c_off]..|
00001480  cf 04 0d 00 d0 0d 54 45  51 20 52 31 2c 23 30 0d  |......TEQ R1,#0.|
00001490  00 d1 09 2e 62 77 30 31  0d 00 d2 12 42 4c 4e 45  |....bw01....BLNE|
000014a0  20 62 61 63 6b 5f 77 6f  72 64 0d 00 d3 13 53 55  | back_word....SU|
000014b0  42 4e 45 53 20 52 31 2c  52 31 2c 23 31 0d 00 d4  |BNES R1,R1,#1...|
000014c0  0c 42 4e 45 20 62 77 30  31 0d 00 d5 04 0d 00 d6  |.BNE bw01.......|
000014d0  1b a4 63 61 6c 6c 28 5a  61 70 5f 4a 75 6d 70 74  |..call(Zap_Jumpt|
000014e0  6f 4f 66 66 73 65 74 29  0d 00 d7 13 4c 44 4d 46  |oOffset)....LDMF|
000014f0  44 20 52 31 33 21 2c 7b  50 43 7d 0d 00 d8 04 0d  |D R13!,{PC}.....|
00001500  00 d9 44 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |..D\\\\\\\\\\\\\|
00001510  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00001540  5c 5c 5c 0d 00 da 44 5c  20 57 6f 72 64 20 64 65  |\\\...D\ Word de|
00001550  6c 65 74 69 6f 6e 20 63  6f 6d 6d 61 6e 64 73 20  |letion commands |
00001560  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00001580  20 20 20 20 20 20 5c 0d  00 db 44 5c 5c 5c 5c 5c  |      \...D\\\\\|
00001590  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000015c0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 0d 00 dc 0a 45  |\\\\\\\\\\\....E|
000015d0  51 55 44 20 30 0d 00 dd  04 0d 00 de 10 2e 64 65  |QUD 0.........de|
000015e0  6c 77 6f 72 64 6c 65 66  74 0d 00 df 14 53 54 4d  |lwordleft....STM|
000015f0  46 44 20 52 31 33 21 2c  7b 52 31 34 7d 0d 00 e0  |FD R13!,{R14}...|
00001600  04 0d 00 e1 17 4c 44 52  20 52 33 2c 5b 52 31 30  |.....LDR R3,[R10|
00001610  2c 23 63 5f 6f 66 66 5d  0d 00 e2 0d 4d 4f 56 20  |,#c_off]....MOV |
00001620  52 30 2c 52 33 0d 00 e3  04 0d 00 e4 0d 54 45 51  |R0,R3........TEQ|
00001630  20 52 31 2c 23 30 0d 00  e5 0a 2e 64 77 6c 30 31  | R1,#0.....dwl01|
00001640  0d 00 e6 12 42 4c 4e 45  20 62 61 63 6b 5f 77 6f  |....BLNE back_wo|
00001650  72 64 0d 00 e7 13 53 55  42 4e 45 53 20 52 31 2c  |rd....SUBNES R1,|
00001660  52 31 2c 23 31 0d 00 e8  0d 42 4e 45 20 64 77 6c  |R1,#1....BNE dwl|
00001670  30 31 0d 00 e9 04 0d 00  ea 2e 5c 5c 5c 20 52 30  |01........\\\ R0|
00001680  20 3d 20 73 74 61 72 74  20 6f 66 20 62 6c 6f 63  | = start of bloc|
00001690  6b 2c 20 52 33 20 3d 20  65 6e 64 20 6f 66 20 62  |k, R3 = end of b|
000016a0  6c 6f 63 6b 0d 00 eb 04  0d 00 ec 0d 4d 4f 56 20  |lock........MOV |
000016b0  52 31 2c 52 30 0d 00 ed  10 53 55 42 20 52 32 2c  |R1,R0....SUB R2,|
000016c0  52 33 2c 52 30 0d 00 ee  16 a4 63 61 6c 6c 28 5a  |R3,R0.....call(Z|
000016d0  61 70 5f 53 74 61 72 74  4f 70 29 0d 00 ef 0d 42  |ap_StartOp)....B|
000016e0  56 53 20 64 77 6c 30 32  0d 00 f0 0d 4d 4f 56 20  |VS dwl02....MOV |
000016f0  52 30 2c 23 32 0d 00 f1  16 a4 63 61 6c 6c 28 5a  |R0,#2.....call(Z|
00001700  61 70 5f 43 6f 6d 6d 61  6e 64 29 0d 00 f2 0d 42  |ap_Command)....B|
00001710  56 53 20 64 77 6c 30 32  0d 00 f3 15 a4 63 61 6c  |VS dwl02.....cal|
00001720  6c 28 5a 61 70 5f 53 74  6f 70 4f 70 29 0d 00 f4  |l(Zap_StopOp)...|
00001730  04 0d 00 f5 0a 2e 64 77  6c 30 32 0d 00 f6 13 4c  |......dwl02....L|
00001740  44 4d 46 44 20 52 31 33  21 2c 7b 50 43 7d 0d 00  |DMFD R13!,{PC}..|
00001750  f7 04 0d 00 f8 44 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |.....D\\\\\\\\\\|
00001760  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00001790  5c 5c 5c 5c 5c 5c 0d 00  f9 10 45 51 55 44 20 28  |\\\\\\....EQUD (|
000017a0  31 3c 3c 31 32 29 0d 00  fa 04 0d 00 fb 11 2e 64  |1<<12).........d|
000017b0  65 6c 77 6f 72 64 72 69  67 68 74 0d 00 fc 14 53  |elwordright....S|
000017c0  54 4d 46 44 20 52 31 33  21 2c 7b 52 31 34 7d 0d  |TMFD R13!,{R14}.|
000017d0  00 fd 04 0d 00 fe 17 4c  44 52 20 52 33 2c 5b 52  |.......LDR R3,[R|
000017e0  31 30 2c 23 63 5f 6f 66  66 5d 0d 00 ff 0d 4d 4f  |10,#c_off]....MO|
000017f0  56 20 52 30 2c 52 33 0d  01 00 04 0d 01 01 0d 54  |V R0,R3........T|
00001800  45 51 20 52 31 2c 23 30  0d 01 02 0a 2e 64 77 72  |EQ R1,#0.....dwr|
00001810  30 31 0d 01 03 11 42 4c  4e 45 20 66 77 64 5f 77  |01....BLNE fwd_w|
00001820  6f 72 64 0d 01 04 13 53  55 42 4e 45 53 20 52 31  |ord....SUBNES R1|
00001830  2c 52 31 2c 23 31 0d 01  05 0d 42 4e 45 20 64 77  |,R1,#1....BNE dw|
00001840  72 30 31 0d 01 06 04 0d  01 07 2e 5c 5c 5c 20 52  |r01........\\\ R|
00001850  33 20 3d 20 73 74 61 72  74 20 6f 66 20 62 6c 6f  |3 = start of blo|
00001860  63 6b 2c 20 52 30 20 3d  20 65 6e 64 20 6f 66 20  |ck, R0 = end of |
00001870  62 6c 6f 63 6b 0d 01 08  04 0d 01 09 0d 4d 4f 56  |block........MOV|
00001880  20 52 31 2c 52 33 0d 01  0a 10 53 55 42 20 52 32  | R1,R3....SUB R2|
00001890  2c 52 30 2c 52 33 0d 01  0b 16 a4 63 61 6c 6c 28  |,R0,R3.....call(|
000018a0  5a 61 70 5f 53 74 61 72  74 4f 70 29 0d 01 0c 0d  |Zap_StartOp)....|
000018b0  42 56 53 20 64 77 72 30  32 0d 01 0d 0d 4d 4f 56  |BVS dwr02....MOV|
000018c0  20 52 30 2c 23 32 0d 01  0e 16 a4 63 61 6c 6c 28  | R0,#2.....call(|
000018d0  5a 61 70 5f 43 6f 6d 6d  61 6e 64 29 0d 01 0f 0d  |Zap_Command)....|
000018e0  42 56 53 20 64 77 72 30  32 0d 01 10 15 a4 63 61  |BVS dwr02.....ca|
000018f0  6c 6c 28 5a 61 70 5f 53  74 6f 70 4f 70 29 0d 01  |ll(Zap_StopOp)..|
00001900  11 04 0d 01 12 0a 2e 64  77 72 30 32 0d 01 13 13  |.......dwr02....|
00001910  4c 44 4d 46 44 20 52 31  33 21 2c 7b 50 43 7d 0d  |LDMFD R13!,{PC}.|
00001920  01 14 04 0d 01 15 44 5c  5c 5c 5c 5c 5c 5c 5c 5c  |......D\\\\\\\\\|
00001930  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00001960  5c 5c 5c 5c 5c 5c 5c 0d  01 16 44 5c 20 57 6f 72  |\\\\\\\...D\ Wor|
00001970  64 20 73 65 61 72 63 68  20 63 6f 6d 6d 61 6e 64  |d search command|
00001980  73 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |s               |
00001990  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000019a0  20 20 20 20 20 20 20 20  20 20 5c 0d 01 17 44 5c  |          \...D\|
000019b0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000019e0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 0d  |\\\\\\\\\\\\\\\.|
000019f0  01 18 17 45 51 55 44 20  28 32 3c 3c 33 29 2b 28  |...EQUD (2<<3)+(|
00001a00  31 3c 3c 31 32 29 0d 01  19 04 0d 01 1a 0f 2e 73  |1<<12).........s|
00001a10  65 61 72 63 68 77 6f 72  64 0d 01 1b 14 53 54 4d  |earchword....STM|
00001a20  46 44 20 52 31 33 21 2c  7b 52 31 34 7d 0d 01 1c  |FD R13!,{R14}...|
00001a30  14 42 4c 20 67 65 74 5f  77 6f 72 6b 73 70 61 63  |.BL get_workspac|
00001a40  65 0d 01 1d 0d 4d 4f 56  20 52 32 2c 52 30 0d 01  |e....MOV R2,R0..|
00001a50  1e 04 0d 01 1f 0d 54 45  51 20 52 31 2c 23 30 0d  |......TEQ R1,#0.|
00001a60  01 20 0c 42 45 51 20 73  77 30 32 0d 01 21 09 2e  |. .BEQ sw02..!..|
00001a70  73 77 30 31 0d 01 22 12  4c 44 52 20 52 30 2c 5b  |sw01..".LDR R0,[|
00001a80  52 32 5d 2c 23 34 0d 01  23 18 a4 53 54 52 28 52  |R2],#4..#..STR(R|
00001a90  30 2c 73 65 61 72 63 68  5f 70 61 72 6d 29 0d 01  |0,search_parm)..|
00001aa0  24 11 42 4c 20 73 65 61  72 63 68 5f 72 74 6e 0d  |$.BL search_rtn.|
00001ab0  01 25 0c 42 56 53 20 73  77 30 32 0d 01 26 11 53  |.%.BVS sw02..&.S|
00001ac0  55 42 53 20 52 31 2c 52  31 2c 23 31 0d 01 27 0c  |UBS R1,R1,#1..'.|
00001ad0  42 4e 45 20 73 77 30 31  0d 01 28 04 0d 01 29 09  |BNE sw01..(...).|
00001ae0  2e 73 77 30 32 0d 01 2a  13 4c 44 4d 46 44 20 52  |.sw02..*.LDMFD R|
00001af0  31 33 21 2c 7b 50 43 7d  0d 01 2b 04 0d 01 2c 44  |13!,{PC}..+...,D|
00001b00  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00001b40  0d 01 2d 0f 2e 73 65 61  72 63 68 5f 72 74 6e 0d  |..-..search_rtn.|
00001b50  01 2e 1a 53 54 4d 46 44  20 52 31 33 21 2c 7b 52  |...STMFD R13!,{R|
00001b60  31 2d 52 37 2c 52 31 34  7d 0d 01 2f 04 0d 01 30  |1-R7,R14}../...0|
00001b70  38 4c 44 52 20 52 37 2c  5b 52 31 30 2c 23 63 5f  |8LDR R7,[R10,#c_|
00001b80  6f 66 66 5d 20 20 20 20  20 5c 20 52 37 20 3d 20  |off]     \ R7 = |
00001b90  63 75 72 72 65 6e 74 20  63 75 72 73 6f 72 20 6f  |current cursor o|
00001ba0  66 66 73 65 74 0d 01 31  04 0d 01 32 0d 4d 4f 56  |ffset..1...2.MOV|
00001bb0  20 52 30 2c 52 37 0d 01  33 0f 42 4c 20 67 65 74  | R0,R7..3.BL get|
00001bc0  63 5f 6f 66 66 0d 01 34  0f 42 4c 20 77 6f 72 64  |c_off..4.BL word|
00001bd0  63 68 61 72 0d 01 35 0e  42 43 43 20 73 72 5f 65  |char..5.BCC sr_e|
00001be0  72 72 0d 01 36 04 0d 01  37 09 2e 73 72 30 31 0d  |rr..6...7..sr01.|
00001bf0  01 38 0d 54 45 51 20 52  30 2c 23 30 0d 01 39 0c  |.8.TEQ R0,#0..9.|
00001c00  42 45 51 20 73 72 30 32  0d 01 3a 10 53 55 42 20  |BEQ sr02..:.SUB |
00001c10  52 30 2c 52 30 2c 23 31  0d 01 3b 0f 42 4c 20 67  |R0,R0,#1..;.BL g|
00001c20  65 74 63 5f 6f 66 66 0d  01 3c 0f 42 4c 20 77 6f  |etc_off..<.BL wo|
00001c30  72 64 63 68 61 72 0d 01  3d 0c 42 43 53 20 73 72  |rdchar..=.BCS sr|
00001c40  30 31 0d 01 3e 10 41 44  44 20 52 30 2c 52 30 2c  |01..>.ADD R0,R0,|
00001c50  23 31 0d 01 3f 09 2e 73  72 30 32 0d 01 40 04 0d  |#1..?..sr02..@..|
00001c60  01 41 30 4d 4f 56 20 52  35 2c 52 30 20 20 20 20  |.A0MOV R5,R0    |
00001c70  20 20 20 20 20 20 20 20  20 20 20 5c 20 52 35 20  |           \ R5 |
00001c80  3d 20 73 74 61 72 74 20  6f 66 20 77 6f 72 64 0d  |= start of word.|
00001c90  01 42 04 0d 01 43 2e 4c  44 52 20 52 32 2c 5b 52  |.B...C.LDR R2,[R|
00001ca0  39 2c 23 66 5f 6c 65 6e  5d 20 20 20 20 20 20 5c  |9,#f_len]      \|
00001cb0  20 52 32 20 3d 20 66 69  6c 65 20 6c 65 6e 67 74  | R2 = file lengt|
00001cc0  68 0d 01 44 0d 4d 4f 56  20 52 30 2c 52 37 0d 01  |h..D.MOV R0,R7..|
00001cd0  45 09 2e 73 72 30 33 0d  01 46 0d 43 4d 50 20 52  |E..sr03..F.CMP R|
00001ce0  30 2c 52 32 0d 01 47 0f  4d 4f 56 48 53 20 52 30  |0,R2..G.MOVHS R0|
00001cf0  2c 52 32 0d 01 48 0c 42  48 53 20 73 72 30 34 0d  |,R2..H.BHS sr04.|
00001d00  01 49 10 41 44 44 20 52  30 2c 52 30 2c 23 31 0d  |.I.ADD R0,R0,#1.|
00001d10  01 4a 0f 42 4c 20 67 65  74 63 5f 6f 66 66 0d 01  |.J.BL getc_off..|
00001d20  4b 0f 42 4c 20 77 6f 72  64 63 68 61 72 0d 01 4c  |K.BL wordchar..L|
00001d30  0c 42 43 53 20 73 72 30  33 0d 01 4d 09 2e 73 72  |.BCS sr03..M..sr|
00001d40  30 34 0d 01 4e 04 0d 01  4f 32 4d 4f 56 20 52 36  |04..N...O2MOV R6|
00001d50  2c 52 30 20 20 20 20 20  20 20 20 20 20 20 20 20  |,R0             |
00001d60  20 20 5c 20 52 36 20 3d  20 65 6e 64 20 6f 66 20  |  \ R6 = end of |
00001d70  77 6f 72 64 20 2b 20 31  0d 01 50 31 53 55 42 20  |word + 1..P1SUB |
00001d80  52 34 2c 52 36 2c 52 35  20 20 20 20 20 20 20 20  |R4,R6,R5        |
00001d90  20 20 20 20 5c 20 52 34  20 3d 20 6c 65 6e 67 74  |    \ R4 = lengt|
00001da0  68 20 6f 66 20 77 6f 72  64 0d 01 51 04 0d 01 52  |h of word..Q...R|
00001db0  10 41 44 44 20 52 30 2c  52 34 2c 23 31 0d 01 53  |.ADD R0,R4,#1..S|
00001dc0  14 a4 63 61 6c 6c 28 5a  61 70 5f 43 6c 61 69 6d  |..call(Zap_Claim|
00001dd0  29 0d 01 54 1b 4c 44 4d  56 53 46 44 20 52 31 33  |)..T.LDMVSFD R13|
00001de0  21 2c 7b 52 31 2d 52 37  2c 50 43 7d 0d 01 55 2d  |!,{R1-R7,PC}..U-|
00001df0  4d 4f 56 20 52 37 2c 52  30 20 20 20 20 20 20 20  |MOV R7,R0       |
00001e00  20 20 20 20 20 20 20 20  5c 20 52 37 20 3d 20 68  |        \ R7 = h|
00001e10  65 61 70 20 62 6c 6f 63  6b 0d 01 56 04 0d 01 57  |eap block..V...W|
00001e20  19 4c 44 52 20 52 30 2c  5b 52 39 2c 23 66 5f 73  |.LDR R0,[R9,#f_s|
00001e30  70 6c 69 74 6f 5d 0d 01  58 0d 43 4d 50 20 52 35  |plito]..X.CMP R5|
00001e40  2c 52 30 0d 01 59 0f 43  4d 50 4c 54 20 52 30 2c  |,R0..Y.CMPLT R0,|
00001e50  52 36 0d 01 5a 0c 42 4c  54 20 73 72 30 35 0d 01  |R6..Z.BLT sr05..|
00001e60  5b 04 0d 01 5c 19 5c 20  57 6f 72 64 20 69 73 20  |[...\.\ Word is |
00001e70  69 6e 20 6f 6e 65 20 70  61 72 74 0d 01 5d 16 4c  |in one part..].L|
00001e80  44 52 20 52 31 2c 5b 52  39 2c 23 66 5f 70 74 72  |DR R1,[R9,#f_ptr|
00001e90  5d 0d 01 5e 10 41 44 44  20 52 31 2c 52 31 2c 52  |]..^.ADD R1,R1,R|
00001ea0  35 0d 01 5f 0d 4d 4f 56  20 52 32 2c 52 37 0d 01  |5.._.MOV R2,R7..|
00001eb0  60 0d 4d 4f 56 20 52 33  2c 52 34 0d 01 61 18 a4  |`.MOV R3,R4..a..|
00001ec0  63 61 6c 6c 28 5a 61 70  5f 4d 6f 76 65 42 79 74  |call(Zap_MoveByt|
00001ed0  65 73 29 0d 01 62 10 42  56 53 20 65 72 72 5f 66  |es)..b.BVS err_f|
00001ee0  72 65 65 0d 01 63 0a 42  20 73 72 30 36 0d 01 64  |ree..c.B sr06..d|
00001ef0  04 0d 01 65 1a 5c 20 57  6f 72 64 20 69 73 20 69  |...e.\ Word is i|
00001f00  6e 20 74 77 6f 20 70 61  72 74 73 0d 01 66 09 2e  |n two parts..f..|
00001f10  73 72 30 35 0d 01 67 16  4c 44 52 20 52 31 2c 5b  |sr05..g.LDR R1,[|
00001f20  52 39 2c 23 66 5f 70 74  72 5d 0d 01 68 10 41 44  |R9,#f_ptr]..h.AD|
00001f30  44 20 52 31 2c 52 31 2c  52 35 0d 01 69 0d 4d 4f  |D R1,R1,R5..i.MO|
00001f40  56 20 52 32 2c 52 37 0d  01 6a 10 53 55 42 20 52  |V R2,R7..j.SUB R|
00001f50  33 2c 52 30 2c 52 35 0d  01 6b 16 53 54 4d 46 44  |3,R0,R5..k.STMFD|
00001f60  20 52 31 33 21 2c 7b 52  31 2d 52 33 7d 0d 01 6c  | R13!,{R1-R3}..l|
00001f70  18 a4 63 61 6c 6c 28 5a  61 70 5f 4d 6f 76 65 42  |..call(Zap_MoveB|
00001f80  79 74 65 73 29 0d 01 6d  10 42 56 53 20 65 72 72  |ytes)..m.BVS err|
00001f90  5f 66 72 65 65 0d 01 6e  16 4c 44 4d 46 44 20 52  |_free..n.LDMFD R|
00001fa0  31 33 21 2c 7b 52 31 2d  52 33 7d 0d 01 6f 04 0d  |13!,{R1-R3}..o..|
00001fb0  01 70 19 4c 44 52 20 52  30 2c 5b 52 39 2c 23 66  |.p.LDR R0,[R9,#f|
00001fc0  5f 73 70 6c 69 74 73 5d  0d 01 71 10 41 44 44 20  |_splits]..q.ADD |
00001fd0  52 31 2c 52 31 2c 52 30  0d 01 72 10 41 44 44 20  |R1,R1,R0..r.ADD |
00001fe0  52 31 2c 52 31 2c 52 33  0d 01 73 10 41 44 44 20  |R1,R1,R3..s.ADD |
00001ff0  52 32 2c 52 32 2c 52 33  0d 01 74 10 53 55 42 20  |R2,R2,R3..t.SUB |
00002000  52 33 2c 52 34 2c 52 33  0d 01 75 18 a4 63 61 6c  |R3,R4,R3..u..cal|
00002010  6c 28 5a 61 70 5f 4d 6f  76 65 42 79 74 65 73 29  |l(Zap_MoveBytes)|
00002020  0d 01 76 10 42 56 53 20  65 72 72 5f 66 72 65 65  |..v.BVS err_free|
00002030  0d 01 77 09 2e 73 72 30  36 0d 01 78 04 0d 01 79  |..w..sr06..x...y|
00002040  2c 5c 20 57 6f 72 64 20  69 73 20 6e 6f 77 20 6f  |,\ Word is now o|
00002050  6e 20 68 65 61 70 2e 20  5a 65 72 6f 2d 74 65 72  |n heap. Zero-ter|
00002060  6d 69 6e 61 74 65 20 69  74 0d 01 7a 0d 4d 4f 56  |minate it..z.MOV|
00002070  20 52 30 2c 23 30 0d 01  7b 13 53 54 52 42 20 52  | R0,#0..{.STRB R|
00002080  30 2c 5b 52 37 2c 52 34  5d 0d 01 7c 04 0d 01 7d  |0,[R7,R4]..|...}|
00002090  2a 5c 20 57 6f 72 6b 20  6f 75 74 20 77 68 61 74  |*\ Work out what|
000020a0  20 74 79 70 65 20 6f 66  20 73 65 61 72 63 68 20  | type of search |
000020b0  77 65 20 77 61 6e 74 0d  01 7e 14 5c 20 20 30 20  |we want..~.\  0 |
000020c0  3d 20 74 6f 20 62 75 66  66 65 72 0d 01 7f 33 5c  |= to buffer...3\|
000020d0  20 2b 31 20 3d 20 66 72  6f 6d 20 68 65 72 65 2c  | +1 = from here,|
000020e0  20 66 6f 72 77 61 72 64  20 20 20 20 20 20 20 20  | forward        |
000020f0  69 65 2c 20 6e 65 78 74  20 6d 61 74 63 68 0d 01  |ie, next match..|
00002100  80 37 5c 20 2d 31 20 3d  20 66 72 6f 6d 20 68 65  |.7\ -1 = from he|
00002110  72 65 2c 20 62 61 63 6b  77 61 72 64 20 20 20 20  |re, backward    |
00002120  20 20 20 69 65 2c 20 70  72 65 76 69 6f 75 73 20  |   ie, previous |
00002130  6d 61 74 63 68 0d 01 81  34 5c 20 2b 32 20 3d 20  |match...4\ +2 = |
00002140  66 72 6f 6d 20 73 74 61  72 74 2c 20 66 6f 72 77  |from start, forw|
00002150  61 72 64 20 20 20 20 20  20 20 69 65 2c 20 66 69  |ard       ie, fi|
00002160  72 73 74 20 6d 61 74 63  68 0d 01 82 33 5c 20 2d  |rst match...3\ -|
00002170  32 20 3d 20 66 72 6f 6d  20 73 74 61 72 74 2c 20  |2 = from start, |
00002180  62 61 63 6b 77 61 72 64  20 20 20 20 20 20 69 65  |backward      ie|
00002190  2c 20 6c 61 73 74 20 6d  61 74 63 68 0d 01 83 17  |, last match....|
000021a0  5c 20 6f 74 68 65 72 73  20 61 72 65 20 65 72 72  |\ others are err|
000021b0  6f 72 73 0d 01 84 04 0d  01 85 18 a4 4c 44 52 28  |ors.........LDR(|
000021c0  52 30 2c 73 65 61 72 63  68 5f 70 61 72 6d 29 0d  |R0,search_parm).|
000021d0  01 86 0d 43 4d 50 20 52  30 2c 23 30 0d 01 87 31  |...CMP R0,#0...1|
000021e0  ec 51 20 52 31 2c 23 31  20 20 20 20 20 20 20 20  |.Q R1,#1        |
000021f0  20 20 20 20 20 20 20 5c  20 54 6f 20 62 75 66 66  |       \ To buff|
00002200  65 72 20 66 6f 72 20 74  79 70 65 20 30 0d 01 88  |er for type 0...|
00002210  40 4d 4f 56 4e 45 20 52  31 2c 23 32 20 20 20 20  |@MOVNE R1,#2    |
00002220  20 20 20 20 20 20 20 20  20 20 20 5c 20 4f 74 68  |           \ Oth|
00002230  65 72 77 69 73 65 2c 20  67 65 74 20 66 69 6c 65  |erwise, get file|
00002240  20 6f 66 66 73 65 74 20  69 6e 20 52 30 0d 01 89  | offset in R0...|
00002250  04 0d 01 8a 39 4d 4f 56  50 4c 20 52 34 2c 23 31  |....9MOVPL R4,#1|
00002260  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 5c  |               \|
00002270  20 46 6f 72 77 61 72 64  73 2c 20 75 6e 6c 65 73  | Forwards, unles|
00002280  73 20 74 79 70 65 20 3c  20 30 0d 01 8b 2e 4d 4f  |s type < 0....MO|
00002290  56 4d 49 20 52 34 2c 23  30 20 20 20 20 20 20 20  |VMI R4,#0       |
000022a0  20 20 20 20 20 20 20 20  5c 20 77 68 65 6e 20 62  |        \ when b|
000022b0  61 63 6b 77 61 72 64 73  0d 01 8c 04 0d 01 8d 45  |ackwards.......E|
000022c0  4d 4f 56 50 4c 20 52 33  2c 52 36 20 20 20 20 20  |MOVPL R3,R6     |
000022d0  20 20 20 20 20 20 20 20  20 20 5c 20 46 6f 72 20  |          \ For |
000022e0  66 6f 72 77 61 72 64 20  73 65 61 72 63 68 2c 20  |forward search, |
000022f0  73 74 61 72 74 20 61 74  20 77 6f 72 64 20 65 6e  |start at word en|
00002300  64 0d 01 8e 48 4d 4f 56  4d 49 20 52 33 2c 52 35  |d...HMOVMI R3,R5|
00002310  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 5c  |               \|
00002320  20 46 6f 72 20 62 61 63  6b 77 61 72 64 20 73 65  | For backward se|
00002330  61 72 63 68 2c 20 73 74  61 72 74 20 61 74 20 77  |arch, start at w|
00002340  6f 72 64 20 73 74 61 72  74 0d 01 8f 04 0d 01 90  |ord start.......|
00002350  42 52 53 42 4d 49 20 52  30 2c 52 30 2c 23 30 20  |BRSBMI R0,R0,#0 |
00002360  20 20 20 20 20 20 20 20  20 20 20 5c 20 47 65 74  |           \ Get|
00002370  20 74 68 65 20 61 62 73  6f 6c 75 74 65 20 76 61  | the absolute va|
00002380  6c 75 65 20 6f 66 20 74  68 65 20 74 79 70 65 0d  |lue of the type.|
00002390  01 91 0d 43 4d 50 20 52  30 2c 23 31 0d 01 92 40  |...CMP R0,#1...@|
000023a0  4d 4f 56 4e 45 20 52 33  2c 23 30 20 20 20 20 20  |MOVNE R3,#0     |
000023b0  20 20 20 20 20 20 20 20  20 20 5c 20 46 72 6f 6d  |          \ From|
000023c0  20 73 74 61 72 74 2c 20  75 6e 6c 65 73 73 20 61  | start, unless a|
000023d0  62 73 28 74 79 70 65 29  20 3d 20 31 0d 01 93 04  |bs(type) = 1....|
000023e0  0d 01 94 13 5c 20 44 6f  20 74 68 65 20 73 65 61  |....\ Do the sea|
000023f0  72 63 68 0d 01 95 0d 4d  4f 56 20 52 30 2c 52 37  |rch....MOV R0,R7|
00002400  0d 01 97 0d 4d 4f 56 20  52 35 2c 23 30 0d 01 98  |....MOV R5,#0...|
00002410  15 a4 63 61 6c 6c 28 5a  61 70 5f 53 65 61 72 63  |..call(Zap_Searc|
00002420  68 29 0d 01 99 10 42 56  53 20 65 72 72 5f 66 72  |h)....BVS err_fr|
00002430  65 65 0d 01 9a 04 0d 01  9b 2c 5c 20 49 66 20 77  |ee.......,\ If w|
00002440  65 20 67 6f 74 20 61 20  74 68 72 6f 77 62 61 63  |e got a throwbac|
00002450  6b 20 62 75 66 66 65 72  2c 20 73 74 6f 70 20 6e  |k buffer, stop n|
00002460  6f 77 0d 01 9c 0d 43 4d  50 20 52 31 2c 23 31 0d  |ow....CMP R1,#1.|
00002470  01 9d 1b 4c 44 4d 45 51  46 44 20 52 31 33 21 2c  |...LDMEQFD R13!,|
00002480  7b 52 31 2d 52 37 2c 50  43 7d 0d 01 9e 04 0d 01  |{R1-R7,PC}......|
00002490  9f 0d 43 4d 50 20 52 30  2c 23 30 0d 01 a0 13 42  |..CMP R0,#0....B|
000024a0  4d 49 20 73 72 5f 6e 6f  74 66 6f 75 6e 64 0d 01  |MI sr_notfound..|
000024b0  a1 04 0d 01 a2 19 a4 63  61 6c 6c 28 5a 61 70 5f  |.......call(Zap_|
000024c0  47 6f 74 6f 4f 66 66 73  65 74 29 0d 01 a3 10 42  |GotoOffset)....B|
000024d0  56 53 20 65 72 72 5f 66  72 65 65 0d 01 a4 04 0d  |VS err_free.....|
000024e0  01 a5 0d 4d 4f 56 20 52  30 2c 52 37 0d 01 a6 13  |...MOV R0,R7....|
000024f0  a4 63 61 6c 6c 28 5a 61  70 5f 46 72 65 65 29 0d  |.call(Zap_Free).|
00002500  01 a7 04 0d 01 a8 19 4c  44 4d 46 44 20 52 31 33  |.......LDMFD R13|
00002510  21 2c 7b 52 31 2d 52 37  2c 50 43 7d 0d 01 a9 04  |!,{R1-R7,PC}....|
00002520  0d 01 aa 0d 2e 65 72 72  5f 66 72 65 65 0d 01 ab  |.....err_free...|
00002530  0d 4d 4f 56 20 52 31 2c  52 30 0d 01 ac 0d 4d 4f  |.MOV R1,R0....MO|
00002540  56 20 52 30 2c 52 37 0d  01 ad 13 a4 63 61 6c 6c  |V R0,R7.....call|
00002550  28 5a 61 70 5f 46 72 65  65 29 0d 01 ae 0d 4d 4f  |(Zap_Free)....MO|
00002560  56 20 52 30 2c 52 31 0d  01 af 1a 4c 44 4d 46 44  |V R0,R1....LDMFD|
00002570  20 52 31 33 21 2c 7b 52  31 2d 52 37 2c 52 31 34  | R13!,{R1-R7,R14|
00002580  7d 0d 01 b0 16 84 52 53  20 50 43 2c 52 31 34 2c  |}.....RS PC,R14,|
00002590  23 56 66 6c 61 67 25 0d  01 b1 04 0d 01 b2 10 2e  |#Vflag%.........|
000025a0  73 72 5f 6e 6f 74 66 6f  75 6e 64 0d 01 b3 0d 4d  |sr_notfound....M|
000025b0  4f 56 20 52 30 2c 52 37  0d 01 b4 13 a4 63 61 6c  |OV R0,R7.....cal|
000025c0  6c 28 5a 61 70 5f 46 72  65 65 29 0d 01 b5 10 41  |l(Zap_Free)....A|
000025d0  44 52 20 52 30 2c 73 72  5f 6e 6f 0d 01 b6 1a 4c  |DR R0,sr_no....L|
000025e0  44 4d 46 44 20 52 31 33  21 2c 7b 52 31 2d 52 37  |DMFD R13!,{R1-R7|
000025f0  2c 52 31 34 7d 0d 01 b7  16 84 52 53 20 50 43 2c  |,R14}.....RS PC,|
00002600  52 31 34 2c 23 56 66 6c  61 67 25 0d 01 b8 04 0d  |R14,#Vflag%.....|
00002610  01 b9 0b 2e 73 72 5f 65  72 72 0d 01 ba 13 41 44  |....sr_err....AD|
00002620  52 20 52 30 2c 73 72 5f  65 72 72 6f 72 0d 01 bb  |R R0,sr_error...|
00002630  1a 4c 44 4d 46 44 20 52  31 33 21 2c 7b 52 31 2d  |.LDMFD R13!,{R1-|
00002640  52 37 2c 52 31 34 7d 0d  01 bc 16 84 52 53 20 50  |R7,R14}.....RS P|
00002650  43 2c 52 31 34 2c 23 56  66 6c 61 67 25 0d 01 bd  |C,R14,#Vflag%...|
00002660  04 0d 01 be 0d 2e 73 72  5f 65 72 72 6f 72 0d 01  |......sr_error..|
00002670  bf 0a 45 51 55 44 20 30  0d 01 c0 17 a4 53 28 22  |..EQUD 0.....S("|
00002680  4e 6f 74 20 69 6e 20 61  20 77 6f 72 64 22 29 0d  |Not in a word").|
00002690  01 c1 04 0d 01 c2 0a 2e  73 72 5f 6e 6f 0d 01 c3  |........sr_no...|
000026a0  0a 45 51 55 44 20 30 0d  01 c4 13 a4 53 28 22 4e  |.EQUD 0.....S("N|
000026b0  6f 74 20 66 6f 75 6e 64  22 29 0d 01 c5 04 0d 01  |ot found")......|
000026c0  c6 44 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |.D\\\\\\\\\\\\\\|
000026d0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00002700  5c 5c 0d 01 c7 44 5c 20  53 75 62 72 6f 75 74 69  |\\...D\ Subrouti|
00002710  6e 65 73 20 20 20 20 20  20 20 20 20 20 20 20 20  |nes             |
00002720  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00002740  20 20 20 20 20 5c 0d 01  c8 44 5c 5c 5c 5c 5c 5c  |     \...D\\\\\\|
00002750  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00002780  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 0d 01 c9 23 5c 20  |\\\\\\\\\\...#\ |
00002790  4d 6f 76 65 20 6f 6e 65  20 77 6f 72 64 20 66 6f  |Move one word fo|
000027a0  72 77 61 72 64 20 69 6e  20 66 69 6c 65 0d 01 ca  |rward in file...|
000027b0  37 5c 20 28 49 6e 29 20  52 30 20 3d 20 66 69 6c  |7\ (In) R0 = fil|
000027c0  65 20 6f 66 66 73 65 74  2c 20 28 4f 75 74 29 20  |e offset, (Out) |
000027d0  52 30 20 3d 20 6e 65 77  20 66 69 6c 65 20 6f 66  |R0 = new file of|
000027e0  66 73 65 74 0d 01 cb 0d  2e 66 77 64 5f 77 6f 72  |fset.....fwd_wor|
000027f0  64 0d 01 cc 1a 53 54 4d  46 44 20 52 31 33 21 2c  |d....STMFD R13!,|
00002800  7b 52 31 2d 52 32 2c 52  31 34 7d 0d 01 cd 16 4c  |{R1-R2,R14}....L|
00002810  44 52 20 52 32 2c 5b 52  39 2c 23 66 5f 6c 65 6e  |DR R2,[R9,#f_len|
00002820  5d 0d 01 ce 04 0d 01 cf  0d 43 4d 50 20 52 30 2c  |]........CMP R0,|
00002830  52 32 0d 01 d0 0f 4d 4f  56 48 53 20 52 30 2c 52  |R2....MOVHS R0,R|
00002840  32 0d 01 d1 0e 42 48 53  20 66 77 5f 65 6f 66 0d  |2....BHS fw_eof.|
00002850  01 d2 04 0d 01 d3 09 2e  66 77 30 31 0d 01 d4 0f  |........fw01....|
00002860  42 4c 20 67 65 74 63 5f  6f 66 66 0d 01 d5 0f 42  |BL getc_off....B|
00002870  4c 20 77 6f 72 64 63 68  61 72 0d 01 d6 0c 42 43  |L wordchar....BC|
00002880  43 20 66 77 30 32 0d 01  d7 10 41 44 44 20 52 30  |C fw02....ADD R0|
00002890  2c 52 30 2c 23 31 0d 01  d8 0d 43 4d 50 20 52 30  |,R0,#1....CMP R0|
000028a0  2c 52 32 0d 01 d9 0e 42  48 53 20 66 77 5f 65 6f  |,R2....BHS fw_eo|
000028b0  66 0d 01 da 0a 42 20 66  77 30 31 0d 01 db 04 0d  |f....B fw01.....|
000028c0  01 dc 09 2e 66 77 30 32  0d 01 dd 10 41 44 44 20  |....fw02....ADD |
000028d0  52 30 2c 52 30 2c 23 31  0d 01 de 0d 43 4d 50 20  |R0,R0,#1....CMP |
000028e0  52 30 2c 52 32 0d 01 df  0e 42 48 53 20 66 77 5f  |R0,R2....BHS fw_|
000028f0  65 6f 66 0d 01 e0 0f 42  4c 20 67 65 74 63 5f 6f  |eof....BL getc_o|
00002900  66 66 0d 01 e1 0f 42 4c  20 77 6f 72 64 63 68 61  |ff....BL wordcha|
00002910  72 0d 01 e2 0c 42 43 43  20 66 77 30 32 0d 01 e3  |r....BCC fw02...|
00002920  04 0d 01 e4 0b 2e 66 77  5f 65 6f 66 0d 01 e5 1a  |......fw_eof....|
00002930  4c 44 4d 46 44 20 52 31  33 21 2c 7b 52 31 2d 52  |LDMFD R13!,{R1-R|
00002940  32 2c 50 43 7d 5e 0d 01  e6 04 0d 01 e7 24 5c 20  |2,PC}^.......$\ |
00002950  4d 6f 76 65 20 6f 6e 65  20 77 6f 72 64 20 62 61  |Move one word ba|
00002960  63 6b 77 61 72 64 20 69  6e 20 66 69 6c 65 0d 01  |ckward in file..|
00002970  e8 37 5c 20 28 49 6e 29  20 52 30 20 3d 20 66 69  |.7\ (In) R0 = fi|
00002980  6c 65 20 6f 66 66 73 65  74 2c 20 28 4f 75 74 29  |le offset, (Out)|
00002990  20 52 30 20 3d 20 6e 65  77 20 66 69 6c 65 20 6f  | R0 = new file o|
000029a0  66 66 73 65 74 0d 01 e9  0e 2e 62 61 63 6b 5f 77  |ffset.....back_w|
000029b0  6f 72 64 0d 01 ea 17 53  54 4d 46 44 20 52 31 33  |ord....STMFD R13|
000029c0  21 2c 7b 52 31 2c 52 31  34 7d 0d 01 eb 04 0d 01  |!,{R1,R14}......|
000029d0  ec 09 2e 62 77 30 31 0d  01 ed 11 53 55 42 53 20  |...bw01....SUBS |
000029e0  52 30 2c 52 30 2c 23 31  0d 01 ee 0e 42 4d 49 20  |R0,R0,#1....BMI |
000029f0  62 77 5f 65 6f 66 0d 01  ef 04 0d 01 f0 0f 42 4c  |bw_eof........BL|
00002a00  20 67 65 74 63 5f 6f 66  66 0d 01 f1 0f 42 4c 20  | getc_off....BL |
00002a10  77 6f 72 64 63 68 61 72  0d 01 f2 0c 42 43 43 20  |wordchar....BCC |
00002a20  62 77 30 31 0d 01 f3 04  0d 01 f4 09 2e 62 77 30  |bw01.........bw0|
00002a30  32 0d 01 f5 11 53 55 42  53 20 52 30 2c 52 30 2c  |2....SUBS R0,R0,|
00002a40  23 31 0d 01 f6 0e 42 4d  49 20 62 77 5f 65 6f 66  |#1....BMI bw_eof|
00002a50  0d 01 f7 0f 42 4c 20 67  65 74 63 5f 6f 66 66 0d  |....BL getc_off.|
00002a60  01 f8 0f 42 4c 20 77 6f  72 64 63 68 61 72 0d 01  |...BL wordchar..|
00002a70  f9 0c 42 43 53 20 62 77  30 32 0d 01 fa 04 0d 01  |..BCS bw02......|
00002a80  fb 0b 2e 62 77 5f 65 6f  66 0d 01 fc 10 41 44 44  |...bw_eof....ADD|
00002a90  20 52 30 2c 52 30 2c 23  31 0d 01 fd 17 4c 44 4d  | R0,R0,#1....LDM|
00002aa0  46 44 20 52 31 33 21 2c  7b 52 31 2c 50 43 7d 5e  |FD R13!,{R1,PC}^|
00002ab0  0d 01 fe 04 0d 01 ff 28  5c 20 47 65 74 20 61 20  |.......(\ Get a |
00002ac0  63 68 61 72 61 63 74 65  72 20 66 72 6f 6d 20 61  |character from a|
00002ad0  20 66 69 6c 65 20 62 75  66 66 65 72 0d 02 00 27  | file buffer...'|
00002ae0  5c 20 28 49 6e 29 20 52  30 3d 66 69 6c 65 20 6f  |\ (In) R0=file o|
00002af0  66 66 73 65 74 20 28 4f  75 74 29 20 52 31 3d 63  |ffset (Out) R1=c|
00002b00  68 61 72 0d 02 01 0d 2e  67 65 74 63 5f 6f 66 66  |har.....getc_off|
00002b10  0d 02 02 17 53 54 4d 46  44 20 52 31 33 21 2c 7b  |....STMFD R13!,{|
00002b20  52 30 2c 52 31 34 7d 0d  02 03 04 0d 02 04 19 4c  |R0,R14}........L|
00002b30  44 52 20 52 31 2c 5b 52  39 2c 23 66 5f 73 70 6c  |DR R1,[R9,#f_spl|
00002b40  69 74 6f 5d 0d 02 05 0d  43 4d 50 20 52 30 2c 52  |ito]....CMP R0,R|
00002b50  31 0d 02 06 1b 4c 44 52  43 53 20 52 31 2c 5b 52  |1....LDRCS R1,[R|
00002b60  39 2c 23 66 5f 73 70 6c  69 74 73 5d 0d 02 07 12  |9,#f_splits]....|
00002b70  41 44 44 43 53 20 52 30  2c 52 30 2c 52 31 0d 02  |ADDCS R0,R0,R1..|
00002b80  08 16 4c 44 52 20 52 31  2c 5b 52 39 2c 23 66 5f  |..LDR R1,[R9,#f_|
00002b90  70 74 72 5d 0d 02 09 13  4c 44 52 42 20 52 31 2c  |ptr]....LDRB R1,|
00002ba0  5b 52 31 2c 52 30 5d 0d  02 0a 04 0d 02 0b 17 4c  |[R1,R0]........L|
00002bb0  44 4d 46 44 20 52 31 33  21 2c 7b 52 30 2c 50 43  |DMFD R13!,{R0,PC|
00002bc0  7d 5e 0d 02 0c 04 0d 02  0d 35 5c 20 43 68 65 63  |}^.......5\ Chec|
00002bd0  6b 20 77 68 65 74 68 65  72 20 61 20 63 68 61 72  |k whether a char|
00002be0  61 63 74 65 72 20 69 73  20 61 20 77 6f 72 64 20  |acter is a word |
00002bf0  63 6f 6e 73 74 69 74 75  65 6e 74 0d 02 0e 2c 5c  |constituent...,\|
00002c00  20 28 49 6e 29 20 52 31  3d 63 68 61 72 20 28 4f  | (In) R1=char (O|
00002c10  75 74 29 20 43 53 3d 57  6f 72 64 2c 20 43 43 3d  |ut) CS=Word, CC=|
00002c20  4e 6f 6e 57 6f 72 64 0d  02 0f 0d 2e 77 6f 72 64  |NonWord.....word|
00002c30  63 68 61 72 0d 02 10 1a  53 54 4d 46 44 20 52 31  |char....STMFD R1|
00002c40  33 21 2c 7b 52 30 2d 52  32 2c 52 31 34 7d 0d 02  |3!,{R0-R2,R14}..|
00002c50  11 12 41 44 52 20 52 30  2c 77 6f 72 64 74 61 62  |..ADR R0,wordtab|
00002c60  0d 02 12 14 4d 4f 56 20  52 32 2c 52 31 2c 4c 53  |....MOV R2,R1,LS|
00002c70  52 20 23 35 0d 02 13 19  4c 44 52 20 52 30 2c 5b  |R #5....LDR R0,[|
00002c80  52 30 2c 52 32 2c 41 53  4c 20 23 32 5d 0d 02 14  |R0,R2,ASL #2]...|
00002c90  10 80 20 52 31 2c 52 31  2c 23 26 31 46 0d 02 15  |.. R1,R1,#&1F...|
00002ca0  10 41 44 44 20 52 31 2c  52 31 2c 23 31 0d 02 16  |.ADD R1,R1,#1...|
00002cb0  15 4d 4f 56 53 20 52 30  2c 52 30 2c 4c 53 52 20  |.MOVS R0,R0,LSR |
00002cc0  52 31 0d 02 17 19 4c 44  4d 46 44 20 52 31 33 21  |R1....LDMFD R13!|
00002cd0  2c 7b 52 30 2d 52 32 2c  50 43 7d 0d 02 18 04 0d  |,{R0-R2,PC}.....|
00002ce0  02 19 25 5c 20 57 6f 72  64 20 63 68 61 72 61 63  |..%\ Word charac|
00002cf0  74 65 72 73 20 28 41 2d  5a 2c 61 2d 7a 2c 30 2d  |ters (A-Z,a-z,0-|
00002d00  39 2c 5f 29 0d 02 1a 0c  2e 77 6f 72 64 74 61 62  |9,_).....wordtab|
00002d10  0d 02 1b 23 45 51 55 44  20 26 30 30 30 30 30 30  |...#EQUD &000000|
00002d20  30 30 20 20 20 20 20 20  20 20 5c 20 26 30 30 2d  |00        \ &00-|
00002d30  26 31 46 0d 02 1c 29 45  51 55 44 20 26 30 33 46  |&1F...)EQUD &03F|
00002d40  46 30 30 30 30 20 20 20  20 20 20 20 20 5c 20 26  |F0000        \ &|
00002d50  32 30 2d 26 33 46 20 28  30 2d 39 29 0d 02 1d 2f  |20-&3F (0-9).../|
00002d60  45 51 55 44 20 26 38 37  46 46 46 46 46 45 20 20  |EQUD &87FFFFFE  |
00002d70  20 20 20 20 20 20 5c 20  26 34 30 2d 26 35 46 20  |      \ &40-&5F |
00002d80  28 41 2d 5a 20 61 6e 64  20 5f 29 0d 02 1e 29 45  |(A-Z and _)...)E|
00002d90  51 55 44 20 26 30 37 46  46 46 46 46 45 20 20 20  |QUD &07FFFFFE   |
00002da0  20 20 20 20 20 5c 20 26  36 30 2d 26 37 46 20 28  |     \ &60-&7F (|
00002db0  61 2d 7a 29 0d 02 1f 23  45 51 55 44 20 26 30 30  |a-z)...#EQUD &00|
00002dc0  30 30 30 30 30 30 20 20  20 20 20 20 20 20 5c 20  |000000        \ |
00002dd0  26 38 30 2d 26 39 46 0d  02 20 23 45 51 55 44 20  |&80-&9F.. #EQUD |
00002de0  26 30 30 30 30 30 30 30  30 20 20 20 20 20 20 20  |&00000000       |
00002df0  20 5c 20 26 41 30 2d 26  42 46 0d 02 21 23 45 51  | \ &A0-&BF..!#EQ|
00002e00  55 44 20 26 30 30 30 30  30 30 30 30 20 20 20 20  |UD &00000000    |
00002e10  20 20 20 20 5c 20 26 43  30 2d 26 44 46 0d 02 22  |    \ &C0-&DF.."|
00002e20  23 45 51 55 44 20 26 30  30 30 30 30 30 30 30 20  |#EQUD &00000000 |
00002e30  20 20 20 20 20 20 20 5c  20 26 45 30 2d 26 46 46  |       \ &E0-&FF|
00002e40  0d 02 23 04 0d 02 24 44  5c 5c 5c 5c 5c 5c 5c 5c  |..#...$D\\\\\\\\|
00002e50  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00002e80  5c 5c 5c 5c 5c 5c 5c 5c  0d 02 25 44 5c 20 57 69  |\\\\\\\\..%D\ Wi|
00002e90  6e 64 6f 77 20 4d 6f 76  65 6d 65 6e 74 20 43 6f  |ndow Movement Co|
00002ea0  6d 6d 61 6e 64 73 20 20  20 20 20 20 20 20 20 20  |mmands          |
00002eb0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00002ec0  20 20 20 20 20 20 20 20  20 20 20 5c 0d 02 26 44  |           \..&D|
00002ed0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00002f10  0d 02 27 17 45 51 55 44  20 28 32 3c 3c 33 29 2b  |..'.EQUD (2<<3)+|
00002f20  28 31 3c 3c 31 32 29 0d  02 28 04 0d 02 29 0c 2e  |(1<<12)..(...)..|
00002f30  77 69 6e 6c 65 66 74 0d  02 2a 14 53 54 4d 46 44  |winleft..*.STMFD|
00002f40  20 52 31 33 21 2c 7b 52  31 34 7d 0d 02 2b 04 0d  | R13!,{R14}..+..|
00002f50  02 2c 0d 42 4c 20 67 65  74 61 72 67 0d 02 2d 04  |.,.BL getarg..-.|
00002f60  0d 02 2e 17 4c 44 52 20  52 30 2c 5b 52 38 2c 23  |....LDR R0,[R8,#|
00002f70  77 5f 6d 69 6e 78 5d 0d  02 2f 10 53 55 42 20 52  |w_minx]../.SUB R|
00002f80  30 2c 52 30 2c 52 32 0d  02 30 17 53 54 52 20 52  |0,R0,R2..0.STR R|
00002f90  30 2c 5b 52 38 2c 23 77  5f 6d 69 6e 78 5d 0d 02  |0,[R8,#w_minx]..|
00002fa0  31 04 0d 02 32 17 4c 44  52 20 52 30 2c 5b 52 38  |1...2.LDR R0,[R8|
00002fb0  2c 23 77 5f 6d 61 78 78  5d 0d 02 33 10 53 55 42  |,#w_maxx]..3.SUB|
00002fc0  20 52 30 2c 52 30 2c 52  32 0d 02 34 17 53 54 52  | R0,R0,R2..4.STR|
00002fd0  20 52 30 2c 5b 52 38 2c  23 77 5f 6d 61 78 78 5d  | R0,[R8,#w_maxx]|
00002fe0  0d 02 35 04 0d 02 36 0d  4d 4f 56 20 52 30 2c 23  |..5...6.MOV R0,#|
00002ff0  31 0d 02 37 0d 4d 4f 56  20 52 31 2c 52 38 0d 02  |1..7.MOV R1,R8..|
00003000  38 19 a4 63 61 6c 6c 28  5a 61 70 5f 4f 70 65 6e  |8..call(Zap_Open|
00003010  57 69 6e 64 6f 77 29 0d  02 39 04 0d 02 3a 13 4c  |Window)..9...:.L|
00003020  44 4d 46 44 20 52 31 33  21 2c 7b 50 43 7d 0d 02  |DMFD R13!,{PC}..|
00003030  3b 04 0d 02 3c 44 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |;...<D\\\\\\\\\\|
00003040  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00003070  5c 5c 5c 5c 5c 5c 0d 02  3d 17 45 51 55 44 20 28  |\\\\\\..=.EQUD (|
00003080  32 3c 3c 33 29 2b 28 31  3c 3c 31 32 29 0d 02 3e  |2<<3)+(1<<12)..>|
00003090  04 0d 02 3f 0d 2e 77 69  6e 72 69 67 68 74 0d 02  |...?..winright..|
000030a0  40 14 53 54 4d 46 44 20  52 31 33 21 2c 7b 52 31  |@.STMFD R13!,{R1|
000030b0  34 7d 0d 02 41 04 0d 02  42 0d 42 4c 20 67 65 74  |4}..A...B.BL get|
000030c0  61 72 67 0d 02 43 04 0d  02 44 17 4c 44 52 20 52  |arg..C...D.LDR R|
000030d0  30 2c 5b 52 38 2c 23 77  5f 6d 69 6e 78 5d 0d 02  |0,[R8,#w_minx]..|
000030e0  45 10 41 44 44 20 52 30  2c 52 30 2c 52 32 0d 02  |E.ADD R0,R0,R2..|
000030f0  46 17 53 54 52 20 52 30  2c 5b 52 38 2c 23 77 5f  |F.STR R0,[R8,#w_|
00003100  6d 69 6e 78 5d 0d 02 47  04 0d 02 48 17 4c 44 52  |minx]..G...H.LDR|
00003110  20 52 30 2c 5b 52 38 2c  23 77 5f 6d 61 78 78 5d  | R0,[R8,#w_maxx]|
00003120  0d 02 49 10 41 44 44 20  52 30 2c 52 30 2c 52 32  |..I.ADD R0,R0,R2|
00003130  0d 02 4a 17 53 54 52 20  52 30 2c 5b 52 38 2c 23  |..J.STR R0,[R8,#|
00003140  77 5f 6d 61 78 78 5d 0d  02 4b 04 0d 02 4c 0d 4d  |w_maxx]..K...L.M|
00003150  4f 56 20 52 30 2c 23 31  0d 02 4d 0d 4d 4f 56 20  |OV R0,#1..M.MOV |
00003160  52 31 2c 52 38 0d 02 4e  19 a4 63 61 6c 6c 28 5a  |R1,R8..N..call(Z|
00003170  61 70 5f 4f 70 65 6e 57  69 6e 64 6f 77 29 0d 02  |ap_OpenWindow)..|
00003180  4f 04 0d 02 50 13 4c 44  4d 46 44 20 52 31 33 21  |O...P.LDMFD R13!|
00003190  2c 7b 50 43 7d 0d 02 51  04 0d 02 52 44 5c 5c 5c  |,{PC}..Q...RD\\\|
000031a0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000031d0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 0d 02 53  |\\\\\\\\\\\\\..S|
000031e0  17 45 51 55 44 20 28 32  3c 3c 33 29 2b 28 31 3c  |.EQUD (2<<3)+(1<|
000031f0  3c 31 32 29 0d 02 54 04  0d 02 55 0a 2e 77 69 6e  |<12)..T...U..win|
00003200  75 70 0d 02 56 14 53 54  4d 46 44 20 52 31 33 21  |up..V.STMFD R13!|
00003210  2c 7b 52 31 34 7d 0d 02  57 04 0d 02 58 0d 42 4c  |,{R14}..W...X.BL|
00003220  20 67 65 74 61 72 67 0d  02 59 04 0d 02 5a 17 4c  | getarg..Y...Z.L|
00003230  44 52 20 52 30 2c 5b 52  38 2c 23 77 5f 6d 69 6e  |DR R0,[R8,#w_min|
00003240  79 5d 0d 02 5b 10 41 44  44 20 52 30 2c 52 30 2c  |y]..[.ADD R0,R0,|
00003250  52 32 0d 02 5c 17 53 54  52 20 52 30 2c 5b 52 38  |R2..\.STR R0,[R8|
00003260  2c 23 77 5f 6d 69 6e 79  5d 0d 02 5d 04 0d 02 5e  |,#w_miny]..]...^|
00003270  17 4c 44 52 20 52 30 2c  5b 52 38 2c 23 77 5f 6d  |.LDR R0,[R8,#w_m|
00003280  61 78 79 5d 0d 02 5f 10  41 44 44 20 52 30 2c 52  |axy].._.ADD R0,R|
00003290  30 2c 52 32 0d 02 60 17  53 54 52 20 52 30 2c 5b  |0,R2..`.STR R0,[|
000032a0  52 38 2c 23 77 5f 6d 61  78 79 5d 0d 02 61 04 0d  |R8,#w_maxy]..a..|
000032b0  02 62 0d 4d 4f 56 20 52  30 2c 23 31 0d 02 63 0d  |.b.MOV R0,#1..c.|
000032c0  4d 4f 56 20 52 31 2c 52  38 0d 02 64 19 a4 63 61  |MOV R1,R8..d..ca|
000032d0  6c 6c 28 5a 61 70 5f 4f  70 65 6e 57 69 6e 64 6f  |ll(Zap_OpenWindo|
000032e0  77 29 0d 02 65 04 0d 02  66 13 4c 44 4d 46 44 20  |w)..e...f.LDMFD |
000032f0  52 31 33 21 2c 7b 50 43  7d 0d 02 67 04 0d 02 68  |R13!,{PC}..g...h|
00003300  44 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |D\\\\\\\\\\\\\\\|
00003310  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00003340  5c 0d 02 69 17 45 51 55  44 20 28 32 3c 3c 33 29  |\..i.EQUD (2<<3)|
00003350  2b 28 31 3c 3c 31 32 29  0d 02 6a 04 0d 02 6b 0c  |+(1<<12)..j...k.|
00003360  2e 77 69 6e 64 6f 77 6e  0d 02 6c 14 53 54 4d 46  |.windown..l.STMF|
00003370  44 20 52 31 33 21 2c 7b  52 31 34 7d 0d 02 6d 04  |D R13!,{R14}..m.|
00003380  0d 02 6e 0d 42 4c 20 67  65 74 61 72 67 0d 02 6f  |..n.BL getarg..o|
00003390  04 0d 02 70 17 4c 44 52  20 52 30 2c 5b 52 38 2c  |...p.LDR R0,[R8,|
000033a0  23 77 5f 6d 69 6e 79 5d  0d 02 71 10 53 55 42 20  |#w_miny]..q.SUB |
000033b0  52 30 2c 52 30 2c 52 32  0d 02 72 17 53 54 52 20  |R0,R0,R2..r.STR |
000033c0  52 30 2c 5b 52 38 2c 23  77 5f 6d 69 6e 79 5d 0d  |R0,[R8,#w_miny].|
000033d0  02 73 04 0d 02 74 17 4c  44 52 20 52 30 2c 5b 52  |.s...t.LDR R0,[R|
000033e0  38 2c 23 77 5f 6d 61 78  79 5d 0d 02 75 10 53 55  |8,#w_maxy]..u.SU|
000033f0  42 20 52 30 2c 52 30 2c  52 32 0d 02 76 17 53 54  |B R0,R0,R2..v.ST|
00003400  52 20 52 30 2c 5b 52 38  2c 23 77 5f 6d 61 78 79  |R R0,[R8,#w_maxy|
00003410  5d 0d 02 77 04 0d 02 78  0d 4d 4f 56 20 52 30 2c  |]..w...x.MOV R0,|
00003420  23 31 0d 02 79 0d 4d 4f  56 20 52 31 2c 52 38 0d  |#1..y.MOV R1,R8.|
00003430  02 7a 19 a4 63 61 6c 6c  28 5a 61 70 5f 4f 70 65  |.z..call(Zap_Ope|
00003440  6e 57 69 6e 64 6f 77 29  0d 02 7b 04 0d 02 7c 13  |nWindow)..{...|.|
00003450  4c 44 4d 46 44 20 52 31  33 21 2c 7b 50 43 7d 0d  |LDMFD R13!,{PC}.|
00003460  02 7d 04 0d 02 7e 44 5c  5c 5c 5c 5c 5c 5c 5c 5c  |.}...~D\\\\\\\\\|
00003470  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000034a0  5c 5c 5c 5c 5c 5c 5c 0d  02 7f 2f 5c 20 28 49 6e  |\\\\\\\.../\ (In|
000034b0  29 20 20 52 30 3d 6c 69  73 74 20 6f 66 20 77 6f  |)  R0=list of wo|
000034c0  72 64 73 2c 20 52 31 3d  6e 75 6d 62 65 72 20 69  |rds, R1=number i|
000034d0  6e 20 6c 69 73 74 0d 02  80 2e 5c 20 28 4f 75 74  |n list....\ (Out|
000034e0  29 20 52 32 3d 73 75 6d  20 6f 66 20 6c 69 73 74  |) R2=sum of list|
000034f0  2c 20 52 30 2c 52 31 2c  52 33 20 63 6f 72 72 75  |, R0,R1,R3 corru|
00003500  70 74 65 64 0d 02 81 44  5c 5c 5c 5c 5c 5c 5c 5c  |pted...D\\\\\\\\|
00003510  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00003540  5c 5c 5c 5c 5c 5c 5c 5c  0d 02 82 0b 2e 67 65 74  |\\\\\\\\.....get|
00003550  61 72 67 0d 02 83 04 0d  02 84 0d 4d 4f 56 20 52  |arg........MOV R|
00003560  32 2c 23 30 0d 02 85 08  2e 4c 30 31 0d 02 86 11  |2,#0.....L01....|
00003570  53 55 42 53 20 52 31 2c  52 31 2c 23 31 0d 02 87  |SUBS R1,R1,#1...|
00003580  14 4c 44 52 50 4c 20 52  33 2c 5b 52 30 5d 2c 23  |.LDRPL R3,[R0],#|
00003590  34 0d 02 88 12 41 44 44  50 4c 20 52 32 2c 52 32  |4....ADDPL R2,R2|
000035a0  2c 52 33 0d 02 89 0b 42  50 4c 20 4c 30 31 0d 02  |,R3....BPL L01..|
000035b0  8a 0f 4d 4f 56 53 20 50  43 2c 52 31 34 0d 02 8b  |..MOVS PC,R14...|
000035c0  04 0d 02 8c 44 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |....D\\\\\\\\\\\|
000035d0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00003600  5c 5c 5c 5c 5c 0d 02 8d  44 5c 20 46 69 6c 74 65  |\\\\\...D\ Filte|
00003610  72 20 53 65 6c 65 63 74  69 6f 6e 20 43 6f 6d 6d  |r Selection Comm|
00003620  61 6e 64 20 20 20 20 20  20 20 20 20 20 20 20 20  |and             |
00003630  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003640  20 20 20 20 20 20 20 20  5c 0d 02 8e 44 5c 5c 5c  |        \...D\\\|
00003650  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00003680  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 0d 02 8f  |\\\\\\\\\\\\\...|
00003690  18 45 51 55 44 20 31 2b  28 33 3c 3c 33 29 2b 28  |.EQUD 1+(3<<3)+(|
000036a0  31 3c 3c 36 29 0d 02 90  04 0d 02 91 44 5c 5c 5c  |1<<6).......D\\\|
000036b0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000036e0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 0d 02 92  |\\\\\\\\\\\\\...|
000036f0  2d 5c 20 28 55 73 65 73  29 20 52 37 3d 63 6f 6d  |-\ (Uses) R7=com|
00003700  6d 61 6e 64 20 73 74 72  69 6e 67 2c 20 52 36 3d  |mand string, R6=|
00003710  68 65 61 70 20 62 6c 6f  63 6b 0d 02 93 44 5c 5c  |heap block...D\\|
00003720  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00003750  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 0d 02  |\\\\\\\\\\\\\\..|
00003760  94 0e 2e 66 69 6c 74 65  72 73 65 6c 0d 02 95 08  |...filtersel....|
00003770  a4 4a 53 52 0d 02 96 04  0d 02 97 2e 5c 5c 20 41  |.JSR........\\ A|
00003780  72 65 20 77 65 20 62 65  69 6e 67 20 61 73 6b 65  |re we being aske|
00003790  64 20 66 6f 72 20 61 20  70 72 6f 6d 70 74 20 73  |d for a prompt s|
000037a0  74 72 69 6e 67 3f 0d 02  98 0d 54 45 51 20 52 32  |tring?....TEQ R2|
000037b0  2c 23 36 0d 02 99 12 42  45 51 20 61 64 64 5f 70  |,#6....BEQ add_p|
000037c0  72 6f 6d 70 74 0d 02 9a  04 0d 02 9b 31 5c 5c 20  |rompt.......1\\ |
000037d0  52 65 6d 65 6d 62 65 72  20 74 68 65 20 6d 69 6e  |Remember the min|
000037e0  69 62 75 66 66 65 72 20  63 6f 6e 74 65 6e 74 73  |ibuffer contents|
000037f0  20 66 6f 72 20 6c 61 74  65 72 0d 02 9c 0d 4d 4f  | for later....MO|
00003800  56 20 52 37 2c 52 30 0d  02 9d 04 0d 02 9e 2c 5c  |V R7,R0.......,\|
00003810  5c 20 47 65 74 20 74 68  65 20 73 65 6c 65 63 74  |\ Get the select|
00003820  65 64 20 61 72 65 61 20  74 6f 20 61 20 68 65 61  |ed area to a hea|
00003830  70 20 62 6c 6f 63 6b 0d  02 9f 39 a4 63 61 6c 6c  |p block...9.call|
00003840  28 5a 61 70 5f 52 65 61  64 53 65 6c 29 20 20 20  |(Zap_ReadSel)   |
00003850  20 20 20 20 20 20 20 20  5c 20 28 4f 75 74 29 20  |        \ (Out) |
00003860  52 32 3d 6c 65 6e 2c 20  52 33 3d 62 6c 6f 63 6b  |R2=len, R3=block|
00003870  0d 02 a0 11 42 56 53 20  65 72 72 6f 72 5f 72 65  |....BVS error_re|
00003880  74 0d 02 a1 0d 54 45 51  20 52 33 2c 23 30 0d 02  |t....TEQ R3,#0..|
00003890  a2 3c 42 45 51 20 65 72  72 6f 72 5f 6e 6f 73 65  |.<BEQ error_nose|
000038a0  6c 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |l               |
000038b0  5c 20 45 72 72 6f 72 20  69 66 20 74 68 65 72 65  |\ Error if there|
000038c0  20 69 73 6e 27 74 20 6f  6e 65 0d 02 a3 04 0d 02  | isn't one......|
000038d0  a4 31 5c 5c 20 53 61 76  65 20 74 68 65 20 73 65  |.1\\ Save the se|
000038e0  6c 65 63 74 65 64 20 61  72 65 61 20 74 6f 20 61  |lected area to a|
000038f0  20 74 65 6d 70 6f 72 61  72 79 20 66 69 6c 65 0d  | temporary file.|
00003900  02 a5 12 41 44 52 20 52  31 2c 66 69 6c 65 5f 69  |...ADR R1,file_i|
00003910  6e 0d 02 a6 46 42 4c 20  73 61 76 65 20 20 20 20  |n...FBL save    |
00003920  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003930  20 20 20 5c 20 28 49 6e  29 20 52 31 3d 66 69 6c  |   \ (In) R1=fil|
00003940  65 6e 61 6d 65 2c 20 52  32 3d 6c 65 6e 2c 20 52  |ename, R2=len, R|
00003950  33 3d 62 6c 6f 63 6b 0d  02 a7 11 42 56 53 20 65  |3=block....BVS e|
00003960  72 72 6f 72 5f 72 65 74  0d 02 a8 04 0d 02 a9 1a  |rror_ret........|
00003970  5c 5c 20 46 72 65 65 20  74 68 65 20 68 65 61 70  |\\ Free the heap|
00003980  20 62 6c 6f 63 6b 0d 02  aa 0d 4d 4f 56 20 52 30  | block....MOV R0|
00003990  2c 52 33 0d 02 ab 30 a4  63 61 6c 6c 28 5a 61 70  |,R3...0.call(Zap|
000039a0  5f 46 72 65 65 29 20 20  20 20 20 20 20 20 20 20  |_Free)          |
000039b0  20 20 20 20 5c 20 28 49  6e 29 20 52 30 3d 62 6c  |    \ (In) R0=bl|
000039c0  6f 63 6b 0d 02 ac 11 42  56 53 20 65 72 72 6f 72  |ock....BVS error|
000039d0  5f 72 65 74 0d 02 ad 04  0d 02 ae 16 5c 5c 20 46  |_ret........\\ F|
000039e0  69 6c 74 65 72 20 74 68  65 20 66 69 6c 65 0d 02  |ilter the file..|
000039f0  af 0d 4d 4f 56 20 52 30  2c 52 37 0d 02 b0 12 41  |..MOV R0,R7....A|
00003a00  44 52 20 52 31 2c 66 69  6c 65 5f 69 6e 0d 02 b1  |DR R1,file_in...|
00003a10  13 41 44 52 20 52 32 2c  66 69 6c 65 5f 6f 75 74  |.ADR R2,file_out|
00003a20  0d 02 b2 48 42 4c 20 66  69 6c 74 65 72 5f 66 69  |...HBL filter_fi|
00003a30  6c 65 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |le              |
00003a40  20 20 5c 20 28 49 6e 29  20 52 30 3d 63 6f 6d 6d  |  \ (In) R0=comm|
00003a50  61 6e 64 2c 20 52 31 3d  69 6e 70 75 74 2c 20 52  |and, R1=input, R|
00003a60  32 3d 6f 75 74 70 75 74  0d 02 b3 11 42 56 53 20  |2=output....BVS |
00003a70  65 72 72 6f 72 5f 72 65  74 0d 02 b4 04 0d 02 b5  |error_ret.......|
00003a80  2e 5c 5c 20 46 69 6e 64  20 74 68 65 20 6c 65 6e  |.\\ Find the len|
00003a90  67 74 68 20 6f 66 20 74  68 65 20 72 65 70 6c 61  |gth of the repla|
00003aa0  63 65 6d 65 6e 74 20 66  69 6c 65 0d 02 b6 13 41  |cement file....A|
00003ab0  44 52 20 52 31 2c 66 69  6c 65 5f 6f 75 74 0d 02  |DR R1,file_out..|
00003ac0  b7 3d 42 4c 20 67 65 74  5f 6c 65 6e 20 20 20 20  |.=BL get_len    |
00003ad0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003ae0  5c 20 28 49 6e 29 20 52  31 3d 66 69 6c 65 20 28  |\ (In) R1=file (|
00003af0  4f 75 74 29 20 52 30 3d  6c 65 6e 0d 02 b8 11 42  |Out) R0=len....B|
00003b00  56 53 20 65 72 72 6f 72  5f 72 65 74 0d 02 b9 41  |VS error_ret...A|
00003b10  4d 4f 56 20 52 34 2c 52  30 20 20 20 20 20 20 20  |MOV R4,R0       |
00003b20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 5c 20  |              \ |
00003b30  53 61 76 65 20 66 69 6c  65 73 69 7a 65 20 69 6e  |Save filesize in|
00003b40  20 52 34 20 66 6f 72 20  6c 61 74 65 72 0d 02 ba  | R4 for later...|
00003b50  04 0d 02 bb 2c 5c 5c 20  47 65 74 20 74 68 65 20  |....,\\ Get the |
00003b60  6e 65 63 65 73 73 61 72  79 20 73 70 61 63 65 20  |necessary space |
00003b70  6f 6e 20 5a 61 70 27 73  20 68 65 61 70 0d 02 bc  |on Zap's heap...|
00003b80  3e a4 63 61 6c 6c 28 5a  61 70 5f 43 6c 61 69 6d  |>.call(Zap_Claim|
00003b90  29 20 20 20 20 20 20 20  20 20 20 20 20 20 5c 20  |)             \ |
00003ba0  28 49 6e 29 20 52 30 3d  73 69 7a 65 20 28 4f 75  |(In) R0=size (Ou|
00003bb0  74 29 20 52 30 3d 62 6c  6f 63 6b 0d 02 bd 11 42  |t) R0=block....B|
00003bc0  56 53 20 65 72 72 6f 72  5f 72 65 74 0d 02 be 43  |VS error_ret...C|
00003bd0  4d 4f 56 20 52 33 2c 52  30 20 20 20 20 20 20 20  |MOV R3,R0       |
00003be0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 5c 20  |              \ |
00003bf0  53 61 76 65 20 62 6c 6f  63 6b 20 61 64 64 72 20  |Save block addr |
00003c00  69 6e 20 52 33 20 66 6f  72 20 6c 61 74 65 72 0d  |in R3 for later.|
00003c10  02 bf 04 0d 02 c0 20 5c  5c 20 4c 6f 61 64 20 74  |...... \\ Load t|
00003c20  68 65 20 72 65 70 6c 61  63 65 6d 65 6e 74 20 66  |he replacement f|
00003c30  69 6c 65 0d 02 c1 13 41  44 52 20 52 31 2c 66 69  |ile....ADR R1,fi|
00003c40  6c 65 5f 6f 75 74 0d 02  c2 3a 42 4c 20 6c 6f 61  |le_out...:BL loa|
00003c50  64 5f 66 69 6c 65 20 20  20 20 20 20 20 20 20 20  |d_file          |
00003c60  20 20 20 20 20 20 20 20  5c 20 28 49 6e 29 20 52  |        \ (In) R|
00003c70  30 3d 62 6c 6f 63 6b 2c  20 52 31 3d 66 69 6c 65  |0=block, R1=file|
00003c80  0d 02 c3 11 42 56 53 20  65 72 72 6f 72 5f 72 65  |....BVS error_re|
00003c90  74 0d 02 c4 04 0d 02 c5  36 5c 5c 20 47 65 74 20  |t.......6\\ Get |
00003ca0  74 68 65 20 66 69 6c 65  20 6f 66 66 73 65 74 20  |the file offset |
00003cb0  61 6e 64 20 6c 65 6e 67  74 68 20 6f 66 20 74 68  |and length of th|
00003cc0  65 20 73 65 6c 65 63 74  69 6f 6e 0d 02 c6 3e a4  |e selection...>.|
00003cd0  63 61 6c 6c 28 5a 61 70  5f 47 65 74 53 65 6c 29  |call(Zap_GetSel)|
00003ce0  20 20 20 20 20 20 20 20  20 20 20 20 5c 20 28 4f  |            \ (O|
00003cf0  75 74 29 20 43 43 2c 20  52 31 3d 6f 66 66 73 65  |ut) CC, R1=offse|
00003d00  74 2c 20 52 32 3d 6c 65  6e 0d 02 c7 4c 42 43 53  |t, R2=len...LBCS|
00003d10  20 65 72 72 6f 72 5f 6e  6f 73 65 6c 20 20 20 20  | error_nosel    |
00003d20  20 20 20 20 20 20 20 20  20 20 20 5c 20 45 72 72  |           \ Err|
00003d30  6f 72 20 69 66 20 74 68  65 72 65 20 69 73 6e 27  |or if there isn'|
00003d40  74 20 6f 6e 65 20 2d 20  63 61 6e 6e 6f 74 20 68  |t one - cannot h|
00003d50  61 70 70 65 6e 0d 02 c8  11 42 56 53 20 65 72 72  |appen....BVS err|
00003d60  6f 72 5f 72 65 74 0d 02  c9 04 0d 02 ca 32 5c 5c  |or_ret.......2\\|
00003d70  20 52 65 70 6c 61 63 65  20 74 68 65 20 73 65 6c  | Replace the sel|
00003d80  65 63 74 69 6f 6e 20 77  69 74 68 20 74 68 65 20  |ection with the |
00003d90  63 68 61 6e 67 65 64 20  74 65 78 74 0d 02 cb 16  |changed text....|
00003da0  a4 63 61 6c 6c 28 5a 61  70 5f 53 74 61 72 74 4f  |.call(Zap_StartO|
00003db0  70 29 0d 02 cc 11 42 56  53 20 65 72 72 6f 72 5f  |p)....BVS error_|
00003dc0  72 65 74 0d 02 cd 4e a4  63 61 6c 6c 28 5a 61 70  |ret...N.call(Zap|
00003dd0  5f 52 65 70 6c 61 63 65  41 72 65 61 29 20 20 20  |_ReplaceArea)   |
00003de0  20 20 20 20 5c 20 28 49  6e 29 20 52 31 3d 6f 66  |    \ (In) R1=of|
00003df0  66 73 65 74 2c 20 52 32  3d 6c 65 6e 2c 20 52 33  |fset, R2=len, R3|
00003e00  3d 62 6c 6f 63 6b 2c 20  52 34 3d 62 6c 6b 6c 65  |=block, R4=blkle|
00003e10  6e 0d 02 ce 11 42 56 53  20 65 72 72 6f 72 5f 72  |n....BVS error_r|
00003e20  65 74 0d 02 cf 15 a4 63  61 6c 6c 28 5a 61 70 5f  |et.....call(Zap_|
00003e30  53 74 6f 70 4f 70 29 0d  02 d0 11 42 56 53 20 65  |StopOp)....BVS e|
00003e40  72 72 6f 72 5f 72 65 74  0d 02 d1 04 0d 02 d2 3a  |rror_ret.......:|
00003e50  5c 5c 20 46 72 65 65 20  74 68 65 20 68 65 61 70  |\\ Free the heap|
00003e60  20 62 6c 6f 63 6b 2c 20  61 6e 64 20 64 65 6c 65  | block, and dele|
00003e70  74 65 20 74 68 65 20 74  65 6d 70 6f 72 61 72 79  |te the temporary|
00003e80  20 66 69 6c 65 73 0d 02  d3 0d 4d 4f 56 20 52 30  | files....MOV R0|
00003e90  2c 52 33 0d 02 d4 30 a4  63 61 6c 6c 28 5a 61 70  |,R3...0.call(Zap|
00003ea0  5f 46 72 65 65 29 20 20  20 20 20 20 20 20 20 20  |_Free)          |
00003eb0  20 20 20 20 5c 20 28 49  6e 29 20 52 30 3d 62 6c  |    \ (In) R0=bl|
00003ec0  6f 63 6b 0d 02 d5 11 42  56 53 20 65 72 72 6f 72  |ock....BVS error|
00003ed0  5f 72 65 74 0d 02 d6 04  0d 02 d7 30 41 44 52 20  |_ret.......0ADR |
00003ee0  52 31 2c 66 69 6c 65 5f  69 6e 20 20 20 20 20 20  |R1,file_in      |
00003ef0  20 20 20 20 20 20 20 20  20 20 5c 20 28 49 6e 29  |          \ (In)|
00003f00  20 52 31 3d 66 69 6c 65  0d 02 d8 0d 42 4c 20 64  | R1=file....BL d|
00003f10  65 6c 65 74 65 0d 02 d9  30 41 44 52 20 52 31 2c  |elete...0ADR R1,|
00003f20  66 69 6c 65 5f 6f 75 74  20 20 20 20 20 20 20 20  |file_out        |
00003f30  20 20 20 20 20 20 20 5c  20 28 49 6e 29 20 52 31  |       \ (In) R1|
00003f40  3d 66 69 6c 65 0d 02 da  0d 42 4c 20 64 65 6c 65  |=file....BL dele|
00003f50  74 65 0d 02 db 04 0d 02  dc 0f 5c 5c 20 46 69 6e  |te........\\ Fin|
00003f60  69 73 68 65 64 0d 02 dd  08 a4 52 54 53 0d 02 de  |ished.....RTS...|
00003f70  04 0d 02 df 44 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |....D\\\\\\\\\\\|
00003f80  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00003fb0  5c 5c 5c 5c 5c 0d 02 e0  44 5c 20 45 72 72 6f 72  |\\\\\...D\ Error|
00003fc0  20 72 65 74 75 72 6e 73  20 20 20 20 20 20 20 20  | returns        |
00003fd0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00003ff0  20 20 20 20 20 20 20 20  5c 0d 02 e1 44 5c 5c 5c  |        \...D\\\|
00004000  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004030  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 0d 02 e2  |\\\\\\\\\\\\\...|
00004040  10 2e 65 72 72 6f 72 5f  6e 6f 73 65 6c 0d 02 e3  |..error_nosel...|
00004050  1c 41 44 52 20 52 30 2c  65 72 72 6f 72 5f 6e 6f  |.ADR R0,error_no|
00004060  73 65 6c 65 63 74 69 6f  6e 0d 02 e4 13 5c 20 46  |selection....\ F|
00004070  61 6c 6c 20 74 68 72 6f  75 67 68 21 0d 02 e5 04  |all through!....|
00004080  0d 02 e6 0e 2e 65 72 72  6f 72 5f 72 65 74 0d 02  |.....error_ret..|
00004090  e7 08 a4 52 54 56 0d 02  e8 04 0d 02 e9 16 2e 65  |...RTV.........e|
000040a0  72 72 6f 72 5f 6e 6f 73  65 6c 65 63 74 69 6f 6e  |rror_noselection|
000040b0  0d 02 ea 0a 45 51 55 44  20 30 0d 02 eb 16 a4 53  |....EQUD 0.....S|
000040c0  28 22 4e 6f 20 73 65 6c  65 63 74 69 6f 6e 22 29  |("No selection")|
000040d0  0d 02 ec 04 0d 02 ed 44  5c 5c 5c 5c 5c 5c 5c 5c  |.......D\\\\\\\\|
000040e0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004110  5c 5c 5c 5c 5c 5c 5c 5c  0d 02 ee 44 5c 20 49 6e  |\\\\\\\\...D\ In|
00004120  70 75 74 20 61 6e 64 20  6f 75 74 70 75 74 20 66  |put and output f|
00004130  69 6c 65 6e 61 6d 65 73  20 66 6f 72 20 63 6f 6d  |ilenames for com|
00004140  6d 61 6e 64 20 20 20 20  20 20 20 20 20 20 20 20  |mand            |
00004150  20 20 20 20 20 20 20 20  20 20 20 5c 0d 02 ef 44  |           \...D|
00004160  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000041a0  0d 02 f0 04 0d 02 f1 0c  2e 66 69 6c 65 5f 69 6e  |.........file_in|
000041b0  0d 02 f2 20 a4 53 28 22  3c 57 69 6d 70 24 53 63  |... .S("<Wimp$Sc|
000041c0  72 61 70 44 69 72 3e 2e  5a 61 70 2d 49 6e 22 29  |rapDir>.Zap-In")|
000041d0  0d 02 f3 04 0d 02 f4 0d  2e 66 69 6c 65 5f 6f 75  |.........file_ou|
000041e0  74 0d 02 f5 21 a4 53 28  22 3c 57 69 6d 70 24 53  |t...!.S("<Wimp$S|
000041f0  63 72 61 70 44 69 72 3e  2e 5a 61 70 2d 4f 75 74  |crapDir>.Zap-Out|
00004200  22 29 0d 02 f6 04 0d 02  f7 44 5c 5c 5c 5c 5c 5c  |").......D\\\\\\|
00004210  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004240  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 0d 02 f8 44 5c 20  |\\\\\\\\\\...D\ |
00004250  41 64 64 20 61 20 70 72  6f 6d 70 74 20 74 6f 20  |Add a prompt to |
00004260  74 68 65 20 6d 69 6e 69  62 75 66 66 65 72 20 28  |the minibuffer (|
00004270  74 61 69 6c 20 63 61 6c  6c 65 64 20 66 72 6f 6d  |tail called from|
00004280  20 63 6f 6d 6d 61 6e 64  29 20 20 20 20 5c 0d 02  | command)    \..|
00004290  f9 44 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |.D\\\\\\\\\\\\\\|
000042a0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000042d0  5c 5c 0d 02 fa 04 0d 02  fb 0f 2e 61 64 64 5f 70  |\\.........add_p|
000042e0  72 6f 6d 70 74 0d 02 fc  18 41 44 52 20 52 30 2c  |rompt....ADR R0,|
000042f0  70 72 6f 6d 70 74 5f 73  74 72 69 6e 67 0d 02 fd  |prompt_string...|
00004300  19 a4 63 61 6c 6c 28 5a  61 70 5f 4d 69 6e 69 50  |..call(Zap_MiniP|
00004310  72 6f 6d 70 74 29 0d 02  fe 08 a4 52 54 53 0d 02  |rompt).....RTS..|
00004320  ff 04 0d 03 00 12 2e 70  72 6f 6d 70 74 5f 73 74  |.......prompt_st|
00004330  72 69 6e 67 0d 03 01 12  a4 53 28 22 46 69 6c 74  |ring.....S("Filt|
00004340  65 72 3a 20 22 29 0d 03  02 04 0d 03 03 44 5c 5c  |er: ").......D\\|
00004350  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004380  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 0d 03  |\\\\\\\\\\\\\\..|
00004390  04 44 5c 20 53 61 76 65  20 64 61 74 61 20 74 6f  |.D\ Save data to|
000043a0  20 61 20 66 69 6c 65 20  20 20 20 20 20 20 20 20  | a file         |
000043b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000043d0  20 5c 0d 03 05 44 5c 20  28 49 6e 29 20 52 31 20  | \...D\ (In) R1 |
000043e0  3d 20 66 69 6c 65 6e 61  6d 65 2c 20 52 32 20 3d  |= filename, R2 =|
000043f0  20 6c 65 6e 2c 20 52 33  20 3d 20 61 64 64 72 20  | len, R3 = addr |
00004400  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00004410  20 20 20 20 20 5c 0d 03  06 44 5c 5c 5c 5c 5c 5c  |     \...D\\\\\\|
00004420  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004450  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 0d 03 07 04 0d 03  |\\\\\\\\\\......|
00004460  08 09 2e 73 61 76 65 0d  03 09 1a 53 54 4d 46 44  |...save....STMFD|
00004470  20 52 31 33 21 2c 7b 52  31 2d 52 35 2c 52 31 34  | R13!,{R1-R5,R14|
00004480  7d 0d 03 0a 23 4d 4f 56  20 52 34 2c 52 33 20 20  |}...#MOV R4,R3  |
00004490  20 20 20 20 20 20 20 20  5c 20 73 74 61 72 74 20  |        \ start |
000044a0  61 64 64 72 0d 03 0b 21  41 44 44 20 52 35 2c 52  |addr...!ADD R5,R|
000044b0  33 2c 52 32 20 20 20 20  20 20 20 5c 20 65 6e 64  |3,R2       \ end|
000044c0  20 61 64 64 72 0d 03 0c  22 4d 4f 56 20 52 30 2c  | addr..."MOV R0,|
000044d0  23 31 30 20 20 20 20 20  20 20 20 20 5c 20 73 61  |#10         \ sa|
000044e0  76 65 20 66 69 6c 65 0d  03 0d 21 4c 44 52 20 52  |ve file...!LDR R|
000044f0  32 2c 66 69 6c 65 5f 74  78 74 20 20 20 20 5c 20  |2,file_txt    \ |
00004500  66 69 6c 65 74 79 70 65  0d 03 0e 12 53 57 49 20  |filetype....SWI |
00004510  22 58 4f 53 5f 46 69 6c  65 22 0d 03 0f 19 4c 44  |"XOS_File"....LD|
00004520  4d 46 44 20 52 31 33 21  2c 7b 52 31 2d 52 35 2c  |MFD R13!,{R1-R5,|
00004530  50 43 7d 0d 03 10 04 0d  03 11 0d 2e 66 69 6c 65  |PC}.........file|
00004540  5f 74 78 74 0d 03 12 0d  45 51 55 44 20 26 46 46  |_txt....EQUD &FF|
00004550  46 0d 03 13 04 0d 03 14  44 5c 5c 5c 5c 5c 5c 5c  |F.......D\\\\\\\|
00004560  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004590  5c 5c 5c 5c 5c 5c 5c 5c  5c 0d 03 15 44 5c 20 47  |\\\\\\\\\...D\ G|
000045a0  65 74 20 74 68 65 20 6c  65 6e 67 74 68 20 6f 66  |et the length of|
000045b0  20 61 20 66 69 6c 65 20  20 20 20 20 20 20 20 20  | a file         |
000045c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000045d0  20 20 20 20 20 20 20 20  20 20 20 20 5c 0d 03 16  |            \...|
000045e0  44 5c 20 28 49 6e 29 20  52 31 20 3d 20 66 69 6c  |D\ (In) R1 = fil|
000045f0  65 20 28 4f 75 74 29 20  52 30 20 3d 20 6c 65 6e  |e (Out) R0 = len|
00004600  67 74 68 20 20 20 20 20  20 20 20 20 20 20 20 20  |gth             |
00004610  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00004620  5c 0d 03 17 44 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\...D\\\\\\\\\\\|
00004630  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004660  5c 5c 5c 5c 5c 0d 03 18  04 0d 03 19 0c 2e 67 65  |\\\\\.........ge|
00004670  74 5f 6c 65 6e 0d 03 1a  1a 53 54 4d 46 44 20 52  |t_len....STMFD R|
00004680  31 33 21 2c 7b 52 31 2d  52 36 2c 52 31 34 7d 0d  |13!,{R1-R6,R14}.|
00004690  03 1b 0e 4d 4f 56 20 52  30 2c 23 31 37 0d 03 1c  |...MOV R0,#17...|
000046a0  12 53 57 49 20 22 58 4f  53 5f 46 69 6c 65 22 0d  |.SWI "XOS_File".|
000046b0  03 1d 0f 4d 4f 56 56 43  20 52 30 2c 52 34 0d 03  |...MOVVC R0,R4..|
000046c0  1e 19 4c 44 4d 46 44 20  52 31 33 21 2c 7b 52 31  |..LDMFD R13!,{R1|
000046d0  2d 52 36 2c 50 43 7d 0d  03 1f 04 0d 03 20 44 5c  |-R6,PC}...... D\|
000046e0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004710  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 0d  |\\\\\\\\\\\\\\\.|
00004720  03 21 44 5c 20 44 65 6c  65 74 65 20 61 20 66 69  |.!D\ Delete a fi|
00004730  6c 65 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |le              |
00004740  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00004760  20 20 5c 0d 03 22 44 5c  20 28 49 6e 29 20 52 31  |  \.."D\ (In) R1|
00004770  20 3d 20 66 69 6c 65 20  20 20 20 20 20 20 20 20  | = file         |
00004780  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000047a0  20 20 20 20 20 20 5c 0d  03 23 44 5c 5c 5c 5c 5c  |      \..#D\\\\\|
000047b0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000047e0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 0d 03 24 04 0d  |\\\\\\\\\\\..$..|
000047f0  03 25 0b 2e 64 65 6c 65  74 65 0d 03 26 1a 53 54  |.%..delete..&.ST|
00004800  4d 46 44 20 52 31 33 21  2c 7b 52 31 2d 52 35 2c  |MFD R13!,{R1-R5,|
00004810  52 31 34 7d 0d 03 27 0d  4d 4f 56 20 52 30 2c 23  |R14}..'.MOV R0,#|
00004820  36 0d 03 28 12 53 57 49  20 22 58 4f 53 5f 46 69  |6..(.SWI "XOS_Fi|
00004830  6c 65 22 0d 03 29 19 4c  44 4d 46 44 20 52 31 33  |le"..).LDMFD R13|
00004840  21 2c 7b 52 31 2d 52 35  2c 50 43 7d 0d 03 2a 04  |!,{R1-R5,PC}..*.|
00004850  0d 03 2b 44 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |..+D\\\\\\\\\\\\|
00004860  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004890  5c 5c 5c 5c 0d 03 2c 44  5c 20 4c 6f 61 64 20 61  |\\\\..,D\ Load a|
000048a0  20 66 69 6c 65 20 20 20  20 20 20 20 20 20 20 20  | file           |
000048b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000048d0  20 20 20 20 20 20 20 5c  0d 03 2d 44 5c 20 28 49  |       \..-D\ (I|
000048e0  6e 29 20 52 30 20 3d 20  61 64 64 72 65 73 73 2c  |n) R0 = address,|
000048f0  20 52 31 20 3d 20 66 69  6c 65 20 20 20 20 20 20  | R1 = file      |
00004900  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00004910  20 20 20 20 20 20 20 20  20 20 20 5c 0d 03 2e 44  |           \...D|
00004920  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004960  0d 03 2f 04 0d 03 30 0e  2e 6c 6f 61 64 5f 66 69  |../...0..load_fi|
00004970  6c 65 0d 03 31 1a 53 54  4d 46 44 20 52 31 33 21  |le..1.STMFD R13!|
00004980  2c 7b 52 31 2d 52 37 2c  52 31 34 7d 0d 03 32 2c  |,{R1-R7,R14}..2,|
00004990  4d 4f 56 20 52 32 2c 52  30 20 20 20 20 20 20 20  |MOV R2,R0       |
000049a0  20 20 20 20 5c 20 61 64  64 72 65 73 73 20 74 6f  |    \ address to|
000049b0  20 6c 6f 61 64 20 74 6f  0d 03 33 23 4d 4f 56 20  | load to..3#MOV |
000049c0  52 30 2c 23 31 36 20 20  20 20 20 20 20 20 20 20  |R0,#16          |
000049d0  5c 20 6c 6f 61 64 20 66  69 6c 65 0d 03 34 2f 4d  |\ load file..4/M|
000049e0  4f 56 20 52 33 2c 23 30  20 20 20 20 20 20 20 20  |OV R3,#0        |
000049f0  20 20 20 5c 20 6c 6f 61  64 20 74 6f 20 67 69 76  |   \ load to giv|
00004a00  65 6e 20 61 64 64 72 65  73 73 0d 03 35 12 53 57  |en address..5.SW|
00004a10  49 20 22 58 4f 53 5f 46  69 6c 65 22 0d 03 36 19  |I "XOS_File"..6.|
00004a20  4c 44 4d 46 44 20 52 31  33 21 2c 7b 52 31 2d 52  |LDMFD R13!,{R1-R|
00004a30  37 2c 50 43 7d 0d 03 37  04 0d 03 38 44 5c 5c 5c  |7,PC}..7...8D\\\|
00004a40  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004a70  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 0d 03 39  |\\\\\\\\\\\\\..9|
00004a80  44 5c 20 46 69 6c 74 65  72 20 66 69 6c 65 5f 69  |D\ Filter file_i|
00004a90  6e 20 74 6f 20 66 69 6c  65 5f 6f 75 74 20 20 20  |n to file_out   |
00004aa0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00004ac0  5c 0d 03 3a 44 5c 20 28  49 6e 29 20 52 30 3d 63  |\..:D\ (In) R0=c|
00004ad0  6f 6d 6d 61 6e 64 2c 20  52 31 3d 69 6e 70 75 74  |ommand, R1=input|
00004ae0  2c 20 52 32 3d 6f 75 74  70 75 74 20 20 20 20 20  |, R2=output     |
00004af0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00004b00  20 20 20 20 5c 0d 03 3b  44 5c 5c 5c 5c 5c 5c 5c  |    \..;D\\\\\\\|
00004b10  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004b40  5c 5c 5c 5c 5c 5c 5c 5c  5c 0d 03 3c 04 0d 03 3d  |\\\\\\\\\..<...=|
00004b50  10 2e 66 69 6c 74 65 72  5f 66 69 6c 65 0d 03 3e  |..filter_file..>|
00004b60  1a 53 54 4d 46 44 20 52  31 33 21 2c 7b 52 30 2d  |.STMFD R13!,{R0-|
00004b70  52 32 2c 52 31 34 7d 0d  03 3f 04 0d 03 40 28 5c  |R2,R14}..?...@(\|
00004b80  20 54 68 65 20 70 61 72  61 6d 65 74 65 72 20 6c  | The parameter l|
00004b90  69 73 74 20 69 73 20 6f  6e 20 74 68 65 20 73 74  |ist is on the st|
00004ba0  61 63 6b 0d 03 41 0e 4d  4f 56 20 52 33 2c 52 31  |ack..A.MOV R3,R1|
00004bb0  33 0d 03 42 04 0d 03 43  36 5c 20 43 6c 61 69 6d  |3..B...C6\ Claim|
00004bc0  20 73 6f 6d 65 20 73 70  61 63 65 20 66 6f 72 20  | some space for |
00004bd0  74 68 65 20 63 6f 6d 6d  61 6e 64 20 62 75 66 66  |the command buff|
00004be0  65 72 20 66 72 6f 6d 20  5a 61 70 0d 03 44 13 4d  |er from Zap..D.M|
00004bf0  4f 56 20 52 30 2c 23 62  75 66 6c 65 6e 25 0d 03  |OV R0,#buflen%..|
00004c00  45 14 a4 63 61 6c 6c 28  5a 61 70 5f 43 6c 61 69  |E..call(Zap_Clai|
00004c10  6d 29 0d 03 46 47 41 44  44 56 53 20 52 31 33 2c  |m)..FGADDVS R13,|
00004c20  52 31 33 2c 23 34 20 20  20 20 20 20 20 20 20 20  |R13,#4          |
00004c30  20 20 20 20 20 20 5c 20  4f 6e 20 61 6e 20 65 72  |      \ On an er|
00004c40  72 6f 72 2c 20 77 65 20  64 6f 6e 27 74 20 72 65  |ror, we don't re|
00004c50  73 74 6f 72 65 20 52 30  21 0d 03 47 1b 4c 44 4d  |store R0!..G.LDM|
00004c60  56 53 46 44 20 52 31 33  21 2c 7b 52 31 2d 52 32  |VSFD R13!,{R1-R2|
00004c70  2c 50 43 7d 0d 03 48 04  0d 03 49 13 4d 4f 56 20  |,PC}..H...I.MOV |
00004c80  52 32 2c 23 62 75 66 6c  65 6e 25 0d 03 4a 0d 4d  |R2,#buflen%..J.M|
00004c90  4f 56 20 52 31 2c 52 30  0d 03 4b 17 41 44 52 20  |OV R1,R0..K.ADR |
00004ca0  52 30 2c 63 6d 64 5f 74  65 6d 70 6c 61 74 65 0d  |R0,cmd_template.|
00004cb0  03 4c 0d 42 4c 20 61 72  67 73 75 62 0d 03 4d 04  |.L.BL argsub..M.|
00004cc0  0d 03 4e 28 5c 20 53 61  76 65 20 74 68 65 20 61  |..N(\ Save the a|
00004cd0  64 64 72 65 73 73 20 6f  66 20 74 68 65 20 68 65  |ddress of the he|
00004ce0  61 70 20 62 6c 6f 63 6b  0d 03 4f 0d 4d 4f 56 20  |ap block..O.MOV |
00004cf0  52 32 2c 52 30 0d 03 50  04 0d 03 51 38 5c 20 44  |R2,R0..P...Q8\ D|
00004d00  72 6f 70 20 52 30 20 66  72 6f 6d 20 74 68 65 20  |rop R0 from the |
00004d10  73 74 61 63 6b 2c 20 61  73 20 77 65 20 69 6e 74  |stack, as we int|
00004d20  65 6e 64 20 74 6f 20 63  6f 72 72 75 70 74 20 69  |end to corrupt i|
00004d30  74 0d 03 52 12 41 44 44  20 52 31 33 2c 52 31 33  |t..R.ADD R13,R13|
00004d40  2c 23 34 0d 03 53 04 0d  03 54 1a 5c 20 53 74 61  |,#4..S...T.\ Sta|
00004d50  72 74 20 74 68 65 20 63  68 69 6c 64 20 74 61 73  |rt the child tas|
00004d60  6b 0d 03 55 19 53 57 49  20 22 58 57 69 6d 70 5f  |k..U.SWI "XWimp_|
00004d70  53 74 61 72 74 54 61 73  6b 22 0d 03 56 17 42 56  |StartTask"..V.BV|
00004d80  53 20 65 72 72 6f 72 5f  73 74 61 72 74 74 61 73  |S error_starttas|
00004d90  6b 0d 03 57 0d 54 45 51  20 52 30 2c 23 30 0d 03  |k..W.TEQ R0,#0..|
00004da0  58 1b 41 44 52 4e 45 20  52 30 2c 65 72 72 6f 72  |X.ADRNE R0,error|
00004db0  5f 6c 69 76 65 74 61 73  6b 0d 03 59 17 42 4e 45  |_livetask..Y.BNE|
00004dc0  20 65 72 72 6f 72 5f 73  74 61 72 74 74 61 73 6b  | error_starttask|
00004dd0  0d 03 5a 04 0d 03 5b 19  5c 20 46 72 65 65 20 74  |..Z...[.\ Free t|
00004de0  68 65 20 68 65 61 70 20  62 6c 6f 63 6b 0d 03 5c  |he heap block..\|
00004df0  0d 4d 4f 56 20 52 30 2c  52 32 0d 03 5d 13 a4 63  |.MOV R0,R2..]..c|
00004e00  61 6c 6c 28 5a 61 70 5f  46 72 65 65 29 0d 03 5e  |all(Zap_Free)..^|
00004e10  04 0d 03 5f 19 4c 44 4d  46 44 20 52 31 33 21 2c  |..._.LDMFD R13!,|
00004e20  7b 52 31 2d 52 32 2c 50  43 7d 0d 03 60 04 0d 03  |{R1-R2,PC}..`...|
00004e30  61 26 5c 20 45 72 72 6f  72 20 69 6e 20 73 74 61  |a&\ Error in sta|
00004e40  72 74 69 6e 67 20 74 68  65 20 63 68 69 6c 64 20  |rting the child |
00004e50  74 61 73 6b 0d 03 62 14  2e 65 72 72 6f 72 5f 73  |task..b..error_s|
00004e60  74 61 72 74 74 61 73 6b  0d 03 63 40 4d 4f 56 20  |tarttask..c@MOV |
00004e70  52 31 2c 52 30 20 20 20  20 20 20 20 20 20 20 20  |R1,R0           |
00004e80  20 20 20 20 20 20 20 20  20 20 20 20 5c 20 50 72  |            \ Pr|
00004e90  65 73 65 72 76 65 20 74  68 65 20 65 72 72 6f 72  |eserve the error|
00004ea0  20 70 6f 69 6e 74 65 72  0d 03 64 04 0d 03 65 0d  | pointer..d...e.|
00004eb0  4d 4f 56 20 52 30 2c 52  32 0d 03 66 4d a4 63 61  |MOV R0,R2..fM.ca|
00004ec0  6c 6c 28 5a 61 70 5f 46  72 65 65 29 20 20 20 20  |ll(Zap_Free)    |
00004ed0  20 20 20 20 20 20 20 20  20 20 20 20 5c 20 46 72  |            \ Fr|
00004ee0  65 65 20 74 68 65 20 68  65 61 70 20 62 6c 6f 63  |ee the heap bloc|
00004ef0  6b 20 28 69 67 6e 6f 72  65 20 65 72 72 6f 72 73  |k (ignore errors|
00004f00  20 68 65 72 65 29 0d 03  67 04 0d 03 68 0d 4d 4f  | here)..g...h.MO|
00004f10  56 20 52 30 2c 52 31 0d  03 69 1a 4c 44 4d 46 44  |V R0,R1..i.LDMFD|
00004f20  20 52 31 33 21 2c 7b 52  31 2d 52 32 2c 52 31 34  | R13!,{R1-R2,R14|
00004f30  7d 0d 03 6a 16 84 52 53  20 50 43 2c 52 31 34 2c  |}..j..RS PC,R14,|
00004f40  23 56 66 6c 61 67 25 0d  03 6b 04 0d 03 6c 44 5c  |#Vflag%..k...lD\|
00004f50  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00004f80  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 0d  |\\\\\\\\\\\\\\\.|
00004f90  03 6d 13 2e 65 72 72 6f  72 5f 6c 69 76 65 74 61  |.m..error_liveta|
00004fa0  73 6b 0d 03 6e 0a 45 51  55 44 20 30 0d 03 6f 27  |sk..n.EQUD 0..o'|
00004fb0  a4 53 28 22 46 69 6c 74  65 72 20 74 61 73 6b 20  |.S("Filter task |
00004fc0  68 61 73 20 6e 6f 74 20  63 6f 6d 70 6c 65 74 65  |has not complete|
00004fd0  64 22 29 0d 03 70 04 0d  03 71 44 5c 5c 5c 5c 5c  |d")..p...qD\\\\\|
00004fe0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00005010  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 0d 03 72 04 0d  |\\\\\\\\\\\..r..|
00005020  03 73 11 2e 63 6d 64 5f  74 65 6d 70 6c 61 74 65  |.s..cmd_template|
00005030  0d 03 74 1f a4 53 28 22  25 30 20 3c 20 25 31 20  |..t..S("%0 < %1 |
00005040  3e 20 25 32 20 32 3e 20  4e 75 6c 6c 3a 22 29 0d  |> %2 2> Null:").|
00005050  03 75 04 0d 03 76 44 5c  5c 5c 5c 5c 5c 5c 5c 5c  |.u...vD\\\\\\\\\|
00005060  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
00005090  5c 5c 5c 5c 5c 5c 5c 0d  03 77 44 5c 20 53 75 62  |\\\\\\\..wD\ Sub|
000050a0  73 74 69 74 75 74 65 20  61 72 67 73 20 69 6e 74  |stitute args int|
000050b0  6f 20 61 20 73 74 72 69  6e 67 20 20 20 20 20 20  |o a string      |
000050c0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000050d0  20 20 20 20 20 20 20 20  20 20 5c 0d 03 78 44 5c  |          \..xD\|
000050e0  20 28 49 6e 29 20 52 30  20 3d 20 74 65 6d 70 6c  | (In) R0 = templ|
000050f0  61 74 65 2c 20 52 31 20  3d 20 6f 75 74 70 75 74  |ate, R1 = output|
00005100  20 62 75 66 66 65 72 2c  20 52 32 20 3d 20 6f 75  | buffer, R2 = ou|
00005110  74 70 75 74 20 62 75 66  66 65 72 20 20 20 5c 0d  |tput buffer   \.|
00005120  03 79 44 5c 20 20 20 20  20 20 6c 65 6e 67 74 68  |.yD\      length|
00005130  2c 20 52 33 20 3d 20 70  61 72 61 6d 65 74 65 72  |, R3 = parameter|
00005140  20 6c 69 73 74 20 20 20  20 20 20 20 20 20 20 20  | list           |
00005150  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00005160  20 20 5c 0d 03 7a 44 5c  20 28 4f 75 74 29 20 52  |  \..zD\ (Out) R|
00005170  30 20 3d 20 6f 75 74 70  75 74 20 62 75 66 66 65  |0 = output buffe|
00005180  72 2c 20 52 31 20 3d 20  6e 75 6c 6c 20 61 74 20  |r, R1 = null at |
00005190  65 6e 64 20 6f 66 20 6f  75 74 70 75 74 20 20 20  |end of output   |
000051a0  20 20 20 20 20 20 5c 0d  03 7b 44 5c 20 20 20 20  |      \..{D\    |
000051b0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000051e0  20 20 20 20 20 20 20 20  20 20 5c 0d 03 7c 44 5c  |          \..|D\|
000051f0  20 43 6f 70 69 65 73 20  74 68 65 20 74 65 6d 70  | Copies the temp|
00005200  6c 61 74 65 20 69 6e 74  6f 20 74 68 65 20 6f 75  |late into the ou|
00005210  74 70 75 74 20 62 75 66  66 65 72 2c 20 72 65 70  |tput buffer, rep|
00005220  6c 61 63 69 6e 67 20 25  6e 20 62 79 20 20 5c 0d  |lacing %n by  \.|
00005230  03 7d 44 5c 20 74 68 65  20 63 6f 6e 74 65 6e 74  |.}D\ the content|
00005240  73 20 6f 66 20 74 68 65  20 6e 74 68 20 70 61 72  |s of the nth par|
00005250  61 6d 65 74 65 72 20 69  6e 20 74 68 65 20 6c 69  |ameter in the li|
00005260  73 74 20 61 74 20 52 33  2e 20 25 25 20 69 73 20  |st at R3. %% is |
00005270  20 20 5c 0d 03 7e 44 5c  20 72 65 70 6c 61 63 65  |  \..~D\ replace|
00005280  64 20 62 79 20 61 20 73  69 6e 67 6c 65 20 25 20  |d by a single % |
00005290  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
000052b0  20 20 20 20 20 20 5c 0d  03 7f 44 5c 5c 5c 5c 5c  |      \...D\\\\\|
000052c0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
*
000052f0  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 0d 03 80 04 0d  |\\\\\\\\\\\.....|
00005300  03 81 0b 2e 61 72 67 73  75 62 0d 03 82 1a 53 54  |....argsub....ST|
00005310  4d 46 44 20 52 31 33 21  2c 7b 52 31 2d 52 35 2c  |MFD R13!,{R1-R5,|
00005320  52 31 34 7d 0d 03 83 04  0d 03 84 26 5c 20 4d 61  |R14}.......&\ Ma|
00005330  69 6e 20 6c 6f 6f 70 20  2d 20 6c 6f 61 64 20 61  |in loop - load a|
00005340  6e 64 20 73 74 6f 72 65  20 62 79 74 65 73 0d 03  |nd store bytes..|
00005350  85 08 2e 4c 31 31 0d 03  86 16 5c 20 42 75 66 66  |...L11....\ Buff|
00005360  65 72 20 6f 76 65 72 66  6c 6f 77 3f 0d 03 87 0d  |er overflow?....|
00005370  54 45 51 20 52 32 2c 23  30 0d 03 88 15 42 45 51  |TEQ R2,#0....BEQ|
00005380  20 4c 65 72 72 5f 6f 76  65 72 66 6c 6f 77 0d 03  | Lerr_overflow..|
00005390  89 04 0d 03 8a 10 4c 44  52 42 20 52 34 2c 5b 52  |......LDRB R4,[R|
000053a0  30 5d 0d 03 8b 04 0d 03  8c 1c 5c 20 41 72 67 75  |0]........\ Argu|
000053b0  6d 65 6e 74 20 73 75 62  73 74 69 74 75 74 69 6f  |ment substitutio|
000053c0  6e 3f 0d 03 8d 10 54 45  51 20 52 34 2c 23 97 22  |n?....TEQ R4,#."|
000053d0  25 22 0d 03 8e 0c 42 45  51 20 4c 70 63 74 0d 03  |%"....BEQ Lpct..|
000053e0  8f 04 0d 03 90 27 5c 20  42 61 73 69 63 20 63 61  |.....'\ Basic ca|
000053f0  73 65 20 2d 20 61 64 64  20 74 6f 20 6f 75 74 70  |se - add to outp|
00005400  75 74 20 73 74 72 69 6e  67 0d 03 91 09 2e 4c 62  |ut string.....Lb|
00005410  61 73 0d 03 92 13 53 54  52 42 20 52 34 2c 5b 52  |as....STRB R4,[R|
00005420  31 5d 2c 23 31 0d 03 93  10 41 44 44 20 52 30 2c  |1],#1....ADD R0,|
00005430  52 30 2c 23 31 0d 03 94  10 53 55 42 20 52 32 2c  |R0,#1....SUB R2,|
00005440  52 32 2c 23 31 0d 03 95  04 0d 03 96 0d 5c 20 41  |R2,#1........\ A|
00005450  74 20 65 6e 64 3f 0d 03  97 0d 54 45 51 20 52 34  |t end?....TEQ R4|
00005460  2c 23 30 0d 03 98 0b 42  4e 45 20 4c 31 31 0d 03  |,#0....BNE L11..|
00005470  99 04 0d 03 9a 39 53 55  42 20 52 31 2c 52 31 2c  |.....9SUB R1,R1,|
00005480  23 31 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |#1              |
00005490  20 20 20 20 20 20 5c 20  42 61 63 6b 20 75 70 20  |      \ Back up |
000054a0  74 6f 20 74 68 65 20 6e  75 6c 6c 0d 03 9b 49 4c  |to the null...IL|
000054b0  44 4d 46 44 20 52 31 33  21 2c 7b 52 30 2c 52 32  |DMFD R13!,{R0,R2|
000054c0  2d 52 35 2c 50 43 7d 20  20 20 20 20 20 20 20 5c  |-R5,PC}        \|
000054d0  20 52 65 73 74 6f 72 65  2c 20 62 75 74 20 72 65  | Restore, but re|
000054e0  73 74 6f 72 65 20 73 61  76 65 64 20 52 31 20 74  |store saved R1 t|
000054f0  6f 20 52 30 0d 03 9c 04  0d 03 9d 1b 5c 20 41 72  |o R0........\ Ar|
00005500  67 75 6d 65 6e 74 20 73  75 62 73 74 69 74 75 74  |gument substitut|
00005510  69 6f 6e 0d 03 9e 09 2e  4c 70 63 74 0d 03 9f 14  |ion.....Lpct....|
00005520  4c 44 52 42 20 52 34 2c  5b 52 30 2c 23 31 5d 21  |LDRB R4,[R0,#1]!|
00005530  0d 03 a0 2b 54 45 51 20  52 34 2c 23 97 22 25 22  |...+TEQ R4,#."%"|
00005540  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00005550  20 20 5c 20 25 25 20 3d  3e 20 25 0d 03 a1 0c 42  |  \ %% => %....B|
00005560  45 51 20 4c 62 61 73 0d  03 a2 04 0d 03 a3 20 5c  |EQ Lbas....... \|
00005570  20 43 68 65 63 6b 20 74  68 61 74 20 77 65 20 68  | Check that we h|
00005580  61 76 65 20 25 30 20 2d  20 25 39 0d 03 a4 10 43  |ave %0 - %9....C|
00005590  4d 50 20 52 34 2c 23 97  22 30 22 0d 03 a5 14 42  |MP R4,#."0"....B|
000055a0  4c 54 20 4c 65 72 72 5f  69 6e 76 61 6c 69 64 0d  |LT Lerr_invalid.|
000055b0  03 a6 10 43 4d 50 20 52  34 2c 23 97 22 39 22 0d  |...CMP R4,#."9".|
000055c0  03 a7 14 42 47 54 20 4c  65 72 72 5f 69 6e 76 61  |...BGT Lerr_inva|
000055d0  6c 69 64 0d 03 a8 04 0d  03 a9 45 41 44 44 20 52  |lid.......EADD R|
000055e0  30 2c 52 30 2c 23 31 20  20 20 20 20 20 20 20 20  |0,R0,#1         |
000055f0  20 20 20 20 20 20 20 20  20 20 20 5c 20 52 30 20  |           \ R0 |
00005600  2d 3e 20 6e 65 78 74 20  75 6e 72 65 61 64 20 74  |-> next unread t|
00005610  65 6d 70 6c 61 74 65 20  63 68 61 72 0d 03 aa 04  |emplate char....|
00005620  0d 03 ab 13 53 55 42 20  52 34 2c 52 34 2c 23 97  |....SUB R4,R4,#.|
00005630  22 30 22 0d 03 ac 19 4c  44 52 20 52 35 2c 5b 52  |"0"....LDR R5,[R|
00005640  33 2c 52 34 2c 4c 53 4c  20 23 32 5d 0d 03 ad 04  |3,R4,LSL #2]....|
00005650  0d 03 ae 19 5c 20 43 6f  70 79 20 5b 52 35 5d 20  |....\ Copy [R5] |
00005660  69 6e 74 6f 20 5b 52 31  5d 0d 03 af 08 2e 4c 31  |into [R1].....L1|
00005670  32 0d 03 b0 13 4c 44 52  42 20 52 34 2c 5b 52 35  |2....LDRB R4,[R5|
00005680  5d 2c 23 31 0d 03 b1 0d  54 45 51 20 52 34 2c 23  |],#1....TEQ R4,#|
00005690  30 0d 03 b2 41 42 45 51  20 4c 31 31 20 20 20 20  |0...ABEQ L11    |
000056a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000056b0  20 20 20 20 20 5c 20 44  6f 6e 65 20 2d 20 67 6f  |     \ Done - go|
000056c0  20 62 61 63 6b 20 74 6f  20 6d 61 69 6e 20 6c 6f  | back to main lo|
000056d0  6f 70 0d 03 b3 04 0d 03  b4 0d 54 45 51 20 52 32  |op........TEQ R2|
000056e0  2c 23 30 0d 03 b5 15 42  45 51 20 4c 65 72 72 5f  |,#0....BEQ Lerr_|
000056f0  6f 76 65 72 66 6c 6f 77  0d 03 b6 04 0d 03 b7 13  |overflow........|
00005700  53 54 52 42 20 52 34 2c  5b 52 31 5d 2c 23 31 0d  |STRB R4,[R1],#1.|
00005710  03 b8 10 53 55 42 20 52  32 2c 52 32 2c 23 31 0d  |...SUB R2,R2,#1.|
00005720  03 b9 09 42 20 4c 31 32  0d 03 ba 04 0d 03 bb 12  |...B L12........|
00005730  2e 4c 65 72 72 5f 6f 76  65 72 66 6c 6f 77 0d 03  |.Lerr_overflow..|
00005740  bc 19 41 44 52 20 52 30  2c 65 72 72 6f 72 5f 6f  |..ADR R0,error_o|
00005750  76 65 72 66 6c 6f 77 0d  03 bd 1a 4c 44 4d 46 44  |verflow....LDMFD|
00005760  20 52 31 33 21 2c 7b 52  31 2d 52 35 2c 52 31 34  | R13!,{R1-R5,R14|
00005770  7d 0d 03 be 16 84 52 53  20 50 43 2c 52 31 34 2c  |}.....RS PC,R14,|
00005780  23 56 66 6c 61 67 25 0d  03 bf 04 0d 03 c0 11 2e  |#Vflag%.........|
00005790  4c 65 72 72 5f 69 6e 76  61 6c 69 64 0d 03 c1 18  |Lerr_invalid....|
000057a0  41 44 52 20 52 30 2c 65  72 72 6f 72 5f 69 6e 76  |ADR R0,error_inv|
000057b0  61 6c 69 64 0d 03 c2 1a  4c 44 4d 46 44 20 52 31  |alid....LDMFD R1|
000057c0  33 21 2c 7b 52 31 2d 52  35 2c 52 31 34 7d 0d 03  |3!,{R1-R5,R14}..|
000057d0  c3 16 84 52 53 20 50 43  2c 52 31 34 2c 23 56 66  |...RS PC,R14,#Vf|
000057e0  6c 61 67 25 0d 03 c4 04  0d 03 c5 13 2e 65 72 72  |lag%.........err|
000057f0  6f 72 5f 6f 76 65 72 66  6c 6f 77 0d 03 c6 0a 45  |or_overflow....E|
00005800  51 55 44 20 30 0d 03 c7  12 a4 53 28 22 4f 76 65  |QUD 0.....S("Ove|
00005810  72 66 6c 6f 77 22 29 0d  03 c8 04 0d 03 c9 12 2e  |rflow").........|
00005820  65 72 72 6f 72 5f 69 6e  76 61 6c 69 64 0d 03 ca  |error_invalid...|
00005830  0a 45 51 55 44 20 30 0d  03 cb 1a a4 53 28 22 49  |.EQUD 0.....S("I|
00005840  6e 76 61 6c 69 64 20 74  65 6d 70 6c 61 74 65 22  |nvalid template"|
00005850  29 0d 03 cc 04 0d 03 cd  40 5c 5c 5c 5c 5c 5c 5c  |).......@\\\\\\\|
00005860  5c 5c 5c 20 45 6e 64 20  4f 66 20 41 73 73 65 6d  |\\\ End Of Assem|
00005870  62 6c 79 20 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |bly \\\\\\\\\\\\|
00005880  5c 5c 5c 5c 5c 5c 5c 5c  5c 5c 5c 5c 5c 5c 5c 5c  |\\\\\\\\\\\\\\\\|
00005890  5c 5c 5c 5c 5c 0d 03 ce  04 0d 03 cf 05 5d 0d 03  |\\\\\........]..|
000058a0  d0 04 0d 03 d1 0a ed 20  70 61 73 73 0d 03 d2 0e  |....... pass....|
000058b0  6c 65 6e 67 74 68 25 3d  50 25 0d 03 d3 05 e1 0d  |length%=P%......|
000058c0  03 d4 04 0d 03 d5 30 dd  20 a4 53 28 41 24 29 20  |......0. .S(A$) |
000058d0  20 20 20 3a 5b 4f 50 54  70 61 73 73 3a 45 51 55  |   :[OPTpass:EQU|
000058e0  53 20 41 24 2b bd 30 3a  41 4c 49 47 4e 3a 5d 3a  |S A$+.0:ALIGN:]:|
000058f0  3d 22 22 0d 03 d6 32 dd  20 a4 52 45 53 28 6e 25  |=""...2. .RES(n%|
00005900  29 20 20 3a 5b 4f 50 54  70 61 73 73 3a 45 51 55  |)  :[OPTpass:EQU|
00005910  53 20 c4 6e 25 2c bd 30  29 3a 41 4c 49 47 4e 3a  |S .n%,.0):ALIGN:|
00005920  5d 3a 3d 22 22 0d 03 d7  41 dd 20 a4 53 53 28 41  |]:=""...A. .SS(A|
00005930  24 29 20 20 20 3a 5b 4f  50 54 70 61 73 73 3a 53  |$)   :[OPTpass:S|
00005940  57 49 20 22 58 4f 53 5f  57 72 69 74 65 53 22 3a  |WI "XOS_WriteS":|
00005950  45 51 55 53 20 41 24 2b  bd 30 3a 41 4c 49 47 4e  |EQUS A$+.0:ALIGN|
00005960  3a 5d 3a 3d 22 22 0d 03  d8 32 dd 20 a4 4a 53 52  |:]:=""...2. .JSR|
00005970  20 20 20 20 20 20 3a 5b  4f 50 54 70 61 73 73 3a  |      :[OPTpass:|
00005980  53 54 4d 46 44 20 20 20  52 31 33 21 2c 7b 52 31  |STMFD   R13!,{R1|
00005990  34 7d 3a 5d 3a 3d 22 22  0d 03 d9 45 dd 20 a4 52  |4}:]:=""...E. .R|
000059a0  54 56 20 20 20 20 20 20  3a 5b 4f 50 54 70 61 73  |TV      :[OPTpas|
000059b0  73 3a 4c 44 4d 46 44 20  20 20 52 31 33 21 2c 7b  |s:LDMFD   R13!,{|
000059c0  52 31 34 7d 3a 84 52 53  20 50 43 2c 52 31 34 2c  |R14}:.RS PC,R14,|
000059d0  23 56 66 6c 61 67 25 3a  5d 3a 3d 22 22 0d 03 da  |#Vflag%:]:=""...|
000059e0  46 dd 20 a4 52 54 43 20  20 20 20 20 20 3a 5b 4f  |F. .RTC      :[O|
000059f0  50 54 70 61 73 73 3a 4c  44 4d 46 44 20 20 20 52  |PTpass:LDMFD   R|
00005a00  31 33 21 2c 7b 52 31 34  7d 3a 42 49 43 53 20 50  |13!,{R14}:BICS P|
00005a10  43 2c 52 31 34 2c 23 56  66 6c 61 67 25 3a 5d 3a  |C,R14,#Vflag%:]:|
00005a20  3d 22 22 0d 03 db 32 dd  20 a4 52 54 53 20 20 20  |=""...2. .RTS   |
00005a30  20 20 20 3a 5b 4f 50 54  70 61 73 73 3a 4c 44 4d  |   :[OPTpass:LDM|
00005a40  46 44 20 20 20 52 31 33  21 2c 7b 50 43 7d 20 3a  |FD   R13!,{PC} :|
00005a50  5d 3a 3d 22 22 0d 03 dc  31 dd 20 a4 52 54 53 4e  |]:=""...1. .RTSN|
00005a60  45 20 20 20 20 3a 5b 4f  50 54 70 61 73 73 3a 4c  |E    :[OPTpass:L|
00005a70  44 4d 4e 45 46 44 20 52  31 33 21 2c 7b 50 43 7d  |DMNEFD R13!,{PC}|
00005a80  3a 5d 3a 3d 22 22 0d 03  dd 31 dd 20 a4 52 54 53  |:]:=""...1. .RTS|
00005a90  45 51 20 20 20 20 3a 5b  4f 50 54 70 61 73 73 3a  |EQ    :[OPTpass:|
00005aa0  4c 44 4d 45 51 46 44 20  52 31 33 21 2c 7b 50 43  |LDMEQFD R13!,{PC|
00005ab0  7d 3a 5d 3a 3d 22 22 0d  03 de 31 dd 20 a4 52 54  |}:]:=""...1. .RT|
00005ac0  53 43 53 20 20 20 20 3a  5b 4f 50 54 70 61 73 73  |SCS    :[OPTpass|
00005ad0  3a 4c 44 4d 43 53 46 44  20 52 31 33 21 2c 7b 50  |:LDMCSFD R13!,{P|
00005ae0  43 7d 3a 5d 3a 3d 22 22  0d 03 df 31 dd 20 a4 52  |C}:]:=""...1. .R|
00005af0  54 53 43 43 20 20 20 20  3a 5b 4f 50 54 70 61 73  |TSCC    :[OPTpas|
00005b00  73 3a 4c 44 4d 43 43 46  44 20 52 31 33 21 2c 7b  |s:LDMCCFD R13!,{|
00005b10  50 43 7d 3a 5d 3a 3d 22  22 0d 03 e0 31 dd 20 a4  |PC}:]:=""...1. .|
00005b20  52 54 53 56 53 20 20 20  20 3a 5b 4f 50 54 70 61  |RTSVS    :[OPTpa|
00005b30  73 73 3a 4c 44 4d 56 53  46 44 20 52 31 33 21 2c  |ss:LDMVSFD R13!,|
00005b40  7b 50 43 7d 3a 5d 3a 3d  22 22 0d 03 e1 31 dd 20  |{PC}:]:=""...1. |
00005b50  a4 52 54 53 56 43 20 20  20 20 3a 5b 4f 50 54 70  |.RTSVC    :[OPTp|
00005b60  61 73 73 3a 4c 44 4d 56  43 46 44 20 52 31 33 21  |ass:LDMVCFD R13!|
00005b70  2c 7b 50 43 7d 3a 5d 3a  3d 22 22 0d 03 e2 31 dd  |,{PC}:]:=""...1.|
00005b80  20 a4 52 54 53 4c 53 20  20 20 20 3a 5b 4f 50 54  | .RTSLS    :[OPT|
00005b90  70 61 73 73 3a 4c 44 4d  4c 53 46 44 20 52 31 33  |pass:LDMLSFD R13|
00005ba0  21 2c 7b 50 43 7d 3a 5d  3a 3d 22 22 0d 03 e3 31  |!,{PC}:]:=""...1|
00005bb0  dd 20 a4 52 54 53 48 49  20 20 20 20 3a 5b 4f 50  |. .RTSHI    :[OP|
00005bc0  54 70 61 73 73 3a 4c 44  4d 48 49 46 44 20 52 31  |Tpass:LDMHIFD R1|
00005bd0  33 21 2c 7b 50 43 7d 3a  5d 3a 3d 22 22 0d 03 e4  |3!,{PC}:]:=""...|
00005be0  31 dd 20 a4 52 54 53 4d  49 20 20 20 20 3a 5b 4f  |1. .RTSMI    :[O|
00005bf0  50 54 70 61 73 73 3a 4c  44 4d 4d 49 46 44 20 52  |PTpass:LDMMIFD R|
00005c00  31 33 21 2c 7b 50 43 7d  3a 5d 3a 3d 22 22 0d 03  |13!,{PC}:]:=""..|
00005c10  e5 31 dd 20 a4 52 54 53  4c 45 20 20 20 20 3a 5b  |.1. .RTSLE    :[|
00005c20  4f 50 54 70 61 73 73 3a  4c 44 4d 4c 45 46 44 20  |OPTpass:LDMLEFD |
00005c30  52 31 33 21 2c 7b 50 43  7d 3a 5d 3a 3d 22 22 0d  |R13!,{PC}:]:="".|
00005c40  03 e6 31 dd 20 a4 52 54  53 47 45 20 20 20 20 3a  |..1. .RTSGE    :|
00005c50  5b 4f 50 54 70 61 73 73  3a 4c 44 4d 47 45 46 44  |[OPTpass:LDMGEFD|
00005c60  20 52 31 33 21 2c 7b 50  43 7d 3a 5d 3a 3d 22 22  | R13!,{PC}:]:=""|
00005c70  0d 03 e7 31 dd 20 a4 52  54 53 4c 54 20 20 20 20  |...1. .RTSLT    |
00005c80  3a 5b 4f 50 54 70 61 73  73 3a 4c 44 4d 4c 54 46  |:[OPTpass:LDMLTF|
00005c90  44 20 52 31 33 21 2c 7b  50 43 7d 3a 5d 3a 3d 22  |D R13!,{PC}:]:="|
00005ca0  22 0d 03 e8 32 dd 20 a4  52 54 53 53 20 20 20 20  |"...2. .RTSS    |
00005cb0  20 3a 5b 4f 50 54 70 61  73 73 3a 4c 44 4d 46 44  | :[OPTpass:LDMFD|
00005cc0  20 20 20 52 31 33 21 2c  7b 50 43 7d 5e 3a 5d 3a  |   R13!,{PC}^:]:|
00005cd0  3d 22 22 0d 03 e9 32 dd  20 a4 52 54 53 53 4e 45  |=""...2. .RTSSNE|
00005ce0  20 20 20 3a 5b 4f 50 54  70 61 73 73 3a 4c 44 4d  |   :[OPTpass:LDM|
00005cf0  4e 45 46 44 20 52 31 33  21 2c 7b 50 43 7d 5e 3a  |NEFD R13!,{PC}^:|
00005d00  5d 3a 3d 22 22 0d 03 ea  32 dd 20 a4 52 54 53 53  |]:=""...2. .RTSS|
00005d10  45 51 20 20 20 3a 5b 4f  50 54 70 61 73 73 3a 4c  |EQ   :[OPTpass:L|
00005d20  44 4d 45 51 46 44 20 52  31 33 21 2c 7b 50 43 7d  |DMEQFD R13!,{PC}|
00005d30  5e 3a 5d 3a 3d 22 22 0d  03 eb 32 dd 20 a4 52 54  |^:]:=""...2. .RT|
00005d40  53 53 43 43 20 20 20 3a  5b 4f 50 54 70 61 73 73  |SSCC   :[OPTpass|
00005d50  3a 4c 44 4d 43 43 46 44  20 52 31 33 21 2c 7b 50  |:LDMCCFD R13!,{P|
00005d60  43 7d 5e 3a 5d 3a 3d 22  22 0d 03 ec 32 dd 20 a4  |C}^:]:=""...2. .|
00005d70  52 54 53 53 43 53 20 20  20 3a 5b 4f 50 54 70 61  |RTSSCS   :[OPTpa|
00005d80  73 73 3a 4c 44 4d 43 53  46 44 20 52 31 33 21 2c  |ss:LDMCSFD R13!,|
00005d90  7b 50 43 7d 5e 3a 5d 3a  3d 22 22 0d 03 ed 43 dd  |{PC}^:]:=""...C.|
00005da0  20 a4 6d 65 6d 28 78 25  29 20 20 3a 77 25 3d 4f  | .mem(x%)  :w%=O|
00005db0  25 2d 63 6f 64 65 25 3a  50 25 3d 50 25 2b 78 25  |%-code%:P%=P%+x%|
00005dc0  3a 4f 25 3d 4f 25 2b 78  25 3a 5b 4f 50 54 70 61  |:O%=O%+x%:[OPTpa|
00005dd0  73 73 3a 41 4c 49 47 4e  3a 5d 3a 3d 77 25 0d 03  |ss:ALIGN:]:=w%..|
00005de0  ee 37 dd 20 a4 72 65 73  28 78 25 29 20 20 3a 50  |.7. .res(x%)  :P|
00005df0  25 3d 50 25 2b 78 25 3a  4f 25 3d 4f 25 2b 78 25  |%=P%+x%:O%=O%+x%|
00005e00  3a 5b 4f 50 54 70 61 73  73 3a 41 4c 49 47 4e 3a  |:[OPTpass:ALIGN:|
00005e10  5d 3a 3d 22 22 0d 03 ef  31 dd 20 a4 6e 65 77 6c  |]:=""...1. .newl|
00005e20  20 20 20 20 20 3a 5b 4f  50 54 70 61 73 73 3a 53  |     :[OPTpass:S|
00005e30  57 49 20 22 58 4f 53 5f  4e 65 77 4c 69 6e 65 22  |WI "XOS_NewLine"|
00005e40  3a 5d 3a 3d 22 22 0d 03  f0 04 0d 03 f1 3b dd 20  |:]:="".......;. |
00005e50  a4 64 61 74 65 20 20 20  20 20 20 de 20 64 61 74  |.date      . dat|
00005e60  65 25 20 36 34 3a 3f 64  61 74 65 25 3d 33 3a c8  |e% 64:?date%=3:.|
00005e70  99 20 22 4f 53 5f 57 6f  72 64 22 2c 26 30 45 2c  |. "OS_Word",&0E,|
00005e80  64 61 74 65 25 0d 03 f2  48 c8 99 20 22 4f 53 5f  |date%...H.. "OS_|
00005e90  43 6f 6e 76 65 72 74 44  61 74 65 41 6e 64 54 69  |ConvertDateAndTi|
00005ea0  6d 65 22 2c 64 61 74 65  25 2c 64 61 74 65 25 2b  |me",date%,date%+|
00005eb0  31 36 2c 33 32 2c 22 25  44 59 20 25 4d 33 20 31  |16,32,"%DY %M3 1|
00005ec0  39 25 59 52 22 20 b8 20  41 25 2c 42 25 0d 03 f3  |9%YR" . A%,B%...|
00005ed0  0f 3f 42 25 3d 31 33 3a  3d 24 41 25 0d 03 f4 04  |.?B%=13:=$A%....|
00005ee0  0d 03 f5 28 f4 20 54 68  69 73 20 6d 6f 64 75 6c  |...(. This modul|
00005ef0  65 73 20 77 6f 72 6b 73  70 61 63 65 20 69 73 20  |es workspace is |
00005f00  61 74 20 52 31 31 21 21  0d 03 f6 04 0d 03 f7 33  |at R11!!.......3|
00005f10  dd 20 a4 41 44 52 28 73  25 2c 78 25 29 20 20 3a  |. .ADR(s%,x%)  :|
00005f20  5b 4f 50 54 70 61 73 73  3a 41 44 44 20 20 20 73  |[OPTpass:ADD   s|
00005f30  25 2c 52 31 31 2c 23 78  25 3a 5d 3a 3d 22 22 0d  |%,R11,#x%:]:="".|
00005f40  03 f8 04 0d 03 f9 35 dd  20 a4 4c 44 52 28 73 25  |......5. .LDR(s%|
00005f50  2c 78 25 29 20 20 3a 5b  4f 50 54 70 61 73 73 3a  |,x%)  :[OPTpass:|
00005f60  4c 44 52 20 20 20 73 25  2c 5b 52 31 31 2c 23 78  |LDR   s%,[R11,#x|
00005f70  25 5d 3a 5d 3a 3d 22 22  0d 03 fa 35 dd 20 a4 4c  |%]:]:=""...5. .L|
00005f80  44 52 45 51 28 73 25 2c  78 25 29 3a 5b 4f 50 54  |DREQ(s%,x%):[OPT|
00005f90  70 61 73 73 3a 4c 44 52  45 51 20 73 25 2c 5b 52  |pass:LDREQ s%,[R|
00005fa0  31 31 2c 23 78 25 5d 3a  5d 3a 3d 22 22 0d 03 fb  |11,#x%]:]:=""...|
00005fb0  35 dd 20 a4 4c 44 52 4e  45 28 73 25 2c 78 25 29  |5. .LDRNE(s%,x%)|
00005fc0  3a 5b 4f 50 54 70 61 73  73 3a 4c 44 52 4e 45 20  |:[OPTpass:LDRNE |
00005fd0  73 25 2c 5b 52 31 31 2c  23 78 25 5d 3a 5d 3a 3d  |s%,[R11,#x%]:]:=|
00005fe0  22 22 0d 03 fc 35 dd 20  a4 4c 44 52 43 53 28 73  |""...5. .LDRCS(s|
00005ff0  25 2c 78 25 29 3a 5b 4f  50 54 70 61 73 73 3a 4c  |%,x%):[OPTpass:L|
00006000  44 52 43 53 20 73 25 2c  5b 52 31 31 2c 23 78 25  |DRCS s%,[R11,#x%|
00006010  5d 3a 5d 3a 3d 22 22 0d  03 fd 35 dd 20 a4 4c 44  |]:]:=""...5. .LD|
00006020  52 43 43 28 73 25 2c 78  25 29 3a 5b 4f 50 54 70  |RCC(s%,x%):[OPTp|
00006030  61 73 73 3a 4c 44 52 43  43 20 73 25 2c 5b 52 31  |ass:LDRCC s%,[R1|
00006040  31 2c 23 78 25 5d 3a 5d  3a 3d 22 22 0d 03 fe 04  |1,#x%]:]:=""....|
00006050  0d 03 ff 35 dd 20 a4 53  54 52 28 73 25 2c 78 25  |...5. .STR(s%,x%|
00006060  29 20 20 3a 5b 4f 50 54  70 61 73 73 3a 53 54 52  |)  :[OPTpass:STR|
00006070  20 20 20 73 25 2c 5b 52  31 31 2c 23 78 25 5d 3a  |   s%,[R11,#x%]:|
00006080  5d 3a 3d 22 22 0d 04 00  35 dd 20 a4 53 54 52 45  |]:=""...5. .STRE|
00006090  51 28 73 25 2c 78 25 29  3a 5b 4f 50 54 70 61 73  |Q(s%,x%):[OPTpas|
000060a0  73 3a 53 54 52 45 51 20  73 25 2c 5b 52 31 31 2c  |s:STREQ s%,[R11,|
000060b0  23 78 25 5d 3a 5d 3a 3d  22 22 0d 04 01 35 dd 20  |#x%]:]:=""...5. |
000060c0  a4 53 54 52 4e 45 28 73  25 2c 78 25 29 3a 5b 4f  |.STRNE(s%,x%):[O|
000060d0  50 54 70 61 73 73 3a 53  54 52 4e 45 20 73 25 2c  |PTpass:STRNE s%,|
000060e0  5b 52 31 31 2c 23 78 25  5d 3a 5d 3a 3d 22 22 0d  |[R11,#x%]:]:="".|
000060f0  04 02 35 dd 20 a4 53 54  52 56 53 28 73 25 2c 78  |..5. .STRVS(s%,x|
00006100  25 29 3a 5b 4f 50 54 70  61 73 73 3a 53 54 52 56  |%):[OPTpass:STRV|
00006110  53 20 73 25 2c 5b 52 31  31 2c 23 78 25 5d 3a 5d  |S s%,[R11,#x%]:]|
00006120  3a 3d 22 22 0d 04 03 04  0d 04 04 11 dd 20 a4 4d  |:=""......... .M|
00006130  4f 56 28 73 25 2c 78 25  29 0d 04 05 45 f4 20 70  |OV(s%,x%)...E. p|
00006140  65 72 66 6f 72 6d 20 4d  4f 56 20 73 25 2c 23 78  |erform MOV s%,#x|
00006150  25 20 6f 6e 20 73 65 63  6f 6e 64 20 70 61 73 73  |% on second pass|
00006160  20 6f 6e 6c 79 20 28 76  61 72 69 61 62 6c 65 20  | only (variable |
00006170  6d 61 79 20 6e 6f 74 20  65 78 69 73 74 29 0d 04  |may not exist)..|
00006180  06 15 e7 20 28 70 61 73  73 20 80 20 32 29 3c 3e  |... (pass . 2)<>|
00006190  30 20 8c 0d 04 07 1a 20  5b 4f 50 54 70 61 73 73  |0 ..... [OPTpass|
000061a0  3a 4d 4f 56 20 73 25 2c  23 78 25 3a 5d 0d 04 08  |:MOV s%,#x%:]...|
000061b0  05 cc 0d 04 09 19 20 5b  4f 50 54 70 61 73 73 3a  |...... [OPTpass:|
000061c0  4d 4f 56 20 73 25 2c 23  30 3a 5d 0d 04 0a 05 cd  |MOV s%,#0:].....|
000061d0  0d 04 0b 07 3d 22 22 0d  04 0c 04 0d 04 0d 11 dd  |....="".........|
000061e0  20 a4 54 45 51 28 73 25  2c 78 25 29 0d 04 0e 45  | .TEQ(s%,x%)...E|
000061f0  f4 20 70 65 72 66 6f 72  6d 20 54 45 51 20 73 25  |. perform TEQ s%|
00006200  2c 23 78 25 20 6f 6e 20  73 65 63 6f 6e 64 20 70  |,#x% on second p|
00006210  61 73 73 20 6f 6e 6c 79  20 28 76 61 72 69 61 62  |ass only (variab|
00006220  6c 65 20 6d 61 79 20 6e  6f 74 20 65 78 69 73 74  |le may not exist|
00006230  29 0d 04 0f 15 e7 20 28  70 61 73 73 20 80 20 32  |)..... (pass . 2|
00006240  29 3c 3e 30 20 8c 0d 04  10 1a 20 5b 4f 50 54 70  |)<>0 ..... [OPTp|
00006250  61 73 73 3a 54 45 51 20  73 25 2c 23 78 25 3a 5d  |ass:TEQ s%,#x%:]|
00006260  0d 04 11 05 cc 0d 04 12  19 20 5b 4f 50 54 70 61  |......... [OPTpa|
00006270  73 73 3a 54 45 51 20 73  25 2c 23 30 3a 5d 0d 04  |ss:TEQ s%,#0:]..|
00006280  13 05 cd 0d 04 14 07 3d  22 22 0d 04 15 04 0d 04  |.......=""......|
00006290  16 0c dd 20 f2 65 72 72  6f 72 0d 04 17 14 f6 3a  |... .error.....:|
000062a0  f1 22 20 61 74 20 6c 69  6e 65 20 22 3b 9e 0d 04  |." at line ";...|
000062b0  18 05 e0 0d 04 19 04 0d  04 1a 11 dd 20 a4 65 72  |............ .er|
000062c0  72 28 61 25 2c 54 24 29  0d 04 1b 41 5b 4f 50 54  |r(a%,T$)...A[OPT|
000062d0  70 61 73 73 3a 41 44 44  20 52 30 2c 50 43 2c 23  |pass:ADD R0,PC,#|
000062e0  30 3a 84 52 53 20 50 43  2c 52 31 34 2c 23 56 66  |0:.RS PC,R14,#Vf|
000062f0  6c 61 67 25 3a 45 51 55  44 20 61 25 3a a4 53 28  |lag%:EQUD a%:.S(|
00006300  54 24 29 3a 5d 3a 3d 22  22 0d 04 1c 04 0d 04 1d  |T$):]:="".......|
00006310  11 dd 20 a4 63 6f 6d 28  54 24 2c 61 25 29 0d 04  |.. .com(T$,a%)..|
00006320  1e 1d 5b 4f 50 54 70 61  73 73 3a 45 51 55 53 20  |..[OPTpass:EQUS |
00006330  54 24 3a 45 51 55 42 20  30 3a 5d 0d 04 1f 25 21  |T$:EQUB 0:]...%!|
00006340  4f 25 3d 30 20 20 20 20  20 3a f4 20 7a 65 72 6f  |O%=0     :. zero|
00006350  20 6e 65 78 74 20 66 6f  75 72 20 62 79 74 65 73  | next four bytes|
00006360  0d 04 20 20 5b 4f 50 54  70 61 73 73 3a 41 4c 49  |..  [OPTpass:ALI|
00006370  47 4e 3a 45 51 55 44 20  61 25 3a 5d 3a 3d 22 22  |GN:EQUD a%:]:=""|
00006380  0d 04 21 04 0d 04 22 45  f4 20 43 61 6c 6c 20 7a  |..!..."E. Call z|
00006390  61 70 20 61 74 20 65 6e  74 72 79 20 6f 66 66 73  |ap at entry offs|
000063a0  65 74 20 61 25 20 45 6e  74 72 79 20 52 30 2d 52  |et a% Entry R0-R|
000063b0  31 31 3d 61 72 67 73 20  52 31 32 3d 7a 61 70 20  |11=args R12=zap |
000063c0  77 6f 72 6b 73 70 61 63  65 0d 04 23 0f dd 20 a4  |workspace..#.. .|
000063d0  63 61 6c 6c 28 61 25 29  0d 04 24 0c 5b 4f 50 54  |call(a%)..$.[OPT|
000063e0  70 61 73 73 0d 04 25 3a  4c 44 52 20 52 31 34 2c  |pass..%:LDR R14,|
000063f0  5b 52 31 32 5d 20 20 20  20 20 20 20 20 20 20 20  |[R12]           |
00006400  20 20 20 20 20 20 5c 20  67 65 74 20 73 74 61 72  |      \ get star|
00006410  74 20 6f 66 20 7a 61 70  20 74 61 62 6c 65 0d 04  |t of zap table..|
00006420  26 36 41 44 44 20 52 31  34 2c 52 31 34 2c 23 61  |&6ADD R14,R14,#a|
00006430  25 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |%               |
00006440  5c 20 67 65 74 20 61 64  64 72 65 73 73 20 6f 66  |\ get address of|
00006450  20 73 75 62 0d 04 27 39  53 54 4d 46 44 20 52 31  | sub..'9STMFD R1|
00006460  33 21 2c 7b 52 31 34 7d  20 20 20 20 20 20 20 20  |3!,{R14}        |
00006470  20 20 20 20 20 20 5c 20  73 61 76 65 20 61 64 64  |      \ save add|
00006480  72 65 73 73 20 6f 6e 20  73 74 61 63 6b 0d 04 28  |ress on stack..(|
00006490  3f 4d 4f 56 20 52 31 34  2c 50 43 20 20 20 20 20  |?MOV R14,PC     |
000064a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 5c  |               \|
000064b0  20 72 65 74 75 72 6e 20  61 64 64 72 65 73 73 20  | return address |
000064c0  28 77 69 74 68 20 66 6c  61 67 73 29 0d 04 29 30  |(with flags)..)0|
000064d0  4c 44 4d 46 44 20 52 31  33 21 2c 7b 50 43 7d 20  |LDMFD R13!,{PC} |
000064e0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 5c 20  |              \ |
000064f0  63 61 6c 6c 20 74 68 65  20 73 75 62 0d 04 2a 09  |call the sub..*.|
00006500  5d 3a 3d 22 22 0d 04 2b  04 0d ff                 |]:=""..+...|
0000650b