changeset 965:53553cdc265c

New commands added to standard CMDS
author boisy
date Fri, 31 Jan 2003 17:49:58 +0000
parents 4f56e6891d94
children 5747fa790c2e
files level2/cmds/dmem.asm level2/cmds/makefile level2/cmds/mmap.asm level2/cmds/pmap.asm level2/cmds/proc.asm level2/cmds/reboot.asm level2/cmds/smap.asm
diffstat 7 files changed, 1871 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level2/cmds/dmem.asm	Fri Jan 31 17:49:58 2003 +0000
@@ -0,0 +1,141 @@
+********************************************************************
+* DMem - Dump memory from system
+*
+* $Id$
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* 2      Written by Kevin Darling
+
+         nam   DMem
+         ttl   Dump memory from system
+
+* Disassembled 98/09/14 19:24:59 by Disasm v1.6 (C) 1988 by RML
+
+         ifp1
+         use   defsfile
+         endc
+
+tylg     set   Prgrm+Objct   
+atrv     set   ReEnt+rev
+rev      set   $01
+edition  set   2
+
+         mod   eom,name,tylg,atrv,start,size
+
+u0000    rmb   1
+u0001    rmb   1
+u0002    rmb   1
+u0003    rmb   2
+u0005    rmb   3
+u0008    rmb   64
+u0048    rmb   1
+u0049    rmb   447
+u0208    rmb   4296
+size     equ   .
+
+name     fcs   /DMem/
+         fcb   edition
+
+L0012    clr   <u0000
+         clr   <u0001
+L0016    lda   ,x+
+         cmpa  #C$SPAC
+         beq   L0046
+         cmpa  #C$CR
+         beq   L0046
+         suba  #$30
+         cmpa  #$0A
+         bcs   L002A
+         anda  #$07
+         adda  #$09
+L002A    lsla
+         lsla
+         lsla
+         lsla
+         sta   <u0002
+         ldd   <u0000
+         rol   <u0002
+         rolb
+         rola
+         rol   <u0002
+         rolb
+         rola
+         rol   <u0002
+         rolb
+         rola
+         rol   <u0002
+         rolb
+         rola
+         std   <u0000
+         bra   L0016
+L0046    leax  -1,x
+         ldd   <u0000
+         rts
+
+start    lbsr  L0128
+         lbeq  L0119
+         cmpa  #'-
+         bne   L006D
+         leax  1,x
+         bsr   L0012
+         tfr   b,a
+         pshs  x
+         leax  >u0008,u
+         os9   F$GPrDsc 
+         lbcs  L00BC
+         puls  x
+         bra   L0073
+L006D    bsr   L0012
+         clr   <u0048
+         stb   <u0049
+L0073    lbsr  L0128
+         lbeq  L0119
+         lbsr  L0012
+         std   <u0003
+         lbsr  L0128
+         beq   L0092
+         lbsr  L0012
+         cmpd  #$1000
+         bls   L0095
+         ldd   #$1000
+         bra   L0095
+L0092    ldd   #$0100
+L0095    std   <u0005
+         leax  >u0048,u
+         tfr   x,d
+         ldy   <u0005
+         ldx   <u0003
+         pshs  u
+         leau  >u0208,u
+         os9   F$CpyMem 
+         puls  u
+         bcs   L00BC
+         ldy   <u0005
+         leax  >u0208,u
+         lda   #$01
+         os9   I$Write  
+L00BB    clrb  
+L00BC    os9   F$Exit   
+
+HelpTxt  fcc   "Use: DMem <block> <offset> [<length>] ! dump"
+         fcb   C$LF
+         fcc   " or: DMem -<id>   <offset> [<length>] ! dump"
+         fcb   C$CR
+HelpTxtL equ   *-HelpTxt
+
+L0119    leax  >HelpTxt,pcr
+L011D    ldy   #HelpTxtL
+         lda   #$02
+         os9   I$WritLn 
+         bra   L00BB
+L0128    lda   ,x+
+         cmpa  #C$SPAC
+         beq   L0128
+         leax  -1,x
+         cmpa  #C$CR
+         rts   
+
+         emod
+eom      equ   *
+         end
--- a/level2/cmds/makefile	Fri Jan 31 17:40:46 2003 +0000
+++ b/level2/cmds/makefile	Fri Jan 31 17:49:58 2003 +0000
@@ -3,11 +3,12 @@
 DEPENDS		= ./Makefile
 
 CMDS		= asm attr backup binex build cmp cobbler copy cputype \
-		date dcheck debug deiniz del deldir devs dir disasm display \
-		dmode dsave dump echo edit error exbin exmode format \
-		free grfdrv help ident iniz irqs link list load login makdir \
-		mdir merge mfree modpatch montype os9gen procs pwd pxd rename \
-		runb save setime shell_21 shellplus sleep tee tmode touch \
+		date dcheck debug deiniz del deldir devs dir dirm disasm \
+		display dmem dmode dsave dump echo edit error exbin exmode \
+		format free grfdrv help ident iniz irqs link list load login \
+		makdir mdir merge mfree mmap modpatch montype os9gen proc \
+		procs pwd pxd reboot rename runb save setime shell_21 \
+		shellplus sleep smap tee tmode touch \
 		tsmon unlink verify wcreate xmode
 SUBS            = gfx2 gfx inkey syscall
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level2/cmds/mmap.asm	Fri Jan 31 17:49:58 2003 +0000
@@ -0,0 +1,287 @@
+********************************************************************
+* MMap - Show memory block map
+*
+* $Id$
+*
+* From Kevin Darling, "Inside OS9 Level II"
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* ?      Original verison                               KKD 88/??/??
+* 4      Modified by Ken Drexler fr various block sizes KD  89/07/30
+
+         nam   MMap
+         ttl   Memory Block Utility
+
+         ifp1  
+         use   defsfile
+         endc  
+
+Revs     set   ReEnt+1
+Type     set   Prgrm+Objct
+edition  set   4
+
+         mod   prglen,name,type,revs,MMap,datsiz
+
+Name     fcs   /MMap/
+         fcb   edition
+
+***************************************************
+*
+* Data
+*
+buffsiz  set   512
+
+numflag  rmb   1          flag for leading zeros
+rowcnt   rmb   1          no rows to print
+free     rmb   1          no free blocks
+rowno    rmb   1          row number
+lcnt     rmb   1          line length counter
+outptr   rmb   2          output pointer
+out      rmb   80         output buffer
+mapsiz   rmb   2          size of map block
+blksiz   rmb   2          block size
+buffer   rmb   buffsiz    map itself
+stack    rmb   200
+datsiz   equ   .
+
+         pag   
+***************************************************
+*
+*  Messages
+*
+header   fcc   /     0 1 2 3 4 5 6 7 8 9 A B C D E F/
+         fcb   C$CR
+hdrlen   equ   *-header
+
+hdr2     fcc   /  #  = = = = = = = = = = = = = = = =/
+         fcb   C$CR
+hdrlen2  equ   *-hdr2
+
+BlockMsg fcc   /  Block Size: /
+blklen   equ   *-Blockmsg
+
+Freemsg  fcc   / Free Blocks: /
+freelen  equ   *-Freemsg
+
+Rammsg   fcc   / KBytes Free: /
+ramlen   equ   *-Rammsg
+
+**********************************************
+*
+MMap     lbsr  pcrtn      print line
+         leax  header,pcr print headers
+         lda   #1
+         ldy   #hdrlen
+         os9   I$WritLn
+         leax  hdr2,pcr
+         ldy   #hdrlen2
+         os9   I$WritLn
+         leax  buffer,u   get block map to read
+         os9   F$GBlkMp
+         lbcs  error
+         std   blksiz     save block size
+         sty   mapsiz     save map size
+         clr   free
+         clr   rowno
+         ldd   mapsiz     compute number of rows
+         lsra             at 16 per row
+         rorb  
+         lsra  
+         rorb  
+         lsra  
+         rorb  
+         lsra  
+         rorb  
+         stb   rowcnt     save count
+         leax  out,u
+         stx   outptr
+         leax  buffer,u   point at map
+         pshs  x
+         bra   loop2
+
+loop     dec   lcnt       count -= 1
+         bne   loop3      if more, skip line print
+
+* print line, start next line
+loop1    pshs  x          save map pointer
+         lbsr  prline     print line
+         dec   rowcnt     done?
+         beq   exit       yes
+loop2    lda   #16        set line length count
+         sta   lcnt
+         lbsr  Space      1 space
+         lda   rowno      print row number
+         lbsr  Hex1
+         inc   rowno      row number += 1
+         lbsr  space2     2 spaces
+         puls  x
+
+* Print one block status
+loop3    ldb   ,x+        get next block
+         beq   freeram
+         bmi   noram
+         bitb  #2         module?
+         bne   module
+         lda   #'U        must be ram in use
+         bra   put
+
+freeram  lda   #'_        not used
+         inc   free       count it
+         bra   put
+
+module   lda   #'M        module
+         bra   put
+
+noram    lda   #'.        not ram
+
+* Print character in A and space
+put      equ   *
+         lbsr  print      put character in output buffer
+         lda   #C$SPAC    add space
+         lbsr  print
+
+         bra   loop
+
+* Add summary messages
+Exit     equ   *
+         leax  BlockMsg,pcr print "Block Size"
+         ldy   #blklen
+         lbsr  Prstr
+         ldd   blksiz
+         clr   numflag    suppress zeros
+         bsr   outdec
+         lbsr  prline     print line
+         leax  freemsg,pcr print "Free Blocks"
+         ldy   #freelen
+         lbsr  Prstr
+         ldb   free       get number of blocks
+         clra  
+         clr   numflag    suppress zeros
+         bsr   outdec     print in decimal
+         bsr   prline
+         leax  rammsg,pcr print "Ram Free"
+         ldy   #ramlen
+         lbsr  Prstr
+         ldb   free       get number of blocks
+         lda   blksiz     get #k/block
+         lsra             by dividing msb by 4
+         lsra  
+         mul   
+         clr   numflag    suppress zeros
+         bsr   outdec     print in decimal
+         bsr   prline
+
+bye      clrb             no errors
+
+error    os9   F$Exit
+
+
+**********************************************
+*
+* Subroutines
+*
+Pcrtn    pshs  a,x        Output carriage return
+         lda   #C$CR
+         sta   out
+         leax  out,u      point at buffer
+         ldy   #1         one char.
+         lda   #1
+         os9   I$WritLn
+         puls  a,x,pc
+
+
+** Decimal output routine
+*  IN:  D - number to output
+*       X - destination buffer
+* OUT:  X,Y,U preserved
+*
+Outdec   pshs  b,x,y,u
+         ldx   outptr     get pointer
+         leau  <dectbl,pcr
+         ldy   #5         set counter
+
+Outdec1  clr   ,s         clear workspace
+
+Outdec2  subd  ,u         subtract power of ten
+         bcs   outdec3
+         inc   ,s
+         bra   outdec2
+
+outdec3  addd  ,u++       add back one power
+         pshs  b          save b
+         ldb   1,s
+         addb  #'0        convert to ascii
+         cmpb  #'0        zero?
+         bne   outdec4    no, print it
+         tst   numflag    suppress zero?
+         beq   outdec5    yes
+outdec4  inc   numflag
+         stb   ,x+        put in buffer
+outdec5  puls  b          restore b
+         leay  -1,y       counter -= 1
+         bne   outdec1
+         stx   outptr     update pointer
+         puls  b,x,y,u,pc
+
+Dectbl   fdb   10000
+         fdb   1000
+         fdb   100
+         fdb   10
+         fdb   1
+
+
+* Print Line
+Prline   ldx   outptr     now print line
+         lda   #C$CR
+         sta   ,x         terminate line
+         leax  out,u
+         ldy   #80
+         lda   #1
+         os9   I$Writln
+         bcs   error
+         leax  out,u      set pointer
+         stx   outptr
+         rts   
+
+
+* Print Spaces
+Space2   bsr   Space
+
+Space    lda   #C$SPAC
+         bra   Print
+
+* Print Hexidecimal Digit in A
+Hex1     tfr   a,b
+         lsra  
+         lsra  
+         lsra  
+         lsra  
+         bsr   outhex
+         tfr   b,a
+Outhex   anda  #$0f
+         cmpa  #$0a       0 - 9
+         bcs   outdig
+         adda  #$07       A - F
+outdig   adda  #'0        make ASCII
+print    pshs  X
+         ldx   outptr
+         sta   ,X+
+         stx   outptr
+         puls  x,pc
+
+
+* Print string to output buffer
+*  IN:  X - string pointer
+*       Y - string length
+*
+Prstr    equ   *
+         lda   ,x+        get character
+         bsr   print      put in buffer
+         leay  -1,y
+         bne   Prstr
+         rts   
+
+         emod  
+Prglen   equ   *
+         end   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level2/cmds/pmap.asm	Fri Jan 31 17:49:58 2003 +0000
@@ -0,0 +1,310 @@
+********************************************************************
+* PMap - Show process map information
+*
+* $Id$
+*
+* From "Inside Level II" by Kevin Darling
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* ?      Original version                               KKD 87/02/08
+* 2      Revised to handle 4K or 8K blocks              KD  89/09/12
+
+         nam   PMap
+         ttl   Show process map information
+
+         ifp1  
+         use   defsfile
+         endc  
+
+Type     set   Prgrm+Objct
+Revs     set   ReEnt+1
+Bufsiz   set   512
+edition  set   2
+
+stdout   set   1
+maxnam   set   30
+
+         pag   
+***************************************************
+*
+         mod   PrgSiz,Name,Type,Revs,Entry,DatSiz
+
+Name     fcs   /PMap/
+         fcb   edition
+
+* Data Equates
+umem     rmb   2
+sysImg   rmb   2          pointer to sysprc datimg
+datimg   rmb   2          datimg for copymem
+lineptr  rmb   2
+number   rmb   3
+leadflag rmb   1
+pid      rmb   1
+hdr      rmb   12
+blkcnt   rmb   1          no. blocks/64k
+outbuf   rmb   80
+buffer   rmb   bufsiz*2   working proc. desc.
+stack    rmb   200
+datsiz   equ   .
+
+*************************************************
+*
+* Messages
+*
+Head1A   fcc   / ID   01 23 45 67 89 AB CD EF  Program    /
+         fcb   C$CR
+
+Head2A   fcc   /____  __ __ __ __ __ __ __ __  ___________/
+Hdrcr    fcb   C$CR
+
+Head1B   fcc   / ID   0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F   Program/
+         fcb   C$CR
+
+Head2B   fcc   /____  __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __  _______/
+         fcb   C$CR
+
+SysNam   fcs   "SYSTEM"
+syslen   equ   *-Sysnam
+
+         spc   3
+***************************************************
+*
+Entry    stu   Umem
+         lda   #1         start with process 1
+         clr   Pid
+
+* Print header
+         leax  buffer,u   point at storage
+         os9   F$GBlkMp   get block info
+         bcs   Error
+         cmpd  #8192      8k?
+         beq   Set8k
+         cmpd  #4096      4k?
+         beq   Set4k
+         bra   Error      we only do 4k/8k
+
+Set8k    lda   #64/8
+         bra   Entry1
+
+Set4k    lda   #64/4
+Entry1   sta   blkcnt     save size
+         leax  Hdrcr,pcr  print line
+         lbsr  PrintL1    print it
+         lda   blkcnt
+         cmpa  #64/4      4k?
+         beq   Headr4
+Headr8   leax  Head1A,pcr
+         lbsr  PrintL1    print it
+         leax  Head2A,pcr
+         bra   Head41
+
+Headr4   leax  Head1B,pcr
+         lbsr  PrintL1
+         leax  Head2B,pcr
+Head41   lbsr  PrintL1
+
+* Main Program Loop
+Main     ldu   umem
+         leax  OutBuf,U   set line pointer
+         stx   Lineptr
+         inc   Pid        next process
+         beq   Bye        >= 255 --> exit
+         lda   Pid        get proc id
+         leax  Buffer,U   set destination
+         os9   F$GPrDsc
+         bcs   Main       loop if no descriptor
+         bsr   Output     print data for descriptor
+         bra   Main
+
+Bye      clrb  
+Error    os9   F$Exit
+
+* Subroutines
+
+Output   lda   P$ID,X     process id
+         lbsr  Outdecl
+         lbsr  Space
+         lbsr  Space
+
+* Print Process DAT Image
+*  IN:  x = process descriptor
+*
+         pshs  X
+         leax  P$DATImg,x point to DAT image
+         ldb   blkcnt     set count
+         pshs  b
+
+PrntImg  ldd   ,x++       get DAT block
+         cmpd  #$00FC     empty?
+         bne   prntimg2
+         ldy   lineptr
+         ldd   #"..
+         std   ,y++
+         sty   lineptr
+         lbsr  space
+         bra   prntimg3
+
+PrntImg2 tfr   b,a        print block no.
+         lbsr  Out2HS
+
+PrntImg3 dec   ,s         count -= 1
+         bne   Prntimg
+         puls  b,x
+
+* Print primary module name
+* IN: X - process descriptor
+*
+         lbsr  Space
+         leay  P$DATImg,X
+         tfr   Y,D        d=dat image
+         std   datimg     save pointer
+         ldx   P$PModul,X x=offset in map
+         bne   doname
+         leax  >sysnam,pcr point at name
+         ldy   lineptr
+         ldb   #syslen
+
+Copy     lda   ,x+
+         sta   ,y+
+         decb  
+         bne   copy
+         bsr   Name2
+         bra   Printlin
+
+Doname   bsr   Printnam
+
+* Print Line
+Printlin ldx   lineptr    terminate line
+         lda   #C$CR
+         sta   ,X
+         ldu   umem
+         leax  outbuf,U
+
+* Print line
+PrintL1  ldy   #80
+         lda   #stdout
+         os9   I$Writln
+         bcs   Error
+         rts   
+
+** Find and print a module name
+* IN:  X - module offset
+*      U - data area
+*      datimg = pointer
+*
+Printnam equ   *
+
+* Read module header
+         pshs  U          save u
+         leau  hdr,U      destination
+         ldd   datimg     proc datimg pointer
+         ldy   #10        set length
+         os9   F$CpyMem
+         lbcs  Error
+
+* Read name from Module to buffer
+         ldd   M$Name,U   get name offset from header
+         ldu   lineptr    move name to outbuf
+         leax  D,X        X - offset to name
+         ldd   datimg
+         ldy   #maxnam    set maximum length
+         os9   F$CpyMem
+         puls  U
+         lbcs  Error
+
+Name2    pshs  X
+         ldx   lineptr
+         clrb             set length = 0
+Name3    incb  
+         lda   ,X+
+         bpl   Name3
+         cmpb  #40
+         bcc   Name5
+         anda  #$7F       clear d7
+         sta   -1,X
+         cmpb  #9
+         bcc   Name5
+         lda   #C$SPAC
+Name4    sta   ,X+
+         incb  
+         cmpb  #9
+         bcs   Name4
+Name5    stx   lineptr
+         puls  X,PC
+
+* Print hex digit in A
+Out2HS   bsr   Hexl
+
+Space    lda   #C$SPAC
+         bra   Print
+
+
+* Print Hexidecimal Digit in A
+Hexl     tfr   A,B
+         lsra  
+         lsra  
+         lsra  
+         lsra  
+         bsr   Outhex
+         tfr   B,A
+Outhex   anda  #$0F
+         cmpa  #$0A       0 - 9
+         bcs   Outdig
+         adda  #$07       A - F
+Outdig   adda  #'0        make ASCII
+
+* Put character in A in buf
+Print    pshs  X
+         ldx   lineptr
+         sta   ,X+
+         stx   lineptr
+         puls  X,PC
+
+* Print 1 Decimal Digit in A
+*
+Outdecl  tfr   A,B        number to B
+         clra  
+
+* Print 2 Decimal Digits in D
+Outdec   clr   leadflag
+         pshs  X
+         ldx   umem
+         leax  number,X
+         clr   ,X
+         clr   1,X
+         clr   2,X
+Hundred  inc   ,X
+         subd  #100
+         bcc   Hundred
+         addd  #100
+Ten      inc   1,X
+         subd  #10
+         bcc   Ten
+         addd  #10
+         incb  
+         stb   2,X
+         bsr   Printled
+         bsr   Printled
+         bsr   Printnum
+         bsr   Space
+         puls  X,PC
+
+Printnum lda   ,X+        get char
+         adda  #'0-1      make ASCII
+         bra   Print
+
+Printled tst   leadflag   print leading zero?
+         bne   Printnum   yes
+         ldb   ,X         is it zero?
+         inc   leadflag
+         decb  
+         bne   Printnum   no, print zeros
+         clr   leadflag
+         lda   #C$SPAC
+         leax  1,X
+         bra   Print
+
+         emod  
+Prgsiz   equ   *
+         end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level2/cmds/proc.asm	Fri Jan 31 17:49:58 2003 +0000
@@ -0,0 +1,505 @@
+********************************************************************
+* Proc - Show process information
+*
+* $Id$
+*
+* NOTE: SHOULD ADD IN TO HANDLE PRINTING NAME OF CURRENT MODULE
+*       RUNNING IN A RUNB or BASIC09 PROCESS
+*
+* From "Inside Level II" by Kevin Darling
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* 1      Original version                               KKD 88/10/28
+* ?      Modified to show status in English, stderr     ??? 89/07/30
+*        and the system process
+* 11     Modified to add current executing/editing      LCB 94/11/08
+*        module name for Basic09 and/or RunB programs
+
+         nam   Proc
+         ttl   Show process information
+
+         ifp1  
+         use   defsfile
+         endc  
+
+Type     set   Prgrm+Objct
+Revs     set   ReEnt+1
+edition  set   11
+
+bufsiz   set   512
+stdout   set   1
+
+         pag   
+***************************************************
+         mod   PrgSiz,Name,Type,Revs,Entry,DatSiz
+
+Name     fcs   /Proc/
+         fcb   edition
+
+* Data Equates
+umem     rmb   2          Data mem ptr
+sysimg   rmb   2          pointer to sysprc datimg
+datimg   rmb   2          datimg for copymem
+datimg2  rmb   2          2nd copy for non-descriptor use
+basicflg rmb   1          Flag that primary module is BASIC09 or RUNB
+outptr   rmb   2          pointer in outbuf
+number   rmb   3
+leadflag rmb   1
+path     rmb   3          stdin, stdout and stderr
+pid      rmb   1
+namlen   rmb   1
+hdr      rmb   64
+outbuf   rmb   80         Buffer for output string
+buffer   rmb   bufsiz     working proc. desc.
+sysprc   rmb   bufsiz     system proc. desc.
+stack    rmb   200
+datsiz   equ   .
+
+**************************************************
+* Messages
+* Headers
+Header   fcc   " ID Prnt User Pty  Age  Tsk  Status  Signal   Module    I/O Paths "
+         fcb   C$CR
+Hdrlen   equ   *-Header
+
+Header2  fcc   /___ ____ ____ ___  ___  ___  _______ __  __  _________ __________________/
+Hdrcr    fcb   C$CR
+Hdrlen2  equ   *-Header2
+
+* State Strings (6 characters each)
+Quesstr  fcc   /??????/
+TimSlpSt fcc   /TSleep/
+TimOStr  fcc   /TimOut/
+ImgChStr fcc   /ImgChg/
+SuspStr  fcc   /Suspnd/
+CondmStr fcc   /Condem/
+DeadStr  fcc   /Dead          /
+Spaces   fcc   /              /
+SystmSt  fcc   /System        /
+
+* Special case module names
+basic09  fcc   'BASIC'
+b09sz    equ   *-basic09
+runb     fcc   'RUNB'
+runbsz   equ   *-runb
+basicms2 fcc   ')'
+         fcb   C$CR
+Nomodule fcc   'Not Defined'
+Nomodsz  equ   *-Nomodule
+
+************************************************
+Entry    stu   <Umem      save data mem ptr
+         lda   #stdout    Std out path=1
+         leax  Hdrcr,PC   print blank line
+         ldy   #1
+         os9   I$WritLn
+         bcs   Error
+         leax  Header,pcr  Print header line 1
+         ldy   #Hdrlen
+         os9   I$WritLn
+         bcs   Error
+         leax  Header2,pcr Print header line 2
+         ldy   #Hdrlen2
+         os9   I$WritLn
+         bcs   Error
+         lda   #1
+         leax  >sysprc,U  get system proc. desc.
+         os9   F$GPrDsc
+         bcs   Error
+         leax  P$DatImg,X just for its dat image
+         stx   <sysimg
+         clra             set <pid = start -1
+         sta   <basicflg  Default: not a RUNB or BASIC09
+         sta   <pid
+
+* Main Program Loop
+Main     ldu   <umem      Get data mem ptr
+         leax  OutBuf,U   Point to line buffer to print to screen
+         stx   <outptr
+         inc   <pid       next process
+         beq   Exit       If wrapped, we are done
+         lda   <pid       get proc ID to check 
+         leax  Buffer,U   Point to place to hold process dsc.
+         os9   F$GPrDsc   Get it
+         bcs   Main       loop if no descriptor
+         bsr   Output     print data for descriptor
+         bra   Main       Do rest of descriptors
+
+Exit     clrb  
+Error    os9   F$Exit
+
+***********************************************
+*  Subroutines
+* Print Data re Process
+* Entry: X=Ptr to buffer copy of process descriptor (Buffer,u)
+Output   lda   P$ID,X     process id
+         lbsr  Outdecl    print pid
+         lda   P$PID,X    parent's id
+         lbsr  Outdecl
+         lbsr  Spce
+         ldd   P$User,X   user id
+         lbsr  Outdec
+         lbsr  Spce
+         lda   P$Prior,X  priority
+         lbsr  Outdecl
+         lbsr  Spce
+         lda   P$Age,X    age
+         lbsr  Outdecl
+         lbsr  Spce
+         lbsr  Spce
+         lda   P$Task,X   task no.
+         lbsr  Out2HS
+         lbsr  Spce
+         lda   P$State,X  state
+         pshs  X          save X
+         lbsr  OutState
+         puls  X          restore x
+         lda   P$Signal,X signal
+         lbsr  Outdecl    - in decimal
+         lbsr  Spce
+         lda   P$Signal,X signal
+         lbsr  Out2HS     - in hex
+         lbsr  Spce
+         ldd   P$Path,X   get stdin and stdout
+         std   <path
+         lda   P$Path+2,X and stderr
+         sta   <path+2
+* Print primary module name
+* IN: X - ptr to process descriptor copy (buffer,u)
+         leay  P$DATImg,X
+         tfr   Y,D        d=dat image
+         std   <datimg
+         std   <datimg2   2nd copy for 2ndary name
+         lda   <pid       working on system process?
+         cmpa  #1
+         beq   Outp2      yes, print name
+         ldx   P$PModul,X x=offset in map
+         ldb   #9         set minimum space padded size of name
+         stb   <namlen
+         lbsr  Printnam   Go append name to buffer
+         bra   Outp3
+
+Outp2    leax  SystmSt,pcr print "System"
+         ldb   #9         name length
+         lbsr  PutSt1
+* Print Standard input Device
+Outp3    lbsr  Spce
+         lda   #'<
+         lbsr  Print
+         lbsr  Device
+         lda   <path+1    get stdout
+         sta   <path
+         lda   #'>
+         lbsr  Print
+         lbsr  Device
+Stderr   lda   <path+2    get stderr
+         sta   <path
+         lda   #'>
+         lbsr  Print      print first >
+         lda   #'>
+         lbsr  Print
+         bsr   Device
+* Print Line
+         ldx   <outptr    now print line
+         lda   #C$CR
+         sta   ,X         terminate line with CR
+         ldu   <umem
+         leax  outbuf,U   Print it (up to 80 chars)
+         ldy   #80
+         lda   #stdout
+         os9   I$Writln
+         lbcs  Error
+         lda   <basicflg  Was module RUNB or BASIC09?
+         beq   notbasic   No, finished this entry
+         clr   <basicflg  Yes, clear out flag for 2nd call to Printnam
+         leax  outbuf,u   Point to output buffer start
+         ldd   #$20*256+45 45 spaces
+copylp   sta   ,x+        Put spaces into output buffer
+         decb             Drop size counter
+         bne   copylp     Copy entire message
+         lda   #'(        Add opening parenthesis
+         sta   ,x+
+         stx   <outptr    Save new output buffer ptr
+         ldd   <datimg2   Get programs DAT img
+         std   <datimg    Save over descriptor one
+         ldx   #$002f     $002f in basic09 is ptr to current module
+         ldy   #2         Just need ptr for now
+         ldu   <umem
+         leau  hdr,u      Point to place to hold it
+         os9   F$CpyMem   Get current module ptr
+         ldu   <umem      Get data mem ptr
+         ldx   hdr,u      Get ptr to module start in BASIC09 workspace
+         beq   NotDef     If 0, no 'current module' defined
+         lbsr  Printnam   Go append sub-module name to output buffer
+         bra   printit    Add closing chars & print it
+
+NotDef   ldx   <outptr    Get current output buffer ptr
+         leay  Nomodule,pcr Point to 'Not Defined'
+         ldb   #Nomodsz   Size of message
+Notlp    lda   ,y+        Copy it
+         sta   ,x+
+         decb             Until done
+         bne   Notlp
+         stx   <outptr    Save output buffer ptr for below
+printit  ldd   basicms2,pcr Get closing ')' + CR
+         ldx   <outptr    Get current output buffer ptr
+         std   ,x         Append to output buffer
+         ldu   <umem
+         leax  outbuf,U   Print it (up to 80 chars)
+         ldy   #80
+         lda   #stdout
+         os9   I$Writln
+         lbcs  Error
+notbasic rts   
+
+* Print Character in A and Device Name
+Device   ldu   <umem      restore U
+         lda   <path
+         bne   Device2    if <path = 0, print spaces
+         leax  Spaces,pcr
+         lbra  PutStr
+
+* Get device name
+Device2  leau  hdr,U      get table offset in sys map
+         ldd   <sysimg
+         ldx   #D.PthDBT  from direct page
+         ldy   #2
+         os9   F$CpyMem
+         lbcs  Error
+         ldx   hdr        get <path descriptor table
+         ldy   #64
+         ldd   <sysimg
+         os9   F$CpyMem
+         lbcs  Error
+         ldb   <path      point to <path block
+         lsrb             four           <paths/ block
+         lsrb  
+         lda   B,U        a=msb block addr.
+         pshs  A
+         ldb   <path      point to <path
+         andb  #3
+         lda   #$40
+         mul   
+         puls  A          d= <path descriptor address
+         addb  #PD.Dev    get device table pointer
+         tfr   D,X
+         ldd   <sysimg
+         ldy   #2
+         os9   F$CpyMem
+         lbcs  Error
+         ldx   hdr        x= dev. table entry sys.
+         ldb   #V$Desc    we want descr. pointer
+         abx   
+         ldd   <sysimg
+         ldy   #2
+         os9   F$CpyMem
+         lbcs  Error
+         ldx   hdr        get descriptor addr.
+         ldu   <umem
+         ldd   <sysimg
+         std   <datimg
+         ldb   #5
+         stb   <namlen
+** Find and print a module name
+* IN:  X - module offset
+*      U - data area
+*      <datimg = pointer
+* Read module header
+Printnam pshs  U          save u
+         leau  hdr,U      destination
+         ldd   <datimg    proc <datimg pointer
+         ldy   #10        set length (M$Name ptr is @ 4)
+         os9   F$CpyMem   Get 1st 10 bytes of module header
+         lbcs  Error
+* Read name from Module to buffer
+         ldd   M$Name,U   get name offset from header
+         ldu   <outptr    move name to outbuf
+         leax  D,X        X - offset to name
+         ldd   <datimg
+         ldy   #40        max length of name we will accept
+         os9   F$CpyMem   Get copy of module name
+         puls  U
+         lbcs  Error
+
+         pshs  X
+         ldx   <outptr
+         pshs  X          Save start of module name ptr
+         clrb             set            length = 0
+Name3    incb             Bump up # chars long name is
+         lda   ,X+        Get char from module name
+         bpl   Name3      No hi-bit terminator yet, keep checking
+         cmpb  #40        Done, is it >39 chars?
+         bhs   Name5      Yes, skip ahead
+         anda  #$7F       Take out hi-bit
+         sta   -1,X       Save char back without hi-bit
+         cmpb  <namlen    Bigger than max name size we allow?
+         bhs   Name5      No, skip ahead
+         lda   #C$SPAC    If smaller, pad with spaces
+Name4    sta   ,X+
+         incb  
+         cmpb  <namlen
+         blo   Name4
+Name5    stx   <outptr    Save new output buffer ptr
+         lda   <basicflg  Are we here doing a basic09 sub-module?
+         bne   notbas     Yes, don't get stuck in recursive loop
+         ldx   ,s         Get ptr to start of module name again
+         leay  basic09,pcr Check for BASIC09 1st
+         ldb   #b09sz     Size of module to check           
+chkb09lp lda   ,x+        Get char from module name
+         anda  #$df       Force to uppercase
+         cmpa  ,y+        Same as one for BASIC09?
+         bne   chkrunb    No, check runb
+         decb             Done 'BASIC' yet?
+         bne   chkb09lp   No, keep checking
+         ldd   ,x++       Get last 2 chars from name
+         cmpd  #$3039     '09'?
+         bne   chkrunb    No, try runb
+         lda   ,x         Next char space (end of name)?
+         cmpa  #C$SPAC
+         beq   setflag    Yes, set basic09 flag
+chkrunb  leay  runb,pcr    Point to 'runb'
+         ldb   #runbsz
+         ldx   ,s         Get ptr to name in buffer
+chkrunlp lda   ,x+        Get char
+         anda  #$df       Force to uppercase
+         cmpa  ,y+        Match?
+         bne   notbas     No, not either basic
+         decb             Done whole check?
+         bne   chkrunlp   No, keep checking
+setflag  sta   <basicflg  Set basic09 flag
+notbas   leas  2,s        Eat start of module name ptr
+         puls  X,PC       Restore X & return
+
+* Print Hexidecimal Digit in D
+Out4HS   pshs  B
+         bsr   Hexl
+         puls  A
+Out2HS   bsr   Hexl
+
+Spce     lda   #C$SPAC
+         bra   Print
+
+* Print Hexidecimal Digit in A
+Hexl     tfr   A,B
+         lsra  
+         lsra  
+         lsra  
+         lsra  
+         bsr   Outhex
+         tfr   B,A
+Outhex   anda  #$0F
+         cmpa  #$0A       0 - 9
+         bcs   Outdig
+         adda  #$07       A - F
+Outdig   adda  #'0        make ASCII
+
+Print    pshs  X
+         ldx   <outptr
+         sta   ,X+
+         stx   <outptr
+         puls  X,PC
+
+* Print 1 Decimal Digit in B
+*
+Outdecl  tfr   A,B        <number to B
+         clra  
+
+* Print 2 Decimal Digits in D
+Outdec   clr   <leadflag
+         pshs  X
+         ldx   <umem
+         leax  <number,X
+         clr   ,X
+         clr   1,X
+         clr   2,X
+Hundred  inc   ,X
+         subd  #100
+         bcc   Hundred
+         addd  #100
+Ten      inc   1,X
+         subd  #10
+         bcc   Ten
+         addd  #10
+         incb  
+         stb   2,X
+         bsr   Printled
+         bsr   Printled
+         bsr   Printnum
+         bsr   Spce
+         puls  X,PC
+
+Printnum lda   ,X+        get char
+         adda  #$30-1     make ASCII
+         bra   Print
+
+Printled tst   <leadflag  print leading zero?
+         bne   Printnum   yes
+         ldb   ,X         is it zero?
+         inc   <leadflag
+         decb  
+         bne   Printnum   no, print zeros
+         clr   <leadflag
+         lda   #C$SPAC
+         leax  1,X
+         bra   Print
+
+* Print process state in English
+*  IN:  A = P$State
+OutState tfr   A,B
+         bitb  #SysState  system?
+         beq   OutSt1     no
+         lda   #'s        s = System state
+         bra   OutSt2
+
+OutSt1   lda   #C$SPAC
+
+OutSt2   bsr   Print
+         bitb  #TimSleep
+         bne   PTimSlp
+         bitb  #TimOut
+         bne   PTimOut
+         bitb  #ImgChg
+         bne   PImgCh
+         bitb  #Suspend
+         bne   PSuspnd
+         bitb  #Condem
+         bne   PCondem
+         bitb  #Dead
+         bne   PDead
+         bitb  #$04
+         bne   PQues
+         leax  Spaces,pcr  nothing to report
+         bra   PutStr
+
+PQues    leax  QuesStr,pcr
+         bra   PutStr
+
+PTimSlp  leax  TimSlpSt,pcr
+         bra   PutStr
+
+PTimOut  leax  TimOStr,pcr
+         bra   PutStr
+
+PImgCh   leax  ImgChStr,pcr
+         bra   PutStr
+
+PSuspnd  leax  SuspStr,pcr
+         bra   PutStr
+
+PCondem  leax  Condmstr,pcr
+         bra   PutStr
+
+PDead    leax  Deadstr,pcr
+
+Putstr   ldb   #6         six characters
+
+Putst1   lda   ,X+
+         lbsr  Print
+         decb  
+         bne   PutSt1
+         rts   
+
+         emod  
+Prgsiz   equ   *
+         end   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level2/cmds/reboot.asm	Fri Jan 31 17:49:58 2003 +0000
@@ -0,0 +1,426 @@
+********************************************************************
+* ReBoot - Reboot into OS-9 or DECB
+*
+* $Id$
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+*   1    Started                                        ADK ??/??/??
+
+         nam   ReBoot
+         ttl   Reboot into OS-9 or DECB
+
+         ifp1
+         use   defsfile
+         endc
+
+tylg     set   Prgrm+Objct   
+atrv     set   ReEnt+Rev
+rev      set   $01
+
+         mod   eom,name,tylg,atrv,start,size
+
+*==================================================================
+* On boot-up, OS9p2 does (in order)
+* an I$ChDir to the directory specified in the Init file
+*     this opens an RBF buffer for the device, and at the minimum,
+*     allocates:
+* $0100 1 page by IOMan for the IRQ/VIRQ polling table
+* $0100 1 page by IOMan for the disk driver static storage
+* $0100 1 page by IOMan for the disk PD.BUF buffer
+* (the path descriptor comes out of memory allocated already by OS9p1
+*  from block 0)
+*
+* Next, OS9p2 does an I$Open to '/term' (or whatever, from the Init module)
+* $0100 1 page allocated for '/term' device static storage
+* $0100 1 page allocated for '/term' PD.BUF buffer
+*
+* CC3IO does an F$Load to get GrfDrv into memory, and we then have
+* $0200 2 pages allocated by IOMan via F$AllPrc, for the F$Load
+*-------   total
+* $0700   pages UP from $4000, so GrfDrv can load
+
+*==================================================================
+* The system's memory map is set up as:
+* $0000-$1FFF: block 0, global system memory
+* $2000-$3FFF: this block MUST be free: grfdrv is loaded here on boot
+*              once booted, process descriptors, etc. get allocated here
+* $4000-$46FF: initial data storage for system prior to loading GrfDrv
+* $4700-$ECFF: OS9Boot file: $A600 maximum size
+* $ED00-$FEFF: kernel, and constant page at $FE00
+* $FF00-$FFFF: hardware, and RAM under block $3F that's unused by everyone!
+*==================================================================
+
+maxOS9Bt equ   $A600      max. size of the OS9Boot file
+
+         org   0
+OS9Boot  rmb   maxOS9Bt
+Kernel   rmb   $1200        size of the kernel to use
+PrcDsc   rmb   $0200        current process descriptor
+param.pt rmb   2            parameter pointer
+os9btsz  rmb   2            size of the OS9Boot file
+rbflag   rmb   2            -b -r flags
+oflag    rmb   1            OS9Boot reload flag
+kflag    rmb   1            kernel reload flag
+gflag    rmb   1            GrfDrv reload flag
+Param    rmb   $C000-.      shift everything up to $C000
+Stack    equ   .
+GrfDrv   rmb   $2000        so we now have all of the memory full
+SIZE     equ   .
+
+*==================================================================
+* We'll put all of the 'magic' code in GrfDrv's stack, which doesn't
+* care about being uninitialize
+*
+* Actually, this program puts it at offset $0000 in block $3F,
+* which is $E000 when the system is rebooted.  BOOT then copies
+* all of the information down to $1C80 before loading in the new OS9Boot
+* file, and copying the original BOOT module back to $ED00+$0130
+*==================================================================
+         org   $1C80      where memory is ALWAYS mapped in
+os9.siz  rmb   2          size of the os9boot file
+grf.flg  rmb   1          flag: reload GrfDrv?
+os9.dat  rmb   16         DAT image
+boot     rmb   $01D0      original BOOT module
+
+NAME     fcs   /ReBoot/
+         fcb   $01
+
+*==================================================================
+* Start of the program: Move the stack to lower memory, and
+* copy the parameters there, too.
+*==================================================================
+Start    lds   #stack       point the stack to somewhere safe
+         tfr   d,y          now Y = size of the parameter area
+         ldu   #param       U=$0000 always in the Coco, so this is OK
+
+s.copy   lda   ,x+
+         sta   ,u+
+         leay  -1,y
+         bne   s.copy
+
+         clra
+         sta   >oflag       no os9boot
+         sta   >kflag       no kernel
+         sta   >gflag       no GrfDrv
+         sta   >rbflag      default to allowing '-r -b' options
+
+         ldx   #Param       point to the start of the parameters again
+         stx   >param.pt    save pointer
+
+*==================================================================
+* Check for more parameters
+*==================================================================
+Check    ldx   >param.pt    get the current parameter pointer
+check.p  ldd   ,x
+         cmpa  #C$SPAC      skip leading spaces
+         bne   Contin
+         leax  1,x
+         bra   check.p
+
+Contin   cmpa  #C$CR       simply reboot
+         bne   Hy          check for hyphens
+         tst   >rbflag      are the '-r' '-b' options valid?
+         lbne  Finalize     no, finalize the boot, and reboot
+         lbra  CrashIt      yes, go ahead and crash the system.
+
+Hy       cmpa  #'-        hyphen?
+         lbne  Help
+         cmpb  #'?        help?
+         lbeq  Help
+         andb  #$DF       make uppercase
+         tst   >rbflag      are the '-r' '-b' options valid?
+         bne   o.flag       no, skip ahead to checking other flags
+         cmpb  #'B
+         lbeq  CrashIt
+
+         cmpb  #'R        reboot?
+         lbeq  LoadIt
+
+*==================================================================
+* Only -L -K -G options are valid here
+*==================================================================
+o.flag   cmpb  #'L          load the OS9Boot file?
+         lbeq  load.os9     yes, go load it
+
+         cmpb  #'K          load the kernel file?
+         lbeq  load.krn     yes, go load it
+
+         cmpb  #'G          load GrfDrv?
+         lbne  Help         no, print out a help message
+
+*==================================================================
+* load in GrfDrv
+*==================================================================
+load.grf tst   >gflag
+         lbne  Help
+         stb   >gflag
+         ldu   #grfdrv      where to put grfdrv
+         ldy   #$2000       the maximum size it can be
+         bsr   load.fil
+         lbra  Check        check for more options
+
+*==================================================================
+* Load in the kernel
+*==================================================================
+load.krn tst   >kflag       already loaded the kernel?
+         lbne  Help         yes, print error
+         stb   >kflag       we're loading the kernel
+         ldu   #kernel      where to put the kernel
+         ldy   #$1200       the size of the kernel
+         bsr   load.fil     load in the kernel file
+         lbra  Check        check for more options
+
+*==================================================================
+* load the specified file
+* Entry: X = parameter pointer
+*        Y = maximum size of the file to read
+*        U = pointer to load address for the file
+*==================================================================
+load.fil stb   >rbflag      don't allow -r -b any more
+         leax  2,x          skip '-X' option
+         lda   ,x+          grab the next character
+         cmpa  #C$SPAC      space?
+         lbne  Help         no, print help message
+
+         pshs  x            save filename for later
+         lda   #READ.       read-only permissions
+         os9   I$Open       open the file
+         lbcs  fil.err
+
+         stx   >param.pt    save parameter pointer for later
+
+         tfr   u,x          put load address into X
+         os9   I$Read       read in the OS9Boot file
+         lbcs  fil.err
+         puls  x,pc         restore unused X, and exit
+
+*==================================================================
+* load a new OS9Boot file
+*==================================================================
+load.os9 tst   >oflag
+         lbne  Help
+         stb   >oflag       flag we have an OS9Boot file requested
+         stb   >rbflag      and the '-r' or '-b' options are no longer valid
+
+         ldu   #$0000       where to put the information
+         ldy   #MaxOS9Bt
+         lbsr  load.fil     go load the file into memory
+         sty   >os9btsz     save the size of the OS9Boot file for later
+* do some syntax checking on the OS9Boot file...
+         lbra  Check        go check for more parameters
+
+*==================================================================
+* finalize the crash of the system
+*==================================================================
+Finalize lbsr  Seek         seek /DD to 0
+         os9   F$ID         get my ID and process #
+         ldx   #PrcDsc      point to where to put the process descriptor
+         os9   F$GPrDsc     get it
+         lbcs  Exit
+         leax  P$DATImg,x   point to it's DAT image
+
+         orcc  #IntMasks    shut off IRQ's
+         lda   #$3F         block $3F
+         sta   >$FFA8       map in block $3F
+
+         lda   >oflag       do OS9Boot?
+         bne   do.os9bt     yup, skip ahead
+         lda   >gflag       OS9Boot OR GrfDrv?
+         beq   do.kern      neither one, just do the kernel
+         lbra  Help         no OS9Boot, but trying to reload GrfDrv: invalid
+
+* copy our DAT image to block 0
+do.os9bt ldu   #$0000       to the start of block $3F
+         ldd   >os9btsz     get the size of the OS9Boot file
+         std   ,u++         save it for later
+         lda   >gflag       do we reload GrfDrv?
+         sta   ,u+          save flag for later
+         ldb   #16          copy the whole DAT image...
+dat.lp   lda   ,x+
+         sta   ,u+
+         decb
+         bne   dat.lp
+
+         lda   >kflag       do we move the kernel over?
+         beq   no.kern      if clear, we don't have a kernel in high memory
+
+do.kern  pshs  u            save current pointer to $E000+x
+         ldu   #$0D00       where to put the new kernel
+         ldx   #kernel      where the new kernel currently is located
+         ldy   #$1200       the size of the kernel
+         bsr   bt.lp        copy the kernel over a byte at a time
+         puls  u            restore low memory pointer
+
+         lda   >oflag
+         ora   >gflag       OS9Boot OR GrfDrv?
+         lbeq  LoadIt.0     nope, just the kernel: reboot quickly
+
+* copy the original BOOT module to block 0
+no.kern  ldx   #$0D00+$0130  block 0, offset $0D00+REL
+         bsr   bt.copy
+         leax  eom,pc       point to the end of the module
+         ldu   #$0D00+$0130 over top of the original BOOT module
+         bsr   bt.copy
+         lbra  LoadIt.0     and go re-load the OS9Boot file
+
+bt.copy  ldy   #$01D0
+bt.lp    lda   ,x+
+         sta   ,u+
+         leay  -1,y
+         bne   bt.lp
+         rts
+
+*==================================================================
+* crash the system
+*==================================================================
+CrashIt  lbsr  Seek       seek /DD to track 0
+         orcc  #IntMasks  turn off IRQ's
+         clrb
+         stb   >$FFA8     map in block 0
+         stb   >$0071     cold reboot
+         lda   #$38       bottom of DECB block mapping
+         sta   >$FFA8     map in block zero
+         stb   >$0071     and cold reboot here, too
+         ldu   #$0000       force code to go at offset $0000
+         leax  ReBoot,pc  reboot code
+         ldy   #BtSize
+cit.loop lda   ,x+
+         sta   ,u+
+         leay  -1,y
+         bne   cit.loop
+         clr   >$FEED     cold reboot
+         clr   >$FFD8     go to low speed
+         jmp   >$0000       jump to the reset code
+
+*==================================================================
+* reboot the system
+*==================================================================
+ReBoot   ldd   #$3808       block $38, 8 times
+         ldx   #$FFA0       where to put it
+Lp       sta   8,x        put into map 1
+         sta   ,x+        and into map 0
+         inca
+         decb             count down
+         bne   Lp
+
+         lda   #$4C       standard DECB mapping
+         sta   >$FF90
+         clr   >$FF91     go to map type 0
+         clr   >$FFDE     and to all-ROM mode
+         ldd   #$FFFF
+*         clrd               executes as CLRA on a 6809
+         fdb   $104F
+         tstb               is it a 6809?
+         bne   Reset        yup, skip ahead
+*         ldmd  #$00       go to 6809 mode!
+         fcb   $11,$3D,$00
+Reset    jmp   [$FFFE]    do a reset
+BtSize   equ   *-Reboot
+
+*==================================================================
+* reload the OS9Boot file
+*==================================================================
+LoadIt   lbsr  Seek       seek /DD to track 0
+         orcc  #IntMasks
+LoadIt.0 clr   >$FFA8     map in block 0
+         ldu   #$0520     somewhere unused
+         leax  <ReLoad,pc   point to code to reboot the system
+         ldy   #LoadSiz
+lit.loop lda   ,x+
+         sta   ,u+
+         leay  -1,y
+         bne   lit.loop
+         jmp   >$0520     and jump to it
+
+ReLoad   clr   >$FF91     go to map type 0
+         ldx   #$ED00     where REL is located
+
+RLp      leax  1,x        to to the next byte (OS...)
+         ldd   ,x
+         cmpd  #M$ID12
+         bne   RLp        if not the start of a module
+         ldd   M$Exec,x   get execution address of the module (REL)
+         jmp   d,x        and go to it
+LoadSiz  equ   *-ReLoad
+
+*==================================================================
+* print out the help message
+*==================================================================
+Help     leax  HMsg,pc
+         ldy   #HLen
+Print    lda   #1         to STDOUT
+         os9   I$Write
+ClnExit  clrb
+Exit     os9   F$Exit
+
+HMsg     fcc   /ReBoot: Reboots the system, or returns to DECB./
+         fcb   C$CR,C$LF
+         fcc   / use: reboot [-b] [-r] [-k filename] [-l filename]/
+         fcc   / [-g filename]/
+         fcb   C$CR,C$LF
+         fcc   /   -b = return to DECB (default)/
+         fcb   C$CR,C$LF
+         fcc   /        ( equivalent to <CTRL><ALT><RESET> )/
+         fcb   C$CR,C$LF
+         fcc   /   -r = reload OS9Boot/
+         fcb   C$CR,C$LF
+         fcc   /        ( equivalent to pressing <RESET> )/
+         fcb   C$CR,C$LF
+         fcc   /**  The previous 2 options are mutually exclusive to the/
+         fcc   / next 3.**/
+         fcb   C$CR,C$LF
+         fcc   /   -k [filename] = load in a new kernel track from [filename]/
+         fcb   C$CR,C$LF
+         fcc   /   -l [filename] = reload the OS9Boot file from [filename]/
+         fcb   C$CR,C$LF
+         fcc   /   -g [filename] = load in a new GrfDrv from [filename]/
+         fcb   C$CR,C$LF
+         fcc   /      If you reload GrfDrv, you MUST also reload the/
+         fcc   / OS9Boot file./
+         fcb   C$CR,C$LF
+HLen     equ   *-HMsg
+
+DD       fcs   '/DD'
+
+*==================================================================
+* Seek /DD to sector 0... why not?
+*==================================================================
+Seek     leax  <DD,pc
+         lda   #READ.
+         os9   I$Open
+         bcs   seek.ex
+         ldx   #$0000
+         ldu   #$0000
+         os9   I$Seek     restore head on /DD to track 0
+         os9   I$Close
+seek.ex  rts
+
+fil.err  puls  u            restore pointer to filename we had error with
+         pshs  b,cc         save error code, condition
+         leax  >fil.msg,pc
+         ldy   #fil.len
+         lda   #$02         to STDERR
+         os9   I$Write
+
+* A=$02 still...
+         leax  ,u
+fil.lp   ldb   ,u+
+         cmpb  #C$SPAC
+         bhi   fil.lp
+         ldb   #C$CR         get a CR
+         stb   -1,u         save for later
+
+         ldy   #$0100       maximum amount of junk to write
+         os9   I$WritLn     dump out the filename
+         puls  b,cc         restore error code, condition
+         os9   F$Exit       and exit
+
+fil.msg  fcc   /ReBoot: Error reading file: /
+fil.len  equ   *-fil.msg
+
+         fcc   'MAGIC Boot Module is next!'
+
+         emod
+eom      equ   *
+         end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/level2/cmds/smap.asm	Fri Jan 31 17:49:58 2003 +0000
@@ -0,0 +1,196 @@
+********************************************************************
+* SMap - Show System Memory Map
+*
+* $Id$
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* 1      Original version
+
+         nam   SMap
+         ttl   Show System Memory Map
+
+* Disassembled 02/05/12 22:05:11 by Disasm v1.6 (C) 1988 by RML
+
+         ifp1
+         use   defsfile
+         endc
+
+tylg     set   Prgrm+Objct   
+atrv     set   ReEnt+rev
+rev      set   $01
+edition  set   1
+
+         mod   eom,name,tylg,atrv,start,size
+
+u0000    rmb   1
+u0001    rmb   3
+u0004    rmb   1
+u0005    rmb   1
+u0006    rmb   1
+u0007    rmb   1
+u0008    rmb   6
+u000E    rmb   1
+u000F    rmb   456
+size     equ   .
+
+name	 fcs   /SMap/
+         fcb   edition
+
+H1       fcc   "    0 1 2 3 4 5 6 7 8 9 A B C D E F"
+         fcb   C$CR
+H1L      equ   *-H1
+H2       fcc   " #  = = = = = = = = = = = = = = = ="
+         fcb   C$CR
+H2L      equ   *-H2
+L005A    fcb   $00,$00,$00,$00
+
+start    lbsr  L0170
+         leax  >H1,pcr
+         lda   #$01
+         ldy   #H1L
+         os9   I$WritLn 
+         leax  >H2,pcr
+         ldy   #H2L
+         os9   I$Write  
+         leax  >L005A,pcr
+         tfr   x,d
+         ldx   #$004E
+         ldy   #$0002
+         pshs  u
+         leau  u000F,u
+         os9   F$CpyMem 
+         puls  u
+         lbcs  L013F
+         ldx   u000F,u
+         ldy   #$0100
+         pshs  u
+         leau  u000F,u
+         os9   F$CpyMem 
+         puls  u
+         lbcs  L013F
+         clr   <u000E
+         clr   <u0004
+         leax  u000F,u
+         lda   #$30
+         sta   <u0005
+         clr   ,-s
+L00B2    lda   ,s
+         bita  #$0F
+         bne   L00DF
+         pshs  x
+         lbsr  L0170
+         leax  u0006,u
+         ldy   #$0004
+         lda   <u0005
+         cmpa  #$3A
+         bne   L00CD
+         lda   #$41
+         sta   <u0005
+L00CD    sta   <u0007
+         inc   <u0005
+         ldd   #$2020
+         sta   <u0006
+         std   <u0008
+         lda   #$01
+         os9   I$Write  
+         puls  x
+L00DF    ldb   ,x+
+         beq   L00ED
+         bmi   L00E9
+         ldb   #$55
+         bra   L00F1
+L00E9    ldb   #$2E
+         bra   L00F1
+L00ED    ldb   #$5F
+         inc   <u0004
+L00F1    stb   <u0007
+         ldb   #$20
+         stb   <u0008
+         pshs  x
+         leax  u0007,u
+         ldy   #$0002
+         lda   #$01
+         os9   I$Write  
+         puls  x
+         dec   ,s
+         lbhi  L00B2
+         puls  a
+         bsr   L0170
+         bsr   L0170
+         leax  >FreePgs,pcr
+         ldy   #FreePgsL
+         lda   #$01
+         os9   I$Write  
+         ldb   <u0004
+         clra  
+         lbsr  L0194
+         bsr   L0170
+         leax  >FreeRAM,pcr
+         ldy   #FreeRAML
+         lda   #$01
+         os9   I$Write  
+         ldb   <u0004
+         clra  
+         lsrb  
+         lsrb  
+         lbsr  L0194
+         bsr   L0170
+         clrb  
+L013F    os9   F$Exit   
+
+FreePgs  fcc   " Number of Free Pages: "
+FreePgsL equ   *-FreePgs
+FreeRAM  fcc   "   Ram Free in KBytes: "
+FreeRAML equ   *-FreeRAM
+
+L0170    pshs  x,a
+         lda   #C$CR
+         sta   <u0007
+         leax  u0007,u
+         ldy   #$0001
+         lda   #$01
+         os9   I$WritLn 
+         puls  pc,x,a
+L0183    sta   <u0007
+         pshs  x
+         leax  u0007,u
+         ldy   #$0001
+         lda   #$01
+         os9   I$Write  
+L0192    puls  pc,x
+L0194    leax  u0001,u
+         clr   <u0000
+         clr   ,x
+         clr   $01,x
+         clr   $02,x
+L019E    inc   ,x
+         subd  #$0064
+         bcc   L019E
+         addd  #$0064
+L01A8    inc   $01,x
+         subd  #$000A
+         bcc   L01A8
+L01AF    addd  #$000A
+         incb  
+         stb   $02,x
+         bsr   L01BF
+         bsr   L01BF
+L01B9    lda   ,x+
+         adda  #$2F
+         bra   L0183
+L01BF    tst   <u0000
+         bne   L01B9
+         ldb   ,x
+         inc   <u0000
+         decb  
+         bne   L01B9
+         clr   <u0000
+         lda   #C$SPAC
+         leax  1,x
+         bra   L0183
+
+         emod
+eom      equ   *
+	end
+