view bootman/bootman.a @ 2163:2db06bc0742a

Start of BootMan
author boisy
date Tue, 20 May 2008 14:43:00 +0000
parents
children d280490500a8
line wrap: on
line source

         NAM    bootman
         TTL    Boot Manager

BOOTTRACK equ   0

         PSECT  bootman,$11,0,0,0,entry

         VSECT
         ENDSECT

TOP      EQU   $FE00

*         ORG   $2600

* This code is executed first - it moves the actual boot manager code
* into high RAM so it is out of the way to load boot files
         fcc    "OS"
entry
         lds    #TOP-1             set stack to absolute TOP - 1
         ldd    #bmgrsiz           get size of boot manager
         pshs   d                  save on stack
         ldd    #TOP               get address at top
         subd   ,s++               subtract size of boot manager
         clrb                      D now holds the address where we copy boot manager
         deca                      minus 256 bytes for stack 
         deca                      minus 256 bytes for statics
         
         pshs   d                  save address for later

         tfr    d,u                place boot manager's dest addr in U
         ldd    #bmgrsiz
         leax   bootmain,pcr
cloop    ldy    ,x++
         sty    ,u++
         subd   #$0002
         bgt    cloop

         jmp    ,s++               send control to moved code
         
* The entry point of the boot manager
* Entry: stack is set up, U points to static storage
         csect
sectptr  rmb    2
         endsect

bootmain lbsr   mach_init   initialize the machine we're running on
         lds    #$FDFF      set up stack
         ldu    #$F200      set up static storage
         leax   256,u
         stx    sectptr,u
         leax   welcome,pcr
         bsr    writestr
loop     bra    loop


welcome  fcc     "NitrOS-9 Boot Manager"
         fcb     0

* Helpful routines

* writestr - write string to output handler
* Entry:
*   X = address of string (nul terminated)
writestr:
         leay    llio,pcr
writeloop
         lda     ,x+
         beq     writedone
         jsr     3,y
         bra     writeloop
writedone
         rts
         
bmgrsiz  equ     *-bootmain

         endsect