           ttl     Monitor Command Processing
*
.   define local data for monitor and stuff
.
monitor:   proc

nextcmd    ldx     #prompt             point to rom prompt
           bsr     pdata               output data and stuff
           bsr     inch                get an input command
           bsr     outsp               follow with a trailing space
*
.   invoke the command through the command table
.
           ldx     #commands           point to command table
           bsr     search              look up the command
           jsr     [1,x]               fire up the command
           bra     nextcmd
*
.   search a command table for the command letter
.
search     cmpa    0,x                 compare to command letter
           beq     do_cmd              if compare equal, do the command
           leax    3,x                 continue down the slot
           tst     0,x                 check for end of table
           bne     search
do_cmd     rts
*
.   command decode table
.
commands   fcb     cr                  null command
           fdb     dummy
           fcb     "C"                 configure processor
           fdb     figleaf
           fcb     "B"                 generic disk boot
           fdb     diskboot
           fcb     "D"
           fdb     fboot               floppy implied
           aif     VERS!=3
           fcb     "H"                 hard disk boot
           fdb     hardboot
           aif
           fcb     "W"                 mini winchester implied
           fdb     miniwin
           fcb     "E"                 block memory examine
           fdb     examine
           fcb     "M"                 physical memory examine
           fdb     memory
           aif     VERS==3
           fcb     "T"                 home Tulin heads
           fdb     tulhome
           fcb     "S"                 seek to any cyl
           fdb     genhome
           fcb     "Q"                 logical memory test
           fdb     memtest
           fcb     "R"                 register examine
           fdb     regs
           fcb     "L"                 logical memory examine
           fdb     lemex
           fcb     "J"                 logical jum
           fdb     jump
           aif
           fcb     0                   end of table
           fdb     bad_cmd
*
.   configurator command
.
figleaf    bsr     config              call the configurator
           lda     corecnt             get memory image count
           adda    #8                  add in system core count
           pshs    a                   stuff count onto stack
           clrd                        set count to zero
*
.   do a peculiar convert to decimal
.
corecvt    adda    #4                  add four to lsp
           daa                         decimal adjust it
           adcb    #0                  then add in the carry
           dec     0,s                 decrement the core count
           bne     corecvt
           stb     0,s+                <-- this is correct!
           beq     coredis
*
.   display the amount of memory available
.
           exg     a,b
           adda    #"0"                convert the uppermost digit
           bsr     outch
           exg     b,a                 get result stuff
coredis    bsr     hexbyte
           bsr     outsp
           lda     #"K"                and tell dude what units
           bra     outch
*
.   logical jump
.
           aif     VERS==3
jump       bsr     getbyte             get first half
           bcs     bad_cmd             croak
           pshs    a                   save it
           bsr     getbyte             get second half
           puls    b                   get first back
           bcs     bad_cmd             if bad, croak
           exg     a,b                 make normal 16 bits
           tfr     d,y                 move to Y
           jmp     0,y                 jump to routine
           aif
*
.   disk boot command
.
diskboot   bsr     config              configure the system
           lda     #-1                 indicate generic boot
dboot      bsr     loadipl             load the ipl sector
           bne     hexbyte             if load fails, display status
           lds     #systack            reload the initial system stack
           jmp     [6,x]               and fire up the bootstrap
*
.   hard disk boot command
.
           aif     VERS!=3
hardboot   bsr     config              configure the system
           bsr     hardon              load the ipl sector
           bra     exboot              go exec the boot if ok
           aif
*
.   floppy disk boot
.
fboot      bsr     config
           lda     #2
           bra     dboot
*
.   western digital boot command
.
miniwin    bsr     config              configure the system
           lda     #0                    load the ipl sector
           bra     dboot
*
.   invalid command detected
.
bad_cmd    ldx     #sorry              point to bad message
           bsr     pdata               invoke the processor
dummy      rts

**         lib     fdboot
**         lib     wdboot
           lib     scsiboot

           aif     VERS==3
           lib     config3
           aif     VERS==2
           lib     hardon
           lib     config
           aif
           lib     pemex
           aif     VERS==3
           lib     lemex
           lib     land_zone
           aif

           end
