<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">         nam   dEd OS-9 Disk Editor Version 2.06
         ttl   Copyright 1987 Doug DeMartinis
*******************************************************
* Copyright 1987 Doug DeMartinis; All Rights Reserved *
*                CIS:    72245,1400                   *
*                Delphi: DOUGLASD                     *
* Personal use and uploading of code, source and docs *
* to BBS's, as well as customization of the terminal  *
* display codes, is permitted only if the copyright   *
* notice and docs remain intact.                      *
*                                                     *
* 10/87 Various mods &amp; fixes by Bruce Isted (BRI)     *
* 11/87 Added Diddle, Find, Push, Remove routines.    *
*       Fixed bug throwing stack off by going in and  *
*        out of various error routines.               *
*                                                     *
*******************************************************
* Further provenance is unknown but there has been at *
* least some modifications by Marie-Louis Marcoux.    *
* The program now reports position in the allocation  *
* map and which sectors the bytes represent when      *
* editing the map. It appears to also contain the     *
* patches indicated below.                            *
* The Rev Ed is 2.05 which would be consistant with   *
* the Marcoux dEd on RTSI as dEd_Plus_1and2_Patch.lzh *
* but the CRC does not match. RG                      *
*******************************************************
*                                                     *
* Mods by Roger A. Krupski (HARDWAREHACK)             *
*                                                     *
* 02/88 -Added "enter" command which cleans up the    *
*        screen by running the REDO subroutine. (RAK) *
*                                                     *
* 01/90 -Added a check for the break key which allows *
*        aborting the &lt;F&gt;ind function. (RAK)          *
*       -Added a check for null filename in OUTFILE:  *
*        and bypass I$Create if so.                   *
*       -Other minor bugs fixed / errors trapped.     *
*******************************************************
* 06/01/11  Robert Gault                              *
*        Corrected BAM to sector calculation.         *
*        No attempt has been made to comment code.    *
*******************************************************
* 08/05/27  Robert Gault                              *
*        Corrected BAM presentation with drives having*
*        more than $##0000 sectors and/or DD.BIT &gt;1.  *
*        Converted all u and L addressing to normal   *
*        lables.                                      *
*        Added cluster/sector toggle.                 *
*******************************************************
* 11/09/20  Robert Gault                              *
*        Corrected BAM presentation in sector mode    *
*        when DD.BIT&gt;1.                               *
*******************************************************
* Disassembled 2006/01/10 00:57:52 by Disasm v1.5 (C) 1988 by RML and RG


         ifp1
         use   defsfile
         endc

tylg     set   Prgrm+Objct   
atrv     set   ReEnt+rev
rev      set   $02
top      mod   eom,name,tylg,atrv,start,size
inpath   rmb   1
outpath  rmb   1
lsn      rmb   3
oldlsn   rmb   3
offset   rmb   2
cursor   rmb   4
hexcol   rmb   1
rownum   rmb   1
asciicol rmb   1
lastflag rmb   1
buffptr  rmb   2
edbufptr rmb   2
edpos    rmb   1
hexascii rmb   1
zeroflag rmb   1
oldecho  rmb   1
echobyte rmb   1
Usave    rmb   2
Ssave    rmb   2
seclen   rmb   2
vmodlen  rmb   2
lmodlen  rmb   2
fileln   rmb   2
bytsread rmb   2
crc      rmb   3
modnmlen rmb   1
wrtflag  rmb   1
xprtflag rmb   1
FHexAsc  rmb   1   
TargLen  rmb   1 
findstr  rmb   17 
findptr  rmb   2
FBytes   rmb   1
HexBuff  rmb   4
FileLen  rmb   4
infile   rmb   30  linked module name
outfile  rmb   30  output filename
CrsrCnt  rmb   1
CrsrFlg  rmb   1
SgnlCode rmb   1
rawflg   rmb   1
clustflg rmb   1   flag for cluster/sector
ddmap    rmb   2
mappags  rmb   2   sectors per Allocation Map
ddbit    rmb   2   copy of DD.BIT
ddbitcalc rmb  2   calculation of sectors per map page
newBAM   rmb   3
nBAMstp  rmb   3
BAMstart rmb   3
BAMstop  rmb   3
u009D    rmb   8
StackCnt rmb   1
Stack    rmb   48
inbuff   rmb   256
i.o.buff rmb   320
size     equ   .
cls      fcb   $0C    clear screen
revvid   fcb   $1F,$20,0    reverse video on
normvid  fcb   $1F,$21,0    reverse video off
eraselin fcb   $04    erase from current character to end of line
erasescr fcb   $0B    erase from current character to end of screen
curon    fcb   $05,$21,0    turns on cursor
curoff   fcb   $05,$20,0    turns off cursor
name     equ   *
         fcs   /dEd/
         fcb   $06
         fcc   /Copyright 1987 Doug DeMartinis/
lsntitle fcs   /LSN=$/
sect     fcs   /SECTOR = $/
header   fcc   /      0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F/
         fcc   /    0 2 4 6 8 A C E /
         fcb   $0D 
command  fcs   /CMD: /
edprompt fcc   "&lt;BREAK&gt; toggles HEX/ASCII edit modes     "
         fcs   /&lt;ENTER&gt; exits edit mode/
zaprompt fcs   /Zap / 
byte     fcs   /byte: / 
char     fcs   /char: / 
sure     fcs   "Are you sure? (Y/N) " 
writing  fcs   /Writing sector.../
out$     fcs   /OUTFILE: / 
vrfymess fcs   /Verifying.../
verrmess fcs   /Verify aborted.../
shell$   fcs   /shell/
linkmess fcs   /Link to which module? / 
linkhdr  fcc   /Off  Len  Name/
         fcb   $0A
         fcc   /---- ---- ----/
         fcb   $0D 
modnmhdr fcs   /MODULE:  / 
offmess  fcs   /OFFSET: $/
xprtmess fcb   $1F,$24      blink on
         fcc   /- Expert Mode -/
         fcb   $1F,$25+$80      blink off
findbyte fcs   /Find byte string $/
findchar fcs   /Find char string: / 
srchmess fcs   /Searching.../
lenmess  fcs   /Current File Length $/
newmess  fcs   /New Length? $/
bootmess fcs   /** RESTART, Enter pathname: /
BAMmess1 fcs   /BAM: From Sector:$       to $       /
BAMmess2 fcs   /BAM: From Cluster:$       to $       /
BITmess  fcs   /Bits:/
bell     fcb   $07
fullmess fcs   /Sector Stack Full /  
helper   fcc   "   Up/Down Arrows  Read &amp; display Next/Previous sector"
         fcb   $0A
         fcc   / &lt;CR&gt; Clean up the screen display/
         fcb   $0A
         fcc   /   *  Restart/
         fcb   $0A
         fcc   "   !  Toggle BAM Cluster/Sector"
         fcb   $0A
         fcc   /   $  Fork a SHELL (Ctrl-BREAK to return)/
         fcb   $0A
         fcc   /   A  Append displayed sector to output file/
         fcb   $0A
         fcc   /   C  Close output file/ 
         fcb   $0A
         fcc   /   D  Diddle (adjust) file length/
         fcb   $0A
         fcc   /   E  Edit the displayed sector/
         fcb   $0A
         fcc   /   F  Find a byte or text string (BREAK aborts)/
         fcb   $0A
         fcc   /   H  Help screen (also use '?')/
         fcb   $0A
         fcc   /   L  Link to a module - List all modules/
         fcb   $0A
         fcc   /   N  Next occurrence of byte(s) or string (Find)/
         fcb   $0A
         fcc   /   O  Open a file for output (use with Append)/
         fcb   $0A
         fcc   /   P  Push current sector onto stack/
         fcb   $0A
         fcc   /   Q  Quit dEd - Exit to OS9/
         fcb   $0A
         fcc   /   R  Remove and display a sector from stack/
         fcb   $0A
         fcc   /   S  Skip to given sector (sector # in hex)/
         fcb   $0A
         fcc   /   U  Unlink from module/
         fcb   $0A
         fcc   /   V  Verify all modules in file/
         fcb   $0A
         fcc   /   W  Write the sector back to the disk/
         fcb   $0A
         fcc   "   X  eXpert mode toggle on/off"
         fcb   $0A
         fcc   /   Z  Zap (fill in) the sector displayed/
         fcb   $0A 
         fcb   $0A
         fcc   /      (Press any key to return to command prompt):/
helpchrs equ   *-helper
usemess  fcc   /Use:  dEd &lt;pathlist&gt;/
         fcb   $0D 
decimals fcb   $98,$96,$80 decimal 10,000,000 
         fcb   $0F,$42,$40 decimal  1,000,000 
         fcb   $01,$86,$A0 decimal    100,000 
         fcb   $00,$27,$10 decimal     10,000
         fcb   $00,$03,$E8 decimal      1,000
         fcb   $00,$00,$64 decimal        100
         fcb   $00,$00,$0A decimal         10
         fcb   $00,$00,$01 decimal          1
* Command jump table
commands fcb   $0C       up arrow
         fdb   nxtsec
         fcb   $0A       down arrow
         fdb   prevsec
         fcb   '*       
         fdb   restart   Restart program with new file/disk
         fcb   '!
         fdb   togCS     Toggle cluster/sector
         fcb   '$        shell
         fdb   goshell
         fcb   $0D       CR
         fdb   cReturn 
         fcb   's        LSN change
         fdb   changLSN 
         fcb   'z        Zap
         fdb   zap 
         fcb   'w        Write sector
         fdb   writesec 
         fcb   'o        Open output file
         fdb   openout 
         fcb   'a        Append to file
         fdb   append 
         fcb   'c        Close output file
         fdb   closeout
         fcb   'e        Edit sector
         fdb   edit 
         fcb   'q        Quit
         fdb   quit 
         fcb   'v        Verify
         fdb   verify
         fcb   'l        Link
         fdb   linker 
         fcb   'u        Unlink
         fdb   unlinker 
         fcb   'x        eXpert mode
         fdb   expert
         fcb   'h        help
         fdb   help 
         fcb   '?        help
         fdb   help
         fcb   'f        Find
         fdb   find     
         fcb   'n        Next find
         fdb   next 
         fcb   'd        Diddle length
         fdb   diddle
         fcb   'p        Push
         fdb   push 
         fcb   'r        Restore (Pop)
         fdb   restore
         fcb   $00

* Intercept signals
* modification by BRI 
icept    stb   SgnlCode,u
         rti
* end modification

restart  lds   &lt;Ssave
         ldu   &lt;Usave
         com   &lt;echobyte
         lbsr  echo
         lbsr  movecmd
         leax  bootmess,pcr
         lbsr  pstring
         lbsr  clrline
         leax  i.o.buff,u
         stx   &lt;inbuff
         ldy   #$50
         clra
         os9   I$ReadLn
         lbcs  error
         cmpy  #1
         bne   newdata
         clr   &lt;echobyte
         lbsr  echo
         lbra  getcmd
newdata  lda   &lt;inpath
         os9   I$Close
         bra   softstrt

start    equ   *
         stx   &lt;inbuff        pointer to param
         leax  &gt;icept,pcr     intercept routine addr
         os9   F$Icpt   
         lbcs  error
* Initialize data area
softstrt clra  
         ldb   #inbuff
         leax  ,u             point to data area
init     sta   ,x+            clear memory
         decb  
         bne   init
         com   clustflg       set default to show clusters
         stu   &lt;Usave
         sts   &lt;Ssave
         ldd   #$0002          cursor move code
         std   &lt;cursor         store it for output
         leas  &lt;-$20,s         make room for terminal options
         leax  ,s              point regX to temp buffer
         clra                  stdin path# 
         clrb                  SS.OPT
         os9   I$GetStt 
         lbcs  error
         lda   $04,x           get echo status byte
         sta   &lt;oldecho
         leas  &lt;$20,s          reset stack
* Open file
         ldx   &lt;inbuff         point to file name
         pshs  x
         clr   &lt;rawflg         raw disk edit open flag
opfLoop  lda   ,x+             find CR
         cmpa  #$0D
         beq   noraw           @ not found
         cmpa  #'@             open raw option
         bne   opfLoop
         com   &lt;rawflg         flag the option
noraw    puls  x
         lda   #$03            update mode
         os9   I$Open   
         bcc   openOK
         cmpb  #$D7         bad pathname
         lbeq  hints
         cmpb  #$D6         no permission
         lbne  bye          exit with error
         ldx   &lt;inbuff      point to file name
         lda   #$83         mode=Dir + Update
         os9   I$Open   
         lbcs  bye          exit with error
openOK   sta   &lt;inpath      path#
         ldb   #$02         ss.size
         os9   I$GetStt 
         stx   &lt;FileLen     msw of file size (in bytes?)
         stu   &lt;FileLen+2   lsw
         ldu   &lt;Usave
         clr   &lt;echobyte
         lbsr  echo         set no echo
         lbsr  clrscr       clear the screen
         tst   &lt;rawflg
         beq   readloop      go if not raw
         lbsr  seeksec       read LSN0 of disk
         ldx   &lt;buffptr      point regX to sector image
* Get DD.BIT RG
         ldd   6,x           get DD.BIT
         std   &lt;ddbit        save new data
         ldd   4,x           get DD.MAP
         std   &lt;ddmap        save copy
* Next line converts DD.MAP to base0 numbering.
* (DD.MAP-1)/$100+1=sectors in map. Original was DD.MAP/$100+1  RG
         subd  #1            needed to correctly convert DD.MAP to sectors in allocation, RG
         tfr   d,x
         ldd   #$100         bytes per sector of map
         lbsr  mul16B
         leax  1,x
         stx   &lt;mappags      pages in allocation map
readloop lbsr  seeksec
         sty   &lt;seclen       either $100 or number of bytes left in file
         ldd   &lt;lsn          get lsn just read
         std   &lt;oldlsn       
         lda   &lt;lsn+2
         sta   &lt;oldlsn+2
         ldd   #0            signal Next
         std   &lt;findptr
disploop lbsr  display       display the sector
getcmd   lbsr  movecmd       move cursor to
         leax  &gt;command,pcr  CMD:
         bsr   pstring
         leax  &gt;erasescr,pcr erase to end of string
         ldy   #$0001        era2chrs
         os9   I$Write  
         lbcs  error
         leax  &gt;i.o.buff,u   
         lbsr  read1         read one char
         lda   ,x
         cmpa  #'A           is it ascii?
         bcs   srchtabl      if not skip
         ora   #$20          upper -&gt; lower
srchtabl leax  &gt;commands,pcr point to command table
findcmd  cmpa  ,x+           found it?
         beq   gotcmd        go if yes
         leax  $02,x         else
         tst   ,x            end of table?
         bne   findcmd       loop
         bra   getcmd        invalid key
gotcmd   tst   &lt;xprtflag     using expert mode?
         beq   jmpcmd        no, then go
         tst   &lt;wrtflag      are we writing?
         beq   jmpcmd        n, then go
         pshs  x,a
         lbsr  xprtwrt       write sector
         puls  x,a
jmpcmd   ldd   ,x             get address offset
         leax  top,pcr        start of module
         jmp   d,x            jump to address
* Print string of characters in fcs mode
pstring  leay  &gt;i.o.buff,u
         clrb                 counter
xfer     incb  
         lda   ,x+           get shar
         bmi   lstchar       if bit7 set,go
         sta   ,y+           put in buffer
         bra   xfer
lstchar  anda  #$7F          clear bit7
         sta   ,y            put in buffer
         leax  &gt;i.o.buff,u   point to string
         clra  
         tfr   d,y           length of string to print
         bra   writeout
wrtlin1  ldy   #$78          #bufsiz 120 chars max
writeout lda   #$01          stdout
wrtlin2  os9   I$WritLn
         lbcs  error
         rts   
readlin3 ldy   #3            chars to read
readlin  clra                stdin
         os9   I$ReadLn      get 2 chars + CR
         lbcs  error
         rts   
movecmd  ldd   #$2036        #cmdpos
movecurs leax  cursor,u      cursor move code
         std   2,x           row/col
         ldy   #4            # chars
         bra   writeout

* Set reverse video code
revdisp  leax  &gt;revvid,pcr 
         ldy   #2            chars to write
         bra   writeout

* Set normal video code
normdisp leax  &gt;normvid,pcr
         ldy   #2            normchrs
         bra   writeout

clrline  leax  &gt;eraselin,pcr
         ldy   #1               
         bra   writeout     
  
clrscr   leax  &gt;cls,pcr
         ldy   #1            eraschrs
         bra   writeout

seeksec  bsr   lsnseek       seek to sector
         leax  &gt;inbuff,u
         stx   &lt;buffptr
         tst   &lt;infile       is module linked?
         beq   read256       on not linked
         ldd   &lt;lmodlen      get module length
         suba  &lt;lsn+2        are more than $100 bytes left?
         bne   read256       yes, then go
         tfr   d,y           no so setup smaller read
         bra   readsome
read256  ldy   #$100         256 bytes
readsome lda   &lt;inpath
         os9   I$Read
         lbcs  error
         rts   

******************************
* changed to ignore errors 01/09/90 (RAK)
*
read1    clra                stdin
         ldy   #1
         os9   I$Read
         rts
*********************** End of mod   
lsnseek  tst   &lt;infile       is module linked?
         bne   offchk        yes so go
         ldx   &lt;lsn
         lda   &lt;lsn+2
         clrb  
lsnseek1 tfr   d,u 
         lda   &lt;inpath
         os9   I$Seek   
         lbcs  error
         ldu   &lt;Usave
lsnrts   rts  
            
offchk   ldd   &lt;lmodlen     linked module length
         subd  #1           base0 on sector
         cmpa  &lt;lsn+2       reading past last sector?
         bcc   offseek      no then go
         ldb   #$D3         e$eof
         lbra  error
* If module is 'linked' add offset for good seek
offseek  ldd   &lt;offset
         adda  &lt;lsn+2
         ldx   #0
         bra   lsnseek1

display  ldd   #$2020
         lbsr  movecurs
         leax  &gt;lsntitle,pcr  
         lbsr  pstring
         bsr   clrline
         lbsr  convert3      hex to ascii for lsn
         leax  &gt;i.o.buff,u
         lbsr  wrtlin1
         tst   &lt;infile       link test
         beq   nolink
         lbsr  prntmod
nolink   tst   &lt;outpath      is an output path open
         beq   noout         no, then go
         lbsr  prntout       display name
noout    ldd   #$2022        hedrpos
         lbsr  movecurs
         leax  &gt;revvid,pcr   reverse video code
         ldy   #2            # of revchrs
         lbsr  wrtlin2
         leax  &gt;header,pcr
         lbsr  wrtlin1
         leax  &gt;normvid,pcr  normal video code
         ldy   #2            normchrs
         lbsr  wrtlin2
disp     lbsr  dsplylin
         lda   &lt;rownum       get row #
         adda  #$10          next row
         sta   &lt;rownum
         bne   disp          do 16 rows
         leax  &gt;inbuff,u
         stx   &lt;buffptr      reset buffer pointer
         tst   &lt;rawflg       edit flag
         beq   contin        if not raw
* New lines handle disks with $xx0000 sectors where xx&gt;00. RG
         tst   &lt;lsn         look at LSN msb
         bne   contin       we're not looking at the map if not $00
         ldd   &lt;lsn+1       get LSN lsw
         cmpd  #1           first page of map?
         bcs   contin       go if lsn0
         cmpd  &lt;mappags
         bhi   contin       lsnrts, go if not map
*        ldd   &lt;lsn+1       we don't need this as it already is loaded. RG
         subd  #1           setup to calc first sector
* Big error as it ignores DD.BIT  New lines added. RG
         ldx   #$800        8 bits/byte x $100 bytes per page if DD.BIT=1

         tst   clustflg
         bne   csf1         no calc if in cluster mode
         pshs  d            save LSN
         ldd   &lt;ddbit       sectors per bit
         lbsr  mulDbyX      mul regD * regX
         stu   &lt;ddbitcalc   sectors per page of allocation map, hope for no overflow
         tfr   u,x          !!!!!!!!!!!!!!!!!!!
         puls  d            recover LSN

csf1     lbsr  mulDbyX      mul regD*regX = value first sector on this page allocation map
         tfr   y,d              
         stb   &lt;newBAM      msb
         stu   &lt;newBAM+1    lsw
*        leau  &gt;$7FF,u  this assumes DD.BIT = 1

         tst   clustflg
         bne   csf2         no calc if in cluster mode
         pshs  d
         bsr   ddbitfix     calculate -sectors per map byte
         addd  &lt;ddbitcalc   regD = value of last bit on first allocation map page
         leau  d,u          add starting value of page
         puls  d
         bra   csf3
csf2     leau  $7ff,u      this is fixed in cluster mode
csf3     cmpu  &lt;FileLen+1  file length times $100
         bls   notshort
         cmpb  &lt;FileLen    file length times $100
         bcs   notshort
         ldu   &lt;FileLen+1
         tst   clustflg
         bne   csf4        no calc in cluster mode
         bsr   ddbitfix      calc -sectors per map byte
         leau  d,u
         bra   csf5
csf4     leau  -1,u        fixed in cluster mode

csf5     ldb   &lt;FileLen
notshort stb   &lt;nBAMstp
         stu   &lt;nBAMstp+1
         ldu   &lt;Usave
         ldx   &lt;newBAM
         ldb   &lt;newBAM+2
         stx   &lt;BAMstart
         stb   &lt;BAMstart+2
         ldx   &lt;nBAMstp
         ldb   &lt;nBAMstp+2
         stx   &lt;BAMstop
         stb   &lt;BAMstop+2
         lbsr  prntBAM
         bra   moredisp

ddbitfix clra             does a   neg(ddbit)
         clrb
         subd  &lt;ddbit
         rts
* End of BAM mod

* Continue the normal display.
contin   ldd   #$2034    clear BAM line
         lbsr  movecurs
         lbsr  clrline
moredisp tst   &lt;xprtflag
         lbeq  lsnrts     go if not expert
         ldd   #$5933     xprtpos
         lbsr  movecurs
         leax  &gt;xprtmess,pcr
         lbra  pstring
convert3 ldd   &lt;lsn
         com   &lt;zeroflag  to suppress leading zeros
         leay  &gt;i.o.buff,u
         bsr   convert1
         tfr   b,a       
         bsr   convert1
         clr   &lt;zeroflag  print leading zeros
         lda   &lt;lsn+2
         bsr   convert1
         ldd   #$2020     space space
         std   ,y++       move to buffer
         ldd   #8         8 decimal digits
         pshs  b,a
         com   &lt;zeroflag  suppress leading zeros
         leax  &gt;decimals,pcr  conversion table pointer
initsub1 clr   ,s
subdec1  ldd   &lt;lsn+1
         subd  $01,x      lsb from table
         pshs  cc         save carry
         std   &lt;lsn+1
         lda   &lt;lsn
         clrb             flag
         suba  ,x         -msb of lsn
         bcc   LSBorrow
         incb  
LSBorrow puls  cc
         bcc   savemsb
         suba  #$01
savemsb  sta   &lt;lsn
         bcc   chekenuf
         incb            set flag
chekenuf tstb            enough?
         bne   enufsub1  go if yes
         inc   ,s        
         bra   subdec1
enufsub1 ldd   &lt;lsn+1    get lsw
         addd  1,x       make it positive
         std   &lt;lsn+1    lsn+1
         lda   &lt;lsn
         bcc   addmsb
         inca            get the carry
addmsb   adda  ,x        make rest of remainder positive
         sta   &lt;lsn
         leax  3,x       point to next table entry
         bsr   decascii
         dec   $01,s     8 digits?
         beq   getCR     go if 8
         lda   1,s       get last two digits?
         cmpa  #2      
         bne   initsub1  if no then loop
         clr   &lt;zeroflag enable leading zeros
         bra   initsub1

getCR    lda   #$0D
         sta   ,y        put into out string
         ldd   &lt;oldlsn+1
         std   &lt;lsn+1
         lda   &lt;oldlsn
         sta   &lt;lsn
         puls  d,pc

* Convert hex byte in regA to ascii and put in buffer
convert1 pshs  a          hex to ascii
         lsra             shift msn to lsnibble
         lsra  
         lsra  
         lsra  
         bsr   objasc
         puls  a          recover byte
         anda  #$0F       mask off msnibble
         bsr   objasc
         rts   
objasc   cmpa  #$09       is a digit?
         ble   asciify
         adda  #$07       
asciify  adda  #$30       add '0
         sta   ,y+        put it into buffer
         tst   &lt;zeroflag
         beq   convdone   go if not
         cmpa  #'0              
         beq   suppres0   erase if yes
         clr   &lt;zeroflag  stop suppression
convdone rts
suppres0 leay  -$01,y
         rts   

* Convert decimal# on stack to ascii and add to buffer
decascii pshs  a
         lda   $03,s      get decimal counter
         bsr   asciify
         puls  pc,a

dsplylin leay  &gt;i.o.buff,u
         leax  &gt;revvid,pcr
         lbsr  transfer   reverse video code
         lda   &lt;seclen+1
         beq   notlast
         anda  #$F0       mask off lsn
         cmpa  &lt;rownum
         bne   notlast
         lda   #$FF
         sta   &lt;lastflag
notlast  lda   &lt;rownum
         bsr   convert1   make it hex
         lda   #':
         sta   ,y+
         leax  &gt;normvid,pcr
         bsr   transfer
         ldd   #$2020     2 spaces
         std   ,y++
         ldx   &lt;buffptr
         ldb   #$10       16 bytes
         tst   &lt;lastflag
         beq   cnvtbyt    go if not
         ldb   &lt;seclen+1
         andb  #$0F       regB= bytes for last line
         beq   noline
         pshs  b
cnvtbyt  lda   ,x+
         bsr   convert1
         lda   #$20       space
         sta   ,y+
         decb  
         bne   cnvtbyt
         tst   &lt;lastflag
         beq   addspc2
         ldd   #$310      regB=max bytes per line
         subb  ,s         regB=bytes to null out
         mul              3 spaces per byte
         lda   #$20       space
addspc1  sta   ,y+
         decb  
         bne   addspc1
addspc2  ldb   #$20
         std   ,y++
         sta   ,y+
         ldx   &lt;buffptr
         asrb             regB=15
         tst   &lt;lastflag
         beq   ascichar
         ldb   ,s
ascichar lda   ,x+
         anda  #$7F       clear bit7
         cmpa  #$20       32
         bcc   printabl
notascii lda   #$2E       notascii '.
printabl sta   ,y+
         decb  
         bne   ascichar
         stx   &lt;buffptr
         tst   &lt;lastflag
         beq   addCR
         ldb   #$10       max bytes per line
         subb  ,s+        regB=bytes to null
         lda   #$20       space
addspc3  sta   ,y+        put in buffer
         decb  
         bne   addspc3
         lda   #$F0       last row
         sta   &lt;rownum
         bsr   addCR      display line
resetlst clr   &lt;lastflag
         leax  &gt;erasescr,pcr   erase to end of screen code
         ldy   #1         era2chrs
         lbra  writeout
addCR    lda   #$0D       CR
         sta   ,y
         leax  &gt;i.o.buff,u
         lbra  wrtlin1

transfer lda   ,x+
         beq   trandone
         sta   ,y+
         bra   transfer
trandone rts

noline   lda   #$F0      signal last row
         sta   &lt;rownum
         bra   resetlst

* Point to net LSN in file
nxtsec  ldd   &lt;lsn+1     nxtsec
         addd  #1
         std   &lt;lsn+1
         bne   readsec
         inc   &lt;lsn
readsec  lbra  readloop

* Point to previous LSN unless at LSN0
prevsec  ldd   &lt;lsn+1
         bne   notfirst
         tst   &lt;lsn
         lbeq  getcmd
notfirst subd  #1
         std   &lt;lsn+1
         cmpd  #$FFFF       borrow if LSN was $xx0000
         bne   readsec
         dec   &lt;lsn
         bra   readsec

* Change LSN
changLSN lbsr  movecmd
         leax  sect,pcr
         lbsr  pstring
         ldy   #7
         bsr   MakeHex
         bcs   BadLSN
         ldd   &lt;HexBuff+2
         std   &lt;lsn+1
         lda   &lt;HexBuff+1
         sta   &lt;lsn
         lbra  readloop

BadLSN   lbsr  beep
         bra   changLSN

MakeHex  pshs  y           save # of bytes to read
         clr   &lt;echobyte
         com   &lt;echobyte
         lbsr  echo
         puls  y
         leax  &gt;i.o.buff,u
         lbsr  readlin
         clr   &lt;echobyte
         lbsr  echo
         leay  -$01,y
         beq   ExitHex
         tfr   y,d
CheckHex lda   ,x+
         bsr   hexdigit
         bcs   invalid
         decb  
         bne   CheckHex
         sty   &lt;HexBuff
getascii lda   #'0
         ldb   ,-x
         leay  -1,y
         beq   convrt2
         lda   ,-x
         leay  -1,y
convrt2  bsr   asciihex
         pshs  b
         cmpy  #0
         bne   getascii
         ldb   &lt;HexBuff+1
         incb              prep for badfind
         lsrb              # of hex bytes
         clra              leading 0
         leax  &lt;HexBuff,u
         cmpb  #4        four bytes on stack?
         beq   hexstack
         sta   ,x+
         cmpb  #3
         beq   hexstack
         sta   ,x+
         cmpb  #2
         beq   hexstack
         sta   ,x+
hexstack puls  a
         sta   ,x+
         decb  
         bne   hexstack
         clrb  
         rts   

invalid  lbsr  beep
ExitHex  leas  2,s
         lbra  readloop

hexdigit cmpa  #'0
         bcs   nothex
         cmpa  #'9
         bls   ishex
         anda  #$5F     lower to upper
         cmpa  #'F
         bhi   nothex
         cmpa  #'A
         bcs   nothex
ishex    clra  
         rts   
nothex   coma  
         rts  
 
asciihex bsr   hexnib
         pshs  b
         tfr   a,b
         bsr   hexnib
         lslb  
         lslb  
         lslb  
         lslb  
         orb   ,s+
         rts   

hexnib   subb  #$30
         cmpb  #9
         bls   nowhex
         andb  #$5F
         subb  #$07
nowhex   rts  
 
* Zap sector
zap      clr   &lt;echobyte
         com   &lt;echobyte
         lbsr  echo
         lbsr  movecmd
         lbsr  clrline
         leax  &gt;zaprompt,pcr
         lbsr  pstring
         tst   &lt;hexascii
         bne   zapascii
         leax  &gt;byte,pcr
         lbsr  pstring
         ldy   #3
         bsr   zapread
         bsr   hexobjct
         bcs   exitzap
zapstart leax  &gt;inbuff,u
         stx   &lt;buffptr
         clrb              counter
zapbuff  sta   ,x+
         decb  
         bne   zapbuff
         clr   &lt;echobyte
         lbsr  echo
         inc   &lt;wrtflag
         lbra  disploop

zapread  clra  
         leax  &gt;i.o.buff,u
         os9   I$ReadLn 
         bcs   cheksig1
         rts   
cheksig1 cmpb  #2           break key signal
         lbne  error
         com   &lt;hexascii
         leas  2,s
         bra   zap

exitzap  clr   &lt;echobyte
         lbsr  echo
         lbra  getcmd

zapascii leax  &gt;char,pcr
         lbsr  pstring
         ldy   #2
         bsr   zapread
         lda   ,x
         cmpa  #$20
         bcs   exitzap
         bra   zapstart

* Convert 2 hex chars in buffer (x) to object byte
hexobjct bsr   cnvrtnib
         bcs   badrts
         tfr   a,b
         bsr   cnvrtnib
         bcs   badrts
         lslb  
         lslb  
         lslb  
         lslb  
         pshs  b
         ora   ,s+
         bra   goodhex

cnvrtnib  bsr  isithex
         bcs   badrts
         bra   cnvrthex

isithex  lda   ,x+
         cmpa  #'0
         bcs   badhex
         cmpa  #'9
         bls   goodhex
         anda  #$5F        lower to upper
         cmpa  #'A
         bcs   badhex
         cmpa  #'F
         bhi   badhex
goodhex  andcc #$FE
         rts   
badhex   orcc  #1
badrts   rts   

cnvrthex suba  #$30
         cmpa  #9
         bls   nowobjct
         suba  #7
nowobjct bra   goodhex

* Write current sector back to disk
writesec tst   &lt;xprtflag    is expert mode on
         lbne  getcmd       yes, then go
         bsr   rusure       no, are you sure
         lbne  getcmd       Y or N
         lbsr  movecmd
         lbsr  clrline
         lbsr  movecmd
         leax  &gt;writing,pcr
         lbsr  pstring
xprtwrt  lbsr  lsnseek      seek to start of sector
         lda   &lt;inpath      path#
         lbsr  write100     write 256 bytes
         tst   &lt;xprtflag
         beq   opendone
         clr   &lt;wrtflag     clear auto-write
         rts   

* Ask  Are you sure?  And get response
rusure   lbsr  movecmd
rusure10 clr   &lt;echobyte
         com   &lt;echobyte
         lbsr  echo
         leax  &gt;sure,pcr
         lbsr  pstring
         lbsr  clrline
         leax  &gt;i.o.buff,u
         lbsr  read1
         clr   &lt;echobyte
         lbsr  echo
         lda   ,x
         anda  #$5F          lower to upper
         cmpa  #'Y
         rts   

* Open output file
openout  tst   &lt;outpath
         bne   opendone
         clr   &lt;echobyte
         com   &lt;echobyte
         lbsr  echo
         lbsr  movecmd
         leax  &gt;out$,pcr
         lbsr  pstring
         lbsr  clrline
         leax  &gt;i.o.buff,u
         ldy   #30            29 char + CR
         lbsr  readlin
         clr   &lt;echobyte
         lbsr  echo
***********************************************
* Return to command prompt if no filename given
* Added 01/09/90 (RAK)
*
         cmpy  #1
         beq   opendone
********************************** END modification
         pshs  x
         leay  &lt;outfile,u
savname  lda   ,x+          get name
         sta   ,y+
         cmpa  #$20         space
         bhi   savname
         lda   #$0D         CR
         sta   -1,y         delimit
         puls  x
         lda   #2           write
         ldb   #$0B         attributes read+write
         os9   I$Create 
         bcs   error
         sta   &lt;outpath
         bsr   prntout
opendone lbra  getcmd

* move cursor &amp; print 'Outout pathlist'
prntout  ldd   #$3021       out position
         lbsr  movecurs
         leax  &gt;out$,pcr
         lbsr  pstring
         leax  &lt;outfile,u
         lbra  wrtlin1

* Write out a sector
write100 leax  &gt;inbuff,u
         ldy   &lt;seclen
         os9   I$Write  
         bcs   error
         rts   

* Close output file
closeout lda   &lt;outpath
         beq   opendone
         os9   I$Close  
         bcs   error
         ldd   #$3021
         lbsr  movecurs
         lbsr  clrline
         clr   &lt;outpath
closed   bra   opendone

* Append sector to output file
append   lda   &lt;outpath
         beq   closed
         bsr   write100
         lbra  nxtsec

* main error routine
error    pshs  b
* modification by BRI
         clr   &lt;SgnlCode
* end modification
         ldd   &lt;oldlsn
         std   &lt;lsn
         lda   &lt;oldlsn+2
         sta   &lt;lsn+2
         puls  b
         lds   &lt;Ssave
         cmpb  #2             break
         beq   error2
         cmpb  #3             shift break
         bne   eofchk
         clr   &lt;wrtflag
         bra   error2
eofchk   cmpb  #$D3
         bne   truerr
error2   lbra  exitzap

truerr   cmpb  #$CD          bad module ID
         bne   othererr
* If module is linked, BMID error must come from trying to Verify modules
* use standard error reporting routine. Otherwise BMID error occurs when
* trying to link (or list names of) modules; need to clear screen after these.
         tst   &lt;infile       module linked?
         bne   othererr      yes, use standard error
         bsr   prterr        display error #
         leax  &gt;cls,pcr
         ldy   #1
         lbsr  writeout
         lbra  disploop
othererr pshs  b
         lbsr  movecmd
         lbsr  clrline
         puls  b
         bsr   prterr
         lbra  getcmd

* display error #
prterr   lda   #$02            error path
         os9   F$PErr   
         clr   &lt;echobyte
         lbsr  echo
         leax  &gt;i.o.buff,u
         lbra  read1

* use with   ded   and no path list
hints    lda   #2              Now this is used
         leax  &gt;usemess,pcr
         ldy   #$78
         lbsr  wrtlin2
         clrb  
         bra   bye

* Exit to OS-9
quit     lbsr  rusure
         lbne  getcmd
         lbsr  clrscr
         lda   &lt;oldecho
         sta   &lt;echobyte
         lbsr  echo
         clrb  
bye      os9   F$Exit   

* Edit sector
edit     lbsr  movecmd
         leax  &gt;edprompt,pcr
         lbsr  pstring
topleft  leax  &gt;inbuff,u
         stx   &lt;edbufptr
         lda   #1
         sta   &lt;edpos
         lda   #$23            top row code
         sta   &lt;rownum
         lda   #$25            hex dump col#
         sta   &lt;hexcol
         lda   #$58            ascii dump col#
         sta   &lt;asciicol
revbyte  lbsr  revdisp
         lbsr  eddisply
edinput  lda   &lt;hexcol
         ldb   &lt;rownum
         tst   &lt;hexascii
         beq   hexin
         lda   &lt;asciicol
hexin    tst   &lt;rawflg   
         lbeq  edcont
         ldx   &lt;lsn+1
         cmpx  #$0001
         lbcs  edcont         not BAM
         cmpx  &lt;mappags
         lbhi  edcont         not BAM
         pshs  b,a
         ldx   &lt;newBAM
         ldb   &lt;newBAM+2
         stx   &lt;BAMstart
         stb   &lt;BAMstart+2
         ldx   &lt;nBAMstp
         ldb   &lt;nBAMstp+2
         stx   &lt;BAMstop
         stb   &lt;BAMstop+2
         clra                calc byte to cluster
         ldb   &lt;rownum
         subb  #$23
         lda   #$10
         mul   
         pshs  b,a
         clra  
         ldb   &lt;hexcol
         subb  #$25
         beq   hexin2
         tfr   d,x
         ldd   #$0003
         lbsr  mul16B
         tfr   x,d
hexin2   addd  ,s++
         ldx   &lt;lsn+1
         cmpx  &lt;mappags
         bcs   hexin3        edit inside of BAM range
         pshs  b,a
         ldd   &lt;ddmap
         clra  
         tfr   d,x
         puls  b,a
         leax  -$01,x
         pshs  x
         cmpd  ,s++
         bhi   hexin4       edit outside of BAM range
hexin3   ldx   #$0008
         tst   clustflg     using clusters or sectors
         bne   csf6         go if clusters
         pshs  d
         ldd   ddbit
         lbsr  mulDbyX
         tfr   u,x
         puls  d
csf6     lbsr  mulDbyX
         tfr   u,d
         addd  &lt;BAMstart+1
         std   &lt;BAMstart+1
         tst   clustflg
         bne   csf7        go if cluster mode
         pshs  d
         ldx   #7
         ldd   ddbit
         lbsr  mulDbyX
         tfr   u,d
         addd  ,s++
         bra   csf8
csf7     addd  #$0007      fixed if clusters
csf8     cmpd  &lt;nBAMstp+1
         bls   hexin5
         ldd   &lt;nBAMstp+1
hexin5   std   &lt;BAMstop+1
         bra   hexin6
hexin4   clr   &lt;BAMstop
         clr   &lt;BAMstop+1
         clr   &lt;BAMstop+2
hexin6   ldu   &lt;Usave
         lbsr  normdisp
         tst   &lt;BAMstop+2
         bne   prtbmess
         tst   &lt;BAMstop+1
         bne   prtbmess
         tst   &lt;BAMstop
         bne   prtbmess
         ldd   #$2034
         lbsr  movecurs
         lbsr  clrline
         bra   hexin7
prtbmess lbsr  prntBAM
         ldd   #$4934
         lbsr  movecurs
         leax  &gt;BITmess,pcr  Bits:
         lbsr  pstring
         leax  &gt;u009D,u
         lda   [&lt;edbufptr,u]
         ldb   #8
         pshs  x,a
bmess2   lsl   ,s
         bcs   bmess3
         lda   #'0
         bra   bmess4
bmess3   lda   #'1
bmess4   sta   ,x+
         decb  
         bne   bmess2
         puls  x,a
         ldy   #8
         lbsr  writeout
hexin7   lbsr  revdisp
         puls  b,a
************ End of BAM mod
edcont   lbsr  movecurs
         leax  &gt;i.o.buff,u
         tst   &lt;hexascii     test for hex/ascii mode
         lbne  inputchr
* modification by BRI
* bra inputbyt
         lbra  inputbyt
* end mod
eddisply lda   &lt;hexcol
         ldb   &lt;rownum
         lbsr  movecurs
         leay  &gt;i.o.buff,u
         lda   [&lt;edbufptr,u]
         pshs  a
         lbsr  convert1
         leax  -2,y
         ldy   #2
         lda   #1
         lbsr  wrtlin2
         lda   &lt;asciicol
         ldb   &lt;rownum
         lbsr  movecurs
         puls  a
         anda  #$7F
         cmpa  #$20
         bcc   prntabl1
         lda   #$2E
prntabl1 leax  &gt;i.o.buff,u
         sta   ,x
         ldy   #1
         lbra  writeout

* read in char, check for break key
* modification by BRI
* toggles cursor on/off if enabled, checks for character
*readit ldy #1 1 char
readit   pshs  x,b
CFlash1  clra  
         ldb   #1
         os9   I$GetStt 
         bcc   CFExit
         cmpb  #$F6           not ready
         bne   CrsrErr
         ldx   #1
         os9   F$Sleep  
         bcs   CrsrErr
         dec   &lt;CrsrCnt
         lda   &lt;CrsrCnt
         eora  &lt;CrsrFlg
         anda  #$40           keep active counter bit
         beq   SigChk
         com   &lt;CrsrFlg
         beq   CrsrOff
         bsr   CrsrOn
         bra   SigChk
CrsrOff  leax  &gt;curoff,pcr
         ldy   #2
         bsr   WritCrsr
SigChk   ldb   &lt;SgnlCode
         cmpb  #2               abort code
         beq   CrsrErr
         cmpb  #$03             shift break
         bne   CFlash1
CrsrErr  stb   ,s
         bsr   CrsrOn
         puls  x,b
         bra   cheksig2
CrsrOn   leax  &gt;curon,pcr
         ldy   #2           cursor on number of bytes
WritCrsr lda   #1
         os9   I$Write  
         clrb  
         rts   
CFExit   bsr   CrsrOn
         puls  x,b
         ldy   #1
* end of mod
         clra  
         os9   I$Read   
         bcs   cheksig2
         rts  
 
* modification by BRI
* clears old signal, traps BREAK,
* cleans up before reporting other errors
* (fixes shift-BREAK/control-BREAK in edit mode and
* error report stack clean up bugs)
* cheksig2 cmpb #2 BREAK key signal?
* lbne error no, process error
* com hexascii yes, toggle hex/ascii flag
* leas 2,s pull return addr off stack
* bra edinput loop back
cheksig2 leas  $02,s
         clr   &lt;SgnlCode
         cmpb  #2              break key
         beq   TrapSgnl
         pshs  b
         lbsr  reset
         clr   &lt;rownum
         puls  b
         lbra  error
TrapSgnl com   &lt;hexascii
         lbra  edinput
* end of mod

* input a hex byte
inputbyt bsr   readit
         bsr   digit
         bcs   edcurs
         lbsr  writeout
         ldb   ,x
* modification by BRI
* bsr readit read another char
         lbsr  readit
* end modification
         bsr   digit
         bcs   edcurs
         exg   a,b
         lbsr  asciihex
         stb   [&lt;edbufptr,u]
         lda   #1
         sta   &lt;wrtflag
         bra   movert

* Check to see if char is valid hex digit.
* Exit with Carry set if not valid.
digit    lda   ,x
         cmpa  #'0
         bcs   notdig
         cmpa  #'9
         bls   gotdig
         anda  #$5F        lower to upper
         cmpa  #'F
         bhi   notdig
         cmpa  #'A
         bcs   notdig
gotdig   andcc #$FE
         rts   
notdig   orcc  #1
         rts   

* Input single ASCII character

* modification by BRI
*inputchr bsr readit read char
inputchr lbsr  readit
* end of mod
         lda   ,x
         cmpa  #$20
         bcs   edcurs
         sta   [&lt;edbufptr,u]
         lda   #1
         sta   &lt;wrtflag
         bra   movert

* check if char is an arrow
edcurs   cmpa  #9              right arrow
         beq   movert
         cmpa  #8              left arrow
         beq   movelt
         cmpa  #$0C            up arrow
         lbeq  moveup
         cmpa  #$0A            down arrow
         lbeq  movedn
         cmpa  #$0D            CR
         lbne  edinput
* exit edit routine
         lbsr  reset
         ldd   #$4934
         lbsr  movecurs
         lbsr  clrline
         clr   &lt;rownum
         lbra  getcmd

* move to next screen byte
movert   lbsr  reset
         tst   &lt;seclen+1
         beq   rtptr
         lda   &lt;edpos
         cmpa  &lt;seclen+1
         lbeq  topleft
rtptr    ldd   &lt;edbufptr
         addd  #1
         std   &lt;edbufptr
         inc   &lt;edpos
displyrt inc   &lt;asciicol     
         lda   &lt;asciicol
         cmpa  #$68          end of row
         bcc   rowdn
         lda   &lt;hexcol
         adda  #3            3 columns used per byte
         sta   &lt;hexcol
         lbra  revbyte
rowdn    inc   &lt;rownum
         lda   &lt;rownum
         cmpa  #$32
         lbhi  topleft
         lda   #$25
         sta   &lt;hexcol
         lda   #$58
         sta   &lt;asciicol
         lbra  revbyte

* move to previous byte
movelt   bsr   reset
         ldd   &lt;edbufptr
         subd  #1
         std   &lt;edbufptr
         dec   &lt;edpos
         dec   &lt;asciicol
         lda   &lt;asciicol
         cmpa  #$58
         bcs   rowup
         lda   &lt;hexcol
         suba  #3
         sta   &lt;hexcol
         lbra  revbyte
rowup    dec   &lt;rownum
         lda   #$52
         sta   &lt;hexcol
         lda   #$67
         sta   &lt;asciicol
         lda   &lt;rownum
         cmpa  #$23
         bcs   gobot
         lbra  revbyte
gobot    ldx   &lt;edbufptr
         ldb   &lt;seclen+1
         beq   botptr
         stb   &lt;edpos
         clra  
         leax  d,x
         decb  
         pshs  b
         lsrb  
         lsrb  
         lsrb  
         lsrb  
         addb  #$23
         stb   &lt;rownum
         lda   ,s+
         anda  #$0F
         pshs  a
         adda  #$58
         sta   &lt;asciicol
         puls  a
         ldb   #3
         mul   
         addb  #$25
         stb   &lt;hexcol
         bra   savebot
botptr   lda   #$32         bottom row
         sta   &lt;rownum
         leax  $100,x
savebot  stx   &lt;edbufptr
         lbra  revbyte

* reset from reverse video to normal
reset    lbsr  normdisp
         lbra  eddisply

* move up a row
moveup   bsr   reset
         ldb   &lt;seclen+1
         beq   moveup1
         lda   &lt;rownum
         cmpa  #$23
         beq   moveup2
moveup1  ldd   &lt;edbufptr
         subd  #$10
         std   &lt;edbufptr
         ldb   &lt;edpos
         subb  #$10
         stb   &lt;edpos
         dec   &lt;rownum
         lda   &lt;rownum
         cmpa  #$23
         bcc   updone
         lda   #$32
         sta   &lt;rownum
         ldd   &lt;edbufptr
         addd  #$100
         std   &lt;edbufptr
updone   lbra  revbyte

moveup2  andb  #$F0
         lda   &lt;seclen+1
         anda  #$0F
         cmpa  &lt;edpos
         bcc   moveup3
         subb  #$10
moveup3  clra  
         pshs  b,a
         ldd   &lt;edbufptr
         addd  ,s+
         std   &lt;edbufptr
         ldb   &lt;edpos
         addb  ,s
         stb   &lt;edpos
         puls  b
         lsrb  
         lsrb  
         lsrb  
         lsrb  
         addb  #$23
         stb   &lt;rownum
         bra   updone

movedn   bsr   reset
         ldb   &lt;seclen+1
         beq   movedn1
         subb  &lt;edpos
         cmpb  #$10
         bcs   movedn2
movedn1  ldd   &lt;edbufptr
         addd  #$0010
         std   &lt;edbufptr
         lda   &lt;edpos
         adda  #$10
         sta   &lt;edpos
         inc   &lt;rownum
         lda   &lt;rownum
         cmpa  #$32
         lbls  revbyte
         ldd   &lt;edbufptr
         subd  #$100
         std   &lt;edbufptr
topptr   lda   #$23
         sta   &lt;rownum
         lbra  revbyte
movedn2  clra  
         ldb   &lt;edpos
         decb  
         andb  #$F0
         pshs  b,a
         ldd   &lt;edbufptr
         subd  ,s+
         std   &lt;edbufptr
         ldb   &lt;edpos
         subb  ,s+
         stb   &lt;edpos
         bra   topptr

* start a temporary shell
goshell  lbsr  clrscr
         lda   &lt;oldecho
         sta   &lt;echobyte
         bsr   echo
         leax  &gt;shell$,pcr
         ldy   #$10
         leau  &gt;i.o.buff,u
         lda   #$0D
         sta   ,u
         ldd   #0
         os9   F$Fork   
         lbcs  error
         os9   F$Wait   
         ldu   &lt;Usave
         leax  &gt;inbuff,u
         stx   &lt;buffptr
         clr   &lt;echobyte
         bsr   echo
cReturn  lbsr  clrscr
         lbra  disploop

* read in option section of path and toggle echo
echo     pshs  x
         leas  &lt;-$20,s
         leax  ,s
         clra  
         clrb  
         os9   I$GetStt 
         lbcs  error
         lda   &lt;echobyte
         sta   $04,x
         clra  
         os9   I$SetStt 
         lbcs  error
         leas  &lt;$20,s
         puls  pc,x

* verify CRC if valid module
verify   lbsr  movecmd
         leax  &gt;vrfymess,pcr
         lbsr  pstring
         ldu   #0
         ldx   #0
         stx   &lt;fileln
         lda   &lt;inpath
         os9   I$Seek   
         lbcs  error
         ldu   &lt;Usave
initCRC  ldd   #$FFFF
         std   &lt;crc
         stb   &lt;crc+2
         leax  &gt;i.o.buff,u
         ldy   #8
         lda   &lt;inpath
         os9   I$Read   
         lbcs  error
         cmpy  #8
         lbne  verr
         ldd   ,x
         cmpa  #$87         module sync byte
         lbne  verr
         cmpb  #$CD         ""
         lbne  verr
         ldd   2,x
         cmpd  #$0F         minimum module length
         lbls  verr
         subd  #3           omit old CRC
         std   &lt;vmodlen
         addd  &lt;fileln
         std   &lt;fileln
* check header parity
         clra  
         ldb   #8
hedpar   eora  ,x+
         decb  
         bne   hedpar
         coma  
         sta   ,x
         ldy   #1
         lda   &lt;inpath
         os9   I$Write  
         lbcs  error
         ldd   &lt;vmodlen
         subd  #9
         std   &lt;vmodlen
         leax  &gt;i.o.buff,u
         ldy   #9
         bsr   CRCcal
bytsleft lda   &lt;inpath
         ldy   #$78
         cmpy  &lt;vmodlen
         bls   readmod
         ldy   &lt;vmodlen
readmod  os9   I$Read   
         bcs   verr
         sty   &lt;bytsread
         bsr   CRCcal
         ldd   &lt;vmodlen
         subd  &lt;bytsread
         std   &lt;vmodlen
         bne   bytsleft
* compare current position with header to 
* prevent overwriting next module
         lda   &lt;inpath
         ldb   #5
         os9   I$GetStt 
         tfr   u,d
         ldu   &lt;Usave
         cmpd  &lt;fileln
         bne   verr
         com   &lt;crc
         com   &lt;crc+1
         com   &lt;crc+2
         leax  &lt;crc,u
         ldy   #3
         lda   &lt;inpath
         os9   I$Write  
         lbcs  error
         ldd   #3
         addd  &lt;fileln
         std   &lt;fileln
         ldb   #6             test for EOF
         lda   &lt;inpath
         os9   I$GetStt 
         lbcc  initCRC
         cmpb  #$D3           EOF
         lbne  error
* redisplay LSN
         lbsr  seeksec
         lbra  disploop

* calculate CRC, regY=# of bytes to use for CRC
CRCcal   leau  &lt;crc,u
         os9   F$CRC    
         lbcs  error
         ldu   &lt;Usave
         rts   

* error with verify
verr     ldd   #$2036         cmd position
         lbsr  movecurs
         leax  &gt;verrmess,pcr
         lbsr  pstring
         ldb   #$CD
         lbsr  prterr
         lbra  getcmd

* Link to a module or display all in merged file
linker    tst   &lt;infile
         lbne  getcmd
         ldd   #0
         std   &lt;fileln
         std   &lt;lmodlen
         clr   &lt;echobyte
         com   &lt;echobyte
         lbsr  echo
         lbsr  movecmd
         lbsr  clrline
         leax  &gt;linkmess,pcr
         lbsr  pstring
         leax  &lt;infile,u
         ldy   #$1E
         lbsr  readlin
         clr   &lt;echobyte
         lbsr  echo
         cmpy  #1
         lbne  parsmod
         lbsr  clrscr
         clr   &lt;infile            list all module names
         leax  &gt;linkhdr,pcr
         lbsr  wrtlin1
nxtmod   ldd   &lt;lmodlen
         addd  &lt;fileln
         std   &lt;fileln
         tfr   d,u
         ldx   #0
         lda   &lt;inpath
         os9   I$Seek   
         bcs   moderr
         ldu   &lt;Usave
         leax  &gt;i.o.buff,u
         ldy   #6
         os9   I$Read   
         bcs   moderr
         ldd   ,x++
         cmpa  #$87
         bne   moderr1
         cmpb  #$CD
         bne   moderr1
         leay  &gt;i.o.buff,u
         ldd   ,x++
         std   &lt;lmodlen
         ldd   ,x++
         pshs  d
         ldd   &lt;fileln
         bsr   convert2
         lda   #$20
         sta   ,y+
         ldd   &lt;lmodlen
         bsr   convert2
         lda   #$20
         sta   ,y+
         ldd   &lt;fileln
         addd  ,s++
         tfr   d,u
         ldx   #0
         lda   &lt;inpath
         os9   I$Seek   
         lbcs  error
         ldu   &lt;Usave
         tfr   y,x
         ldy   #$1D
         lda   &lt;inpath
         os9   I$Read   
         lbcs  error
namend   lda   ,x+
         bpl   namend
         anda  #$7F            look for fcs delimiter
         sta   -1,x
         lda   #$0D            CR
         sta   ,x
         leax  &gt;i.o.buff,u
         lbsr  wrtlin1
         bra   nxtmod

convert2 lbsr  convert1
         tfr   b,a
         lbra  convert1

moderr2  cmpb  #$D3           e$e0f
         bne   moderr
         ldb   #$DD           module not found
         bra   moderr
moderr1  ldb   #$CD           bad module ID
moderr   clr   &lt;infile
         cmpb  #$D3           end of file
         lbne  error
         lbsr  read1
         leax  &gt;inbuff,u
         stx   &lt;buffptr
         lbra  cReturn

parsmod  os9   F$PrsNam 
         lbcs  error
         stb   &lt;modnmlen
         decb  
         lda   b,x
         ora   #$80           fcs format
         sta   b,x
         stx   &lt;crc
         ldu   #0
modloop  ldx   #0
         lda   &lt;inpath
         os9   I$Seek   
         lbcs  error
         ldu   &lt;Usave
         leax  &gt;i.o.buff,u
         ldy   #6
         os9   I$Read   
         bcs   moderr2
         ldd   ,x++
         cmpa  #$87           module sync code
         bne   moderr1
         cmpb  #$CD           ""
         bne   moderr1
         ldd   ,x++
         std   &lt;lmodlen
         ldd   ,x
         addd  &lt;fileln
         tfr   d,u
         ldx   #0
         lda   &lt;inpath
         os9   I$Seek   
         bcs   moderr2
         ldu   &lt;Usave
         leax  &gt;i.o.buff,u
         ldy   #$1D
         os9   I$Read   
         bcs   moderr2
         tfr   x,y
         ldx   &lt;crc
         ldb   &lt;modnmlen
         os9   F$CmpNam 
         bcc   newbase
         ldd   &lt;lmodlen
         addd  &lt;fileln
         std   &lt;fileln
         tfr   d,u
         bra   modloop

* set offset to module so effective LSN is $00
newbase  lda   #$0D           CR
         sta   b,x            delimit name
         decb  
         lda   b,x            last character
         anda  #$7F           clear marker
         sta   b,x
         ldd   &lt;fileln
         std   &lt;offset
         ldd   #6
         leax  lsn,u
nbloop   sta   ,x+
         decb  
         bne   nbloop
         lbra  readloop

* display module name and offset
prntmod  ldd   #$3020               mod position
         lbsr  movecurs
         leax  &gt;modnmhdr,pcr
         lbsr  pstring
         leax  &lt;infile,u
         lbsr  wrtlin1
         ldd   #$5820               offset position
         lbsr  movecurs
         leax  &gt;offmess,pcr
         lbsr  pstring
         leay  &gt;i.o.buff,u
         ldd   &lt;offset
         lbsr  convert2
         lda   #$0D                 CR
         sta   ,y
         lbra  writeout

* unlink module and restore LSN to that of file
unlinker tst   &lt;infile
         lbeq  getcmd
         ldd   #8
         leax  lsn,u
unloop   sta   ,x+
         decb  
         bne   unloop
         ldd   #$3020           mod position
         lbsr  movecurs
         lbsr  clrline
         lbsr  clrline
         clr   &lt;infile
         lbra  readloop

* toggle expert mode - edits and zaps are auto-written
expert   tst   &lt;xprtflag
         beq   xprton           turn flag on if not on
         clr   &lt;xprtflag
         ldd   #$5933           expert position
         lbsr  movecurs
         lbsr  clrline
xprtout  lbra  getcmd
xprton   lbsr  rusure
         bne   xprtout
         com   &lt;xprtflag
         ldd   #$5933            expert position
         lbsr  movecurs
         leax  &gt;xprtmess,pcr     display EXPERT
         lbsr  pstring
         bra   xprtout

help     lbsr  clrscr
         leax  &gt;helper,pcr
         ldy   #helpchrs
         lbsr  wrtlin2
         leax  &gt;i.o.buff,u
         lbsr  read1
         lbra  cReturn

find     clr   &lt;echobyte
         com   &lt;echobyte
         lbsr  echo
         lbsr  movecmd
         lbsr  clrline
         tst   &lt;FhexAsc       hex or ascii mode?
         bne   charfind       go if ascii
         leax  &gt;findbyte,pcr
         lbsr  pstring
         ldy   #$21
         lbsr  FRead
         cmpy  #1
         lbeq  exitfind
         leay  -1,y
         tfr   y,d
         lsrb  
         lbcs  badfind
         stb   &lt;TargLen
         leau  &lt;findstr,u
* convert 2 bytes pointed to by regX, store in regA
FConvert lbsr  hexobjct
         lbcs  badfind
         sta   ,u+
         leay  -2,y
         bne   FConvert
         ldu   &lt;Usave
         bra   gofind

* input string of ascii chars
charfind leax  &gt;findchar,pcr
         lbsr  pstring
         ldy   #$11
         lbsr  FRead
         cmpy  #1
         lbeq  exitfind
         tfr   y,d
         decb                 dump CR
         stb   &lt;TargLen
         leay  &lt;findstr,u
find20   lda   ,x+
         sta   ,y+
         decb  
         bne   find20

* Check if byte from target string matches byte in buffer by EOR'ing the two.
*  If they match exactly, result is 0. If in 'char' search mode, EOR results
*  in bits 5 and/or 7 being set if 2 bytes differ only by case or bit 7 status

*****************************
* Added 01/08/90 (RAK)
*
*        clr   echobyte   echo off
*        lbsr  echo      
*
* END of modification
*****************************
gofind   clr   &lt;echobyte
         lbsr  echo
         leax  &gt;inbuff,u
find30   ldb   &lt;seclen+1
         leay  &lt;findstr,u
find50   lda   ,y
         eora  ,x+
         lbeq  found1
         tst   &lt;FHexAsc
         beq   find60
         bita  #$5F      %01011111
         lbeq  found1
find60   decb  
find70   bne   find50    no match in this sector
* Modification (addition) by RAK 01/08/90
* Read a character from std in to catch a break
* key which allows aborting a &lt;F&gt;IND.
* Note: "finderr2" resets the stack.
         pshs  y,x,b,a
         clra  
         ldb   #1        SS.Ready
         os9   I$GetStt 
         bcs   NoKey
         leax  &gt;i.o.buff,u
         lbsr  read1
         lda   ,x
         cmpa  #5         catch key to abort find
         beq   finderr2
NoKey    puls  y,x,b,a
* end of mod
         bsr   FNxtSec
         bra   find30

FNxtSec  tst   &lt;infile
         beq   find75
         ldd   &lt;lmodlen
         subd  #1
         cmpa  &lt;lsn+2
         beq   finderr2
find75   ldd   &lt;lsn+1
         addd  #1
         std   &lt;lsn+1
         bne   find80
         inc   &lt;lsn
find80   lbsr  lsnseek
         leax  &gt;inbuff,u
         stx   &lt;buffptr
         tst   &lt;infile
         beq   find256
         ldd   &lt;lmodlen
         suba  &lt;lsn+2
         bne   find256
         tfr   d,y
         bra   FRdSome
find256  ldy   #$100
FRdSome  lda   &lt;inpath
         os9   I$Read   
         bcs   finderr
         sty   &lt;seclen
         rts 

* Get byte/char to find  
FRead    leax  &gt;i.o.buff,u
         clra  
         os9   I$ReadLn 
         bcs   cheksig3
         rts   
cheksig3 leas  2,s
         clr   &lt;SgnlCode
         cmpb  #2          break key?
         lbne  error
         com   &lt;FHexAsc
         lbra  find
badfind  ldu   &lt;Usave
         bsr   beep
         lbra  find

* make a beep
beep     leax  &gt;bell,pcr
         ldy   #1
         lbra  writeout

* If error reading next sector was EOF, then find was unsuccessful.
* Re-read original sector and return to CMD: prompt
finderr  cmpb  #$D3         EOF
         lbne  error
finderr2 lds   &lt;Ssave
         ldd   &lt;oldlsn
         std   &lt;lsn
         lda   &lt;oldlsn+2
         sta   &lt;lsn+2
         lbsr  seeksec
         sty   &lt;seclen
         bsr   beep
exitfind lbra  exitzap

found1   pshs  b
         decb  
         stb   &lt;Fbytes
* Save pointer (X) to next byte in buffer for search to resume if this search
*  is unsuccessful or for 'Next' command
         stx   &lt;findptr
         ldb   &lt;TargLen
find90   decb  
         beq   matched
         dec   ,s
         beq   find130
find100  leay  1,y
         lda   ,y
         eora  ,x+
         beq   find90
         tst   &lt;FHexAsc
         beq   find110
         bita  #$5F
         beq   find90
find110  leas  1,s
* Restore buffer pointer (X) to byte after 1st byte found that matched in
* search just completed (unsuccessfully). Restore B to # bytes left in 
* sector at that point. Y = start of target string.
         ldx   &lt;findptr
find120  leay  &lt;findstr,u
         ldb   &lt;FBytes
         lbra  find70
* Read in next sector to complete test for match
find130  leas  1,s
         pshs  y,b
         lbsr  FNxtSec
         puls  y,b
         lda   &lt;seclen+1
         pshs  a
         bra   find100

* Successful Find
*  Must determine whether target string starts in last LSN read or
*  next-to-last, for display
matched  leas  1,s
         lda   &lt;lsn+2
         cmpa  &lt;oldlsn+2
         beq   match40
         cmpx  &lt;findptr
         bcc   match30
         ldd   &lt;lsn+1
         subd  #1
         std   &lt;lsn+1
         cmpd  #$FFFF
         bne   match20
         dec   &lt;lsn
match20  lbsr  seeksec
         sty   &lt;seclen
match30  ldd   &lt;lsn
         std   &lt;oldlsn
         lda   &lt;lsn+2
         sta   &lt;oldlsn+2
match40  lbsr  display
* Get offset of found string from beginning of LSN
         ldd   &lt;findptr
         subd  #1
         std   &lt;edbufptr
         subd  &lt;buffptr
* Now LS nib of B = col #, MS nib = row # for display
         pshs  b
         andb  #$0F
         pshs  b
         addb  #$58
         stb   &lt;asciicol
         puls  b
         lda   #$03
         mul   
         addb  #$25
         stb   &lt;hexcol
         puls  b
         andb  #$F0
         lsrb  
         lsrb  
         lsrb  
         lsrb  
         addb  #$23
         stb   &lt;rownum
         lbsr  revdisp
         lbsr  eddisply
         lbsr  normdisp
         clr   &lt;rownum
*** This line changed from 'lbra getcmd' in Version 2.0 ***
         lbra  exitfind

* Next Search starts from Find unless LSN changed
next     tst   &lt;TargLen
         lbeq  getcmd
         lbsr  movecmd
         leax  &gt;srchmess,pcr
         lbsr  pstring
         ldx   &lt;findptr
         lbeq  gofind
         lbra  find120

* Display/change file size
diddle   lbsr  movecmd
         leax  &gt;lenmess,pcr
         lbsr  pstring
         com   &lt;zeroflag
         leay  &gt;i.o.buff,u
         ldd   &lt;FileLen
         lbsr  convert1        nibble to ascii
         tfr   b,a
         lbsr  convert1        second nibble
         ldd   &lt;FileLen+2
         lbsr  convert1        third nibble
         clr   &lt;zeroflag
         tfr   b,a
         lbsr  convert1
         ldd   #$2020
         std   ,y++
         std   ,y++
         leax  &gt;i.o.buff,u
         stx   &lt;bytsread
         tfr   y,d
         subd  &lt;bytsread       chars to display
         tfr   d,y
         lbsr  writeout
         leax  &gt;newmess,pcr
         lbsr  pstring
         ldy   #9
         lbsr  MakeHex
         bcs   diddle
         ldd   #$2037         command1 position
         lbsr  movecurs
         lbsr  rusure10
         lbne  getcmd
         ldx   &lt;HexBuff
         ldu   &lt;HexBuff+2
         ldb   #2             size
         lda   &lt;inpath
         os9   I$SetStt 
         lbcs  error
         stx   &lt;FileLen
         stu   &lt;FileLen+2
         ldu   &lt;Usave
* Make sure LSN displayed is still within file (in case file shortened).
* If not, reset display to show last LSN with new file length.
         lda   &lt;FileLen
         cmpa  &lt;lsn
         bcs   RstLSN
         bne   diddled
         ldd   &lt;FileLen+1
         cmpd  &lt;lsn+1
         bls   RstLSN10
diddled  lbra  readloop

RstLSN   sta   &lt;lsn
         ldd   &lt;FileLen+1
RstLSN10 tst   &lt;FileLen+3
         bne   RstLSN20
         subd  #1
RstLSN20 std   &lt;lsn+1
         cmpd  #$FFFF
         bne   diddled
         dec   &lt;lsn
         bra   diddled

push    lda   &lt;StackCnt
         cmpa  #$10
         bcc   full
         ldb   #$03
         mul   
         leax  &gt;Stack,u
         leax  b,x
         ldd   &lt;lsn
         std   ,x++
         lda   &lt;lsn+2
         sta   ,x
* Now that LSN is on stack, check to make sure it isn't the last one
* pushed, as well. If so, don't increment StackCnt, which effectively
* cancels the Push operation.
         tst   &lt;StackCnt
         beq   pushOK
         cmpa  -$03,x
         bne   pushOK
         ldd   &lt;lsn
         cmpa  -5,x
         beq   pushed
pushOK   inc   &lt;StackCnt
pushed   lbra  getcmd

* Stack is full - display message
full     lbsr  movecmd
         leax  &gt;bell,pcr
         lbsr  pstring   full message
         lbsr  read1
         bra   pushed

restore  lda   &lt;StackCnt
         beq   pushed
         ldb   #3
         mul   
         subb  #3
         leax  &gt;Stack,u
         leax  b,x
         ldd   ,x++
         std   &lt;lsn
         lda   ,x
         sta   &lt;lsn+2
         dec   &lt;StackCnt
         lbra  readloop

* This is a general purpose 16x16 bit multiplication.
* regD is first number, regX is second number.
* Returns answer in regY and regU.
mulDbyX    pshs  u,y,x,b,a
         clr   4,s
         lda   3,s     lower word of regX times regB
         mul   
         std   6,s
         ldd   1,s     upper word of regX times regB
         mul   
         addb  6,s
         adca  #$00
         std   5,s
         ldb   ,s      original regA
         lda   3,s     upper word regX
         mul   
         addd  5,s
         std   5,s
         bcc   mulDX2  L171D
         inc   4,s
mulDX2   lda   ,s
         ldb   2,s
         mul   
         addd  4,s
         std   4,s
         puls  pc,u,y,x,b,a

* Looks like 16*regX
mul16B   pshs  x,b,a
         lda   #$10
         pshs  a
         clra  
         clrb  
mul16B2  lsl   4,s
         rol   3,s
         rolb  
         rola  
         cmpd  1,s
         bcs   mul16B3
         subd  1,s
         inc   4,s
mul16B3  dec   ,s
         bne   mul16B2
         ldx   3,s
         leas  5,s
         rts   

prntBAM  ldd   #$2034
         lbsr  movecurs
         tst   clustflg
         bne   csf9
         leax  BAMmess1,pcr
         bra   csf10
csf9     leax  BAMmess2,pcr
csf10    lbsr  pstring
         leay  &gt;i.o.buff,u
         pshs  y
         ldd   &lt;BAMstart      get 3 byte address and display it
         lbsr  convert1       convert hex to ascii
         tfr   b,a
         lbsr  convert1       convert hex to ascii
         lda   &lt;BAMstart+2
         lbsr  convert1       convert hex to ascii
         lda   ,-y
         ora   #$80
         sta   ,y
         ldd   #$3234
         lbsr  movecurs
         ldx   ,s
         lbsr  pstring
         ldy   ,s
         ldd   &lt;BAMstop
         lbsr  convert1
         tfr   b,a
         lbsr  convert1
         lda   &lt;BAMstop+2
         lbsr  convert1
         lda   ,-y
         ora   #$80
         sta   ,y
         ldd   #$3D34
         lbsr  movecurs
         puls  x
         lbsr  pstring
         rts   

togCS    com   &lt;clustflg
         lbra  cReturn

         emod
eom      equ   *

         end
</pre></body></html>