OpenCores
URL https://opencores.org/ocsvn/rf6809/rf6809/trunk

Subversion Repositories rf6809

[/] [rf6809/] [trunk/] [software/] [boot/] [boot_rom.asm] - Diff between revs 4 and 13

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 13
Line 1... Line 1...
; ============================================================================
; ============================================================================
;        __
;        __
;   \\__/ o\    (C) 2013-2022  Robert Finch, Stratford
;   \\__/ o\    (C) 2013-2022  Robert Finch, Waterloo
;    \  __ /    All rights reserved.
;    \  __ /    All rights reserved.
;     \/_//     robfinch@opencores.org
;     \/_//     robfinch@opencores.org
;       ||
;       ||
;
;
;
;
; This source file is free software: you can redistribute it and/or modify
; BSD 3-Clause License
; it under the terms of the GNU Lesser General Public License as published
; Redistribution and use in source and binary forms, with or without
; by the Free Software Foundation, either version 3 of the License, or
; modification, are permitted provided that the following conditions are met:
; (at your option) any later version.
;
;
; 1. Redistributions of source code must retain the above copyright notice, this
; This source file is distributed in the hope that it will be useful,
;    list of conditions and the following disclaimer.
; but WITHOUT ANY WARRANTY; without even the implied warranty of
;
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; 2. Redistributions in binary form must reproduce the above copyright notice,
; GNU General Public License for more details.
;    this list of conditions and the following disclaimer in the documentation
;
;    and/or other materials provided with the distribution.
; You should have received a copy of the GNU General Public License
;
; along with this program.  If not, see .
; 3. Neither the name of the copyright holder nor the names of its
 
;    contributors may be used to endorse or promote products derived from
 
;    this software without specific prior written permission.
 
;
 
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
;
; ============================================================================
; ============================================================================
;
;
CR      EQU     $0D             ;ASCII equates
CR      EQU     $0D             ;ASCII equates
LF      EQU     $0A
LF      EQU     $0A
Line 29... Line 42...
CTRLI   EQU     $09
CTRLI   EQU     $09
CTRLJ   EQU     $0A
CTRLJ   EQU     $0A
CTRLK   EQU     $0B
CTRLK   EQU     $0B
CTRLM   EQU $0D
CTRLM   EQU $0D
CTRLS   EQU     $13
CTRLS   EQU     $13
 
CTRLT EQU $14
CTRLX   EQU     $18
CTRLX   EQU     $18
XON             EQU     $11
XON             EQU     $11
XOFF    EQU     $13
XOFF    EQU     $13
 
 
FIRST_CORE      EQU     1
FIRST_CORE      EQU     1
Line 79... Line 93...
KeybdLocks              EQU             $FFFFFCD00
KeybdLocks              EQU             $FFFFFCD00
KeybdBuffer             EQU             $FFFFFC000      ; buffer is 16 chars
KeybdBuffer             EQU             $FFFFFC000      ; buffer is 16 chars
 
 
COREID  EQU             $FFFFFFFE0
COREID  EQU             $FFFFFFFE0
MSCOUNT EQU             $FFFFFFFE4
MSCOUNT EQU             $FFFFFFFE4
LEDS            EQU             $FFFE60000
LEDS            EQU             $FFFE60001
 
VIA                     EQU             $FFFE60000
 
VIA_PA          EQU             1
 
VIA_DDRA        EQU             3
 
VIA_ACR                 EQU             11
 
VIA_IFR                 EQU             13
 
VIA_IER                 EQU             14
 
VIA_T3LL                EQU             18
 
VIA_T3LH                EQU             19
 
VIA_T3CMPL      EQU             20
 
VIA_T3CMPH      EQU             21
TEXTSCR         EQU             $FFFE00000
TEXTSCR         EQU             $FFFE00000
TEXTREG         EQU             $FFFE0DF00
TEXTREG         EQU             $FFFE0DF00
TEXT_COLS       EQU             0
TEXT_COLS       EQU             0
TEXT_ROWS       EQU             1
TEXT_ROWS       EQU             1
TEXT_CURPOS     EQU             34
TEXT_CURPOS     EQU             34
 
ACIA            EQU             $FFFE30100
 
ACIA_TX         EQU             0
 
ACIA_RX         EQU             0
 
ACIA_STAT       EQU             1
 
ACIA_CMD        EQU             2
 
ACIA_CTRL       EQU             3
 
ACIA_CTRL2      EQU             11
 
RTC                             EQU             $FFFE30500      ; I2C
 
RTCBuf          EQU             $7FC0
 
 
KEYBD           EQU             $FFFE30400
KEYBD           EQU             $FFFE30400
KEYBDCLR        EQU             $FFFE30402
KEYBDCLR        EQU             $FFFE30402
PIC                     EQU             $FFFE3F000
PIC                     EQU             $FFFE3F000
SPRITE_CTRL             EQU             $FFFE10000
SPRITE_CTRL             EQU             $FFFE10000
SPRITE_EN                       EQU             $3C0
SPRITE_EN                       EQU             $3C0
 
 
 
OUTSEMA EQU     $EF0000
 
SEMAABS EQU     $1000
 
OSSEMA  EQU     $EF0010
 
 
BIOS_SCREENS    EQU     $17000000       ; $17000000 to $171FFFFF
BIOS_SCREENS    EQU     $17000000       ; $17000000 to $171FFFFF
 
 
; EhBASIC vars:
; EhBASIC vars:
;
;
NmiBase         EQU             $DC
NmiBase         EQU             $FF0013
IrqBase         EQU             $DF
IrqBase         EQU             $FF0014
 
 
; The IO focus list is a doubly linked list formed into a ring.
 
;
 
IOFocusNdx      EQU             $100
IOFocusNdx      EQU             $100
IOFocusID               EQU             $100
 
 
; These variables in global OS storage area
 
 
 
IOFocusList     EQU             $FF0000 ; to $FF000F
 
IOFocusID               EQU             $FF0010
 
IrqSource               EQU             $FF0011
 
IRQFlag                 EQU             $FF0012
 
 
; These variables use direct page access
; These variables use direct page access
CursorRow       EQU             $110
CursorRow       EQU             $110
CursorCol       EQU             $111
CursorCol       EQU             $111
CharColor       EQU             $112
CharColor       EQU             $112
Line 113... Line 155...
CursorFlash     EQU             $114
CursorFlash     EQU             $114
KeyState1       EQU     $120
KeyState1       EQU     $120
KeyState2       EQU     $121
KeyState2       EQU     $121
KeyLED          EQU     $122
KeyLED          EQU     $122
KeybdID         EQU     $124
KeybdID         EQU     $124
 
KeybdBlock      EQU     $126
 
kbdHeadRcv      EQU     $127
 
kbdTailRcv      EQU     $128
 
kbdFifo                 EQU     $40                             ; in local RAM
 
kbdFifoAlias    EQU     $C00040 ; to $C0007F    ; alias for $40 to $7F
 
SerhZero                EQU     $130
 
SerHeadRcv      EQU     $131
 
SertZero                EQU     $132
 
SerTailRcv      EQU     $133
 
SerHeadXmit     EQU     $136
 
SerTailXmit     EQU     $138
 
SerRcvXon               EQU     $139
 
SerRcvXoff      EQU     $140
 
SerRcvBuf               EQU     $BFF000 ; 4kB serial recieve buffer
 
 
 
asmbuf  EQU             $160    ; to $17F
 
 
QNdx0           EQU             $780
QNdx0           EQU             $780
QNdx1           EQU             QNdx0+2
QNdx1           EQU             QNdx0+2
QNdx2           EQU             QNdx1+2
QNdx2           EQU             QNdx1+2
QNdx3           EQU             QNdx2+2
QNdx3           EQU             QNdx2+2
Line 126... Line 184...
FreeMbx         EQU             RunningTCB + 2
FreeMbx         EQU             RunningTCB + 2
nMailbox        EQU             FreeMbx + 2
nMailbox        EQU             FreeMbx + 2
FreeMsg         EQU             nMailbox + 2
FreeMsg         EQU             nMailbox + 2
nMsgBlk         EQU             FreeMsg + 2
nMsgBlk         EQU             FreeMsg + 2
 
 
IrqSource       EQU             $79A
 
 
 
IRQFlag         EQU             $7C6
 
 
 
CharOutVec      EQU             $800
CharOutVec      EQU             $800
CharInVec       EQU             $804
CharInVec       EQU             $804
 
CmdPromptJI     EQU     $808
 
 
; Register save area for monitor
; Register save area for monitor
mon_DSAVE       EQU             $900
mon_DSAVE       EQU             $900
mon_XSAVE       EQU             $902
mon_XSAVE       EQU             $902
mon_YSAVE       EQU             $904
mon_YSAVE       EQU             $904
Line 145... Line 201...
mon_DPRSAVE     EQU             $90E
mon_DPRSAVE     EQU             $90E
mon_CCRSAVE     EQU             $90F
mon_CCRSAVE     EQU             $90F
 
 
mon_numwka      EQU             $910
mon_numwka      EQU             $910
mon_r1          EQU             $920
mon_r1          EQU             $920
mon_r2          EQU             $922
mon_r2          EQU             $924
 
 
; The ORG directive must set an address a multiple of 4 in order for the Verilog
; The ORG directive must set an address a multiple of 4 in order for the Verilog
; output to work correctly.
; output to work correctly.
 
 
        org             $FFD0AC
        org             $FFD0AC
Line 201... Line 257...
        lbra    ClearScreen
        lbra    ClearScreen
        org             $FFD308
        org             $FFD308
HomeCursorJmp
HomeCursorJmp
        lbra    HomeCursor
        lbra    HomeCursor
 
 
        org             $FFE000
        org             $FFD400
 
 
; Local RAM test routine
; Local RAM test routine
; Checkerboard testing.
; Checkerboard testing.
; There is 70kB of local RAM
; There is 70kB of local RAM
; Does not use any RAM including no stack
; Does not use any RAM including no stack
Line 215... Line 271...
        lda             #1
        lda             #1
        sta             LEDS
        sta             LEDS
        ldd             #$AAA555
        ldd             #$AAA555
ramtest1:
ramtest1:
        std             ,y++
        std             ,y++
        cmpy    #$C00000
        cmpy    #$8000
        blo             ramtest1
        blo             ramtest1
        ; now readback values and compare
        ; now readback values and compare
        ldy             #0
        ldy             #0
ramtest3:
ramtest3:
        ldd             ,y++
        ldd             ,y++
        cmpd    #$AAA555
        cmpd    #$AAA555
        bne             ramerr
        bne             ramerr
        cmpy    #$C00000
        cmpy    #$8000
        blo             ramtest3
        blo             ramtest3
        lda             #2
        lda             #2
        sta             LEDS
        sta             LEDS
        jmp             ,u
        jmp             ,u
ramerr:
ramerr:
Line 239... Line 295...
        lda             #'F'
        lda             #'F'
        sta             ,x
        sta             ,x
        sync
        sync
        jmp             ,u
        jmp             ,u
 
 
        org             $FFF000
        org             $FFE000
        FDB Monitor
        FDB Monitor
        FDB DumRts      ;       NEXTCMD
        FDB DumRts      ;       NEXTCMD
        FDB INCH
        FDB INCH
        FDB INCHE
        FDB INCHE
        FDB INCHEK
        FDB INCHEK
Line 265... Line 321...
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
 
 
start:
start:
 
        lda             #$FFF                   ; all cores can do this
 
        sta             VIA+VIA_DDRA
        lda             #$55                    ; see if we can at least set LEDs
        lda             #$55                    ; see if we can at least set LEDs
        sta             LEDS
        sta             LEDS
 
        lda             #1                              ; prime OS semaphore
 
        sta             OSSEMA+$1000
        ldu             #st6                    ; U = return address
        ldu             #st6                    ; U = return address
        jmp             ramtest         ; JMP dont JSR
        jmp             ramtest         ; JMP dont JSR
st6:
st6:
        lds             #$3FFF          ; boot up stack area
        lds             #$6FFF          ; boot up stack area
        lda             COREID
        lda             COREID
        cmpa    #FIRST_CORE
        cmpa    #FIRST_CORE
;       beq             st8
;       beq             st8
;       sync                                            ; halt cores other than 2
;       sync                                            ; halt cores other than 2
st8:
st8:
Line 285... Line 345...
;       jmp             ,x                              ; jump to the BIOS now in local RAM
;       jmp             ,x                              ; jump to the BIOS now in local RAM
st7:
st7:
        bsr             Delay3s         ; give some time for devices to reset
        bsr             Delay3s         ; give some time for devices to reset
        lda             #$AA
        lda             #$AA
        sta             LEDS
        sta             LEDS
        lda             #2
        lda             #FIRST_CORE
        sta             IOFocusID       ; core #2 has focus
        sta             IOFocusID       ; core #2 has focus
        sta             RunningID
        sta             RunningID
        lda             #$0CE
        lda             #$0CE
        sta             ScreenColor
        sta             ScreenColor
        sta             CharColor
        sta             CharColor
        bsr             ClearScreen
        bsr             ClearScreen
        ldd             #DisplayChar
        ldd             #DisplayChar
        std             CharOutVec
        std             CharOutVec
        ldd             #DBGGetKey
        ldd             #SerialPeekCharDirect
        std             CharInVec
        std             CharInVec
 
        ldb             #24                             ; request IO focus
 
        lbsr    OSCall
        ldb             COREID
        ldb             COREID
        cmpb    #FIRST_CORE
        cmpb    #FIRST_CORE
        beq             init
        beq             init
        bra             skip_init
        bra             skip_init
        bra             multi_sieve
        bra             multi_sieve
Line 309... Line 371...
        bra             st3
        bra             st3
 
 
        ; initialize interrupt controller
        ; initialize interrupt controller
        ; first, zero out all the vectors
        ; first, zero out all the vectors
init:
init:
 
        lbsr    rtc_read        ; get clock values
 
        ldx             #kbdHeadRcv
 
        ldb             #32                             ; number of bytes to zero out
 
init1:
 
        clr             ,x+
 
        decb
 
        bne             init1
 
        lbsr    TimerInit
 
        lbsr    InitSerial
        ldx             #128
        ldx             #128
        lda             #1                      ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
        lda             #1                      ; set irq(bit0), clear firq (bit1), disable int (bit 6), clear edge sense(bit 7)
        ldb             #FIRST_CORE                     ; serving core id
        ldb             #FIRST_CORE                     ; serving core id
st1:
st1:
        clr             PIC,x           ; cause code
        clr             PIC,x           ; cause code
Line 322... Line 393...
        cmpx    #256
        cmpx    #256
        blo             st1
        blo             st1
;       lda             #4                              ; make the timer interrupt edge sensitive
;       lda             #4                              ; make the timer interrupt edge sensitive
;       sta             PIC+4                   ; reg #4 is the edge sensitivity setting
;       sta             PIC+4                   ; reg #4 is the edge sensitivity setting
;       sta             PIC                             ; reg #0 is interrupt enable
;       sta             PIC                             ; reg #0 is interrupt enable
 
        lda             #$81                    ; make irq edge sensitive
 
        sta             PIC+$FD
 
        lda             #31                             ; enable timer interrupt
 
;       sta             PIC+9
 
        ldb             #1
 
        stb             OUTSEMA+SEMAABS ; set semaphore to 1 available slot
skip_init:
skip_init:
        andcc   #$EF                    ; unmask irq
        andcc   #$EF                    ; unmask irq
        lda             #56
        lda             #56
        sta             TEXTREG+TEXT_COLS
        sta             TEXTREG+TEXT_COLS
        lda             #29
        lda             #29
Line 417... Line 493...
        blo             multi_sieve2
        blo             multi_sieve2
multi_sieve4:                                   ; hang machine
multi_sieve4:                                   ; hang machine
        sync
        sync
        lbra    Monitor
        lbra    Monitor
 
 
 
;------------------------------------------------------------------------------
 
; Single core sieve.
 
;------------------------------------------------------------------------------
 
 
sieve:
sieve:
        lda             #'P'                                    ; indicate prime
        lda             #'P'                                    ; indicate prime
        ldx             #0                                              ; start at first char of screen
        ldx             #0                                              ; start at first char of screen
sieve3:
sieve3:
        sta             TEXTSCR,x                       ; store 'P'
        sta             TEXTSCR,x                       ; store 'P'
Line 439... Line 519...
        blo             multi_sieve1
        blo             multi_sieve1
        incb                                                            ; number of cores working on it
        incb                                                            ; number of cores working on it
        cmpb    #4080
        cmpb    #4080
        blo             sieve2
        blo             sieve2
sieve4:                                                         ; hang machine
sieve4:                                                         ; hang machine
        sync
        rts
        lbra    MonitorStart
 
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Three second delay for user convenience and to allow some devices time to
; Three second delay for user convenience and to allow some devices time to
; reset.
; reset.
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
Line 474... Line 553...
        aslb
        aslb
        rola
        rola
        rts
        rts
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
 
; Parameters:
 
;               b = core id of core to copy
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
CopyVirtualScreenToScreen:
CopyVirtualScreenToScreen:
        pshs    d,x,y,u
        pshs    d,x,y,u
        bsr             GetScreenLocation
        ; Compute virtual screen location for core passed in accb.
 
        tfr             b,a
 
        asla
 
        asla
 
        asla
 
        asla
 
        ora             #$C00
 
        clrb
        tfr             d,x
        tfr             d,x
 
        pshs    d
        ldy             #TEXTSCR
        ldy             #TEXTSCR
        ldu             #56*29/2
        ldu             #56*29/2
cv2s1:
cv2s1:
        ldd             ,x++
        ldd             ,x++
        std             ,y++
        std             ,y++
        leau    -1,u
        leau    -1,u
        cmpu    #0
        cmpu    #0
        bne             cv2s1
        bne             cv2s1
        ; reset the cursor position in the text controller
        ; reset the cursor position in the text controller
        ldb             CursorRow
        puls    x
 
        ldb             CursorRow,x
        lda             #56
        lda             #56
        mul
        mul
        tfr             d,x
        tfr             d,y
        ldb             CursorCol
        ldb             CursorCol,x
 
        tfr             y,x
        abx
        abx
        stx             TEXTREG+TEXT_CURPOS
        stx             TEXTREG+TEXT_CURPOS
        puls    d,x,y,u,pc
        puls    d,x,y,u,pc
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
Line 564... Line 655...
;       lda             CharColor
;       lda             CharColor
        lda             #$0CE
        lda             #$0CE
        tfr             u,x                                     ; get back count
        tfr             u,x                                     ; get back count
cs2:
cs2:
        sta             ,y+
        sta             ,y+
        leax    -1,x                            ; decrement x
        dex                                                             ; decrement x
        bne             cs2
        bne             cs2
cs3:
cs3:
        puls    d,x,y,u,pc
        puls    d,x,y,u,pc
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
Line 586... Line 677...
        tfr             d,u
        tfr             d,u
        leax    56,x                    ; x = index to source row
        leax    56,x                    ; x = index to source row
scrup1:
scrup1:
        ldd             ,x++                    ; move 2 characters
        ldd             ,x++                    ; move 2 characters
        std             ,u++
        std             ,u++
        leay    -1,y
        dey
        bne             scrup1
        bne             scrup1
        lda             #30
        lda             #29
        bsr             BlankLine
        bsr             BlankLine
        puls    d,x,y,u,pc
        puls    d,x,y,u,pc
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Blank out a line on the display
; Blank out a line on the display
Line 722... Line 813...
; Parameters:
; Parameters:
;       accb = char to display
;       accb = char to display
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
DisplayChar:
DisplayChar:
 
        lbsr    SerialPutChar
        pshs    d,x
        pshs    d,x
        cmpb    #CR                                     ; carriage return ?
        cmpb    #CR                                     ; carriage return ?
        bne             dccr
        bne             dccr
        clr             CursorCol               ; just set cursor column to zero on a CR
        clr             CursorCol               ; just set cursor column to zero on a CR
        bsr             UpdateCursorPos
        bsr             UpdateCursorPos
dcx14:
dcx14:
        puls    d,x,pc
        lbra            dcx4
dccr:
dccr:
        cmpb    #$91                            ; cursor right ?
        cmpb    #$91                            ; cursor right ?
        bne             dcx6
        bne             dcx6
        lda             CursorCol
        lda             CursorCol
        cmpa    #56
        cmpa    #56
Line 790... Line 882...
        lda             CursorCol
        lda             CursorCol
        beq             dcx4
        beq             dcx4
        deca
        deca
        sta             CursorCol
        sta             CursorCol
        bsr             CalcScreenLoc
        bsr             CalcScreenLoc
 
        tfr             d,x
 
        lda             CursorCol
dcx5:
dcx5:
        ldb             1,x
        ldb             1,x
        stb             ,x++
        stb             ,x++
        inca
        inca
        cmpa    #56
        cmpa    #56
        blo             dcx5
        blo             dcx5
        ldb             #' '
        ldb             #' '
        leax    -1,x
        dex
        stb             ,x
        stb             ,x
        puls    d,x,dp,pc
        bra             dcx4
dcx3:
dcx3:
        cmpb    #LF                             ; linefeed ?
        cmpb    #LF                             ; linefeed ?
        beq             dclf
        beq             dclf
        pshs    b
        pshs    b
        bsr     CalcScreenLoc
        bsr     CalcScreenLoc
Line 812... Line 906...
        stb             ,x
        stb             ,x
        ; ToDo character color
        ; ToDo character color
;       lda             CharColor
;       lda             CharColor
;       sta             $2000,x
;       sta             $2000,x
        bsr             IncCursorPos
        bsr             IncCursorPos
        puls    d,x,pc
        bra             dcx4
dclf:
dclf:
        bsr             IncCursorRow
        bsr             IncCursorRow
dcx4:
dcx4:
        puls    d,x,pc
        puls    d,x,pc
 
 
Line 862... Line 956...
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
DisplayString:
DisplayString:
        pshs    d,x
        pshs    d,x
        tfr             d,x
        tfr             d,x
 
dspj2:                                          ; lock semaphore for access
 
        lda             OUTSEMA+1
 
        beq             dspj2
dspj1B:
dspj1B:
        ldb             ,x+                             ; move string char into acc
        ldb             ,x+                             ; move string char into acc
        beq             dsretB          ; is it end of string ?
        beq             dsretB          ; is it end of string ?
        bsr             OUTCH                   ; display character
        lbsr    OUTCH                   ; display character
        bra             dspj1B
        bra             dspj1B
dsretB:
dsretB:
 
        clr             OUTSEMA+1       ; unlock semaphore
        puls    d,x,pc
        puls    d,x,pc
 
 
DisplayStringCRLF:
DisplayStringCRLF:
        pshs    d
        pshs    d
        bsr             DisplayString
        bsr             DisplayString
        ldb             #CR
        ldb             #CR
        bsr             OUTCH
        lbsr    OUTCH
        ldb             #LF
        ldb             #LF
        bsr             OUTCH
        lbsr    OUTCH
        puls    d,pc
        puls    d,pc
 
 
;
;
; PRINT CR, LF, STRING
; PRINT CR, LF, STRING
;
;
Line 943... Line 1041...
        pshs    b
        pshs    b
        andb    #$0F
        andb    #$0F
        cmpb    #10
        cmpb    #10
        blo             DispNyb1
        blo             DispNyb1
        addb    #'A'-10
        addb    #'A'-10
        bsr             OUTCH
        lbsr    OUTCH
        puls    b,pc
        puls    b,pc
DispNyb1
DispNyb1
        addb    #'0'
        addb    #'0'
        bsr             OUTCH
        lbsr    OUTCH
        puls    b,pc
        puls    b,pc
 
 
;==============================================================================
;==============================================================================
 
; Timer
 
;==============================================================================
 
 
 
OPT INCLUDE "d:\cores2022\rf6809\software\boot\timer.asm"
 
OPT INCLUDE "d:\cores2022\rf6809\software\boot\i2c.asm"
 
OPT INCLUDE "d:\cores2022\rf6809\software\boot\rtc_driver.asm"
 
 
 
;==============================================================================
; Keyboard I/O
; Keyboard I/O
;==============================================================================
;==============================================================================
 
 
OPT INCLUDE "d:\cores2022\rf6809\software\boot\scancodes.asm"
OPT INCLUDE "d:\cores2022\rf6809\software\boot\scancodes.asm"
OPT INCLUDE "d:\cores2022\rf6809\software\boot\keyboard.asm"
OPT INCLUDE "d:\cores2022\rf6809\software\boot\keyboard.asm"
Line 985... Line 1091...
        rts
        rts
 
 
KeybdSeek:
KeybdSeek:
        rts
        rts
 
 
 
;==============================================================================
 
; Serial I/O
 
;==============================================================================
 
 
 
OPT INCLUDE "d:\cores2022\rf6809\software\boot\serial.asm"
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Check if there is a keyboard character available. If so return true (<0)
; Check if there is a keyboard character available. If so return true (<0)
; otherwise return false (0) in accb.
; otherwise return false (0) in accb.
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
Line 996... Line 1108...
        bra             DBGCheckForKey
        bra             DBGCheckForKey
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
INCH:
INCH:
        ldd             #-1                             ; block if no key available
        pshs    b
        bra             DBGGetKey
INCH2:
 
        ldb             COREID
 
        cmpb    IOFocusID       ; if we do not have focus, block
 
        bne             INCH2
 
;       ldb             #$800                   ; block if no key available, get scancode directly
 
;       bra             GetKey
 
;       jsr             [CharInVec]     ; vector is being overwritten somehow
 
        lbsr    SerialPeekCharDirect
 
        tsta
 
        bmi             INCH1                   ; block if no key available
 
        leas    1,s                             ; get rid of blocking status
 
        rts
 
INCH1:
 
        puls    b                                       ; check blocking status
 
        tstb
 
        bmi     INCH                    ; if blocking, loop
 
        ldd             #-1                             ; return -1 if no char available
 
        rts
 
 
INCHE:
INCHE:
        bsr             INCH
        bsr             INCH
        bra             INCHEK3
        bra             INCHEK3
 
 
Line 1013... Line 1142...
        cmpa    #CR
        cmpa    #CR
        bne             INCHEK2
        bne             INCHEK2
        lbsr            CRLF
        lbsr            CRLF
        bra             INCHEK1
        bra             INCHEK1
INCHEK2:
INCHEK2:
        bsr             DisplayChar
        lbsr    DisplayChar
INCHEK1:
INCHEK1:
        rts
        rts
 
 
OUTCH:
OUTCH:
        jmp             [CharOutVec]
        jmp             [CharOutVec]
Line 1040... Line 1169...
        stx             SPRITE_CTRL+SPRITE_EN
        stx             SPRITE_CTRL+SPRITE_EN
        std             SPRITE_CTRL+SPRITE_EN+2
        std             SPRITE_CTRL+SPRITE_EN+2
        rts
        rts
 
 
;==============================================================================
;==============================================================================
 
; Femtiki Operating System.
 
;==============================================================================
 
 
 
OSCallTbl:
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             0
 
        fcw             ReleaseIOFocus
 
        fcw             0
 
        fcw             RequestIOFocus
 
 
 
OSCall:
 
        ; wait for availability
 
osc1:
 
        tst             OSSEMA+1
 
        beq             osc1
 
        aslb
 
        ldx             #OSCallTbl
 
        abx
 
        tst             ,x
 
        beq             oscx
 
        jmp             [,x]
 
oscx:
 
        clr             OSSEMA+1
 
        rts
 
 
 
RequestIOFocus:
 
        ldb             COREID
 
        ldx             #IOFocusList
 
        abx
 
        sta             ,x
 
        tst             IOFocusID
 
        lbne    oscx
 
        stb             IOFocusID
 
        lbra    oscx
 
 
 
ReleaseIOFocus:
 
        ldb             COREID
 
        ldx             #IOFocusList
 
        abx
 
        clr             ,x                                              ; clear the request indicator
 
        lbsr    CopyScreenToVirtualScreen
 
        cmpb    IOFocusID                       ; are we the one with the focus?
 
        lbne    oscx
 
        ; We had the focus, so now a new core needs the focus.
 
        ; Search the focus list for a requestor. If no requester
 
        ; is found, give focus to core #1.
 
        lda             #15
 
riof2:
 
        incb
 
        andb    #15
 
        abx
 
        tst             ,x
 
        bne             riof1
 
        deca
 
        bne             riof2
 
        ; If no focus is requested by anyone, give to core #1
 
        ldb             #1
 
        lda             #24
 
        sta             ,x
 
riof1:
 
        stb             IOFocusID
 
        lbsr    CopyVirtualScreenToScreen
 
        lbra    oscx
 
 
 
 
 
;==============================================================================
 
; Disassembler
 
;==============================================================================
 
 
 
OPT     include "d:\cores2022\rf6809\software\boot\disassem.asm"
 
 
 
;==============================================================================
; System Monitor
; System Monitor
;==============================================================================
;==============================================================================
;
 
 
CmdPrompt:
 
        lbsr    CRLF
 
        ldb             #'$'
 
        lbsr    OUTCH
 
        lbra    OUTCH
 
 
 
msgF09Starting:
 
        fcb             "Femtiki F09 Multi-core OS Starting",CR,LF,0
 
 
MonitorStart:
MonitorStart:
 
        ldd             #msgF09Starting
 
        lbsr    DisplayString
        ldd             #HelpMsg
        ldd             #HelpMsg
        bsr             DisplayString
        lbsr    DisplayString
 
        ldd             #CmdPrompt
 
        std             CmdPromptJI
Monitor:
Monitor:
        leas    $3FFF                           ; reset stack pointer
        leas    $6FFF                           ; reset stack pointer
        clrb                                                    ; turn off keyboard echo
        clrb                                                    ; turn off keyboard echo
        bsr             SetKeyboardEcho
        lbsr    SetKeyboardEcho
 
        ; Reset IO vectors
 
        ldd             #SerialPeekCharDirect
 
        std             CharInVec
 
        ldd             #DisplayChar
 
        std             CharOutVec
 
        ldd             #CmdPrompt
 
        std             CmdPromptJI
;       jsr             RequestIOFocus
;       jsr             RequestIOFocus
PromptLn:
PromptLn:
        lbsr    CRLF
        jsr             [CmdPromptJI]
        ldb             #'$'
 
        bsr             OUTCH
 
 
 
; Get characters until a CR is keyed
; Get characters until a CR is keyed
 
 
Prompt3:
Prompt3:
        ldd             #-1                                     ; block until key present
        ldd             #-1                                     ; block until key present
        bsr             DBGGetKey
        lbsr    INCH
        cmpb    #CR
        cmpb    #CR
        beq             Prompt1
        beq             Prompt1
        bsr             OUTCH
        lbsr    OUTCH
        bra             Prompt3
        bra             Prompt3
 
 
; Process the screen line that the CR was keyed on
; Process the screen line that the CR was keyed on
;
;
Prompt1:
Prompt1:
        ldd             #$5050
        ldd             #$5050
        std             LEDS
        std             LEDS
        ldb             RunningID
;       ldb             RunningID
        cmpb    #61
;       cmpb    #61
        bhi             Prompt3
;       bhi             Prompt3
        ldd             #$5151
        ldd             #$5151
        std             LEDS
        std             LEDS
        clr             CursorCol                       ; go back to the start of the line
        clr             CursorCol                       ; go back to the start of the line
        bsr             CalcScreenLoc   ; calc screen memory location
        lbsr    CalcScreenLoc   ; calc screen memory location
        tfr             d,y
        tfr             d,y
        ldd             #$5252
        ldd             #$5252
        std             LEDS
        std             LEDS
 
skipDollar:
        bsr             MonGetNonSpace
        bsr             MonGetNonSpace
        cmpb    #'$'
        cmpb    #'$'
        bne             Prompt2                 ; skip over '$' prompt character
        beq             skipDollar              ; skip over '$' prompt character
        lda             #$5353
        lda             #$5353
        std             LEDS
        std             LEDS
        bsr             MonGetNonSpace
 
 
 
; Dispatch based on command character
; Dispatch based on command character
;
;
Prompt2:
Prompt2:
 
        cmpb    #'<'
 
        bne             PromptHelp
 
        bsr             MonGetch
 
        cmpb    #'>'
 
        bne             Monitor
 
        bsr             MonGetch
 
        cmpb    #'s'
 
        bne             Prompt2a
 
        ldd             #SerialPeekCharDirect
 
        std             CharInVec
 
        ldd             #SerialPutChar
 
        std             CharOutVec
 
        bra             Monitor
 
Prompt2a:
 
        cmpb    #'c'
 
        bne             Monitor
 
        ldd             #GetKey
 
        std             CharInVec
 
        ldd             #DisplayChar
 
        std             CharOutVec
 
        bra             Monitor
 
PromptHelp:
        cmpb    #'?'                    ; $? - display help
        cmpb    #'?'                    ; $? - display help
        bne             PromptC
        bne             PromptC
        ldd             #HelpMsg
        ldd             #HelpMsg
        bsr             DisplayString
        lbsr    DisplayString
        bra             Monitor
        bra             Monitor
PromptC:
PromptC:
        cmpb    #'C'
        cmpb    #'C'
        bne             PromptD
        bne             PromptD
        lbsr            ClearScreen
        lbsr            ClearScreen
        bsr             HomeCursor
        lbsr    HomeCursor
        bra             Monitor
        bra             Monitor
PromptD:
PromptD:
        cmpb    #'D'
        cmpb    #'D'
        bne             PromptF
        bne             PromptF
        bsr             MonGetch
        bsr             MonGetch
        cmpb    #'R'
        cmpb    #'R'
        bne             Prompt3
        bne             DumpMemory
        bra             DumpRegs
        bra             DumpRegs
PromptF:
PromptF:
        cmpb    #'F'
        cmpb    #'F'
        bne             PromptJ
        bne             PromptJ
        bsr             MonGetch
        bsr             MonGetch
Line 1124... Line 1385...
PromptJ:
PromptJ:
        cmpb    #'J'
        cmpb    #'J'
        lbeq    jump_to_code
        lbeq    jump_to_code
PromptR:
PromptR:
        cmpb    #'R'
        cmpb    #'R'
 
        bne             Prompt_s
 
        ldu             #Monitor
 
        lbra    ramtest
 
Prompt_s:
 
        cmpb    #'s'
 
        bne             PromptT
 
        lbsr    SerialOutputTest
 
        bra             Monitor
 
PromptT:
 
        cmpb    #'T'
 
        bne             PromptU
 
        bsr             MonGetch
 
        cmpb    #'I'
 
        bne             Monitor
 
        bsr             MonGetch
 
        cmpb    #'R'
        bne             Monitor
        bne             Monitor
        lbsr    ramtest
        lbsr    rtc_read
        bra             Monitor
        bra             Monitor
 
PromptU:
 
        cmpb    #'U'
 
        bne             Monitor
 
        lbra    disassem
 
 
MonGetch:
MonGetch:
        ldb             ,y
        ldb             ,y
        leay    1,y
        iny
        rts
        rts
 
 
MonGetNonSpace:
MonGetNonSpace:
        bsr             MonGetCh
        bsr             MonGetCh
        cmpb    #' '
        cmpb    #' '
        beq             MonGetNonSpace
        beq             MonGetNonSpace
        cmpb    #9              ; tab
 
        beq             MonGetNonSpace
 
        rts
        rts
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Ignore blanks in the input
; Ignore blanks in the input
; Y = text pointer
; Y = text pointer
Line 1152... Line 1431...
ignBlanks:
ignBlanks:
ignBlanks1:
ignBlanks1:
        bsr             MonGetch
        bsr             MonGetch
        cmpb    #' '
        cmpb    #' '
        beq             ignBlanks1
        beq             ignBlanks1
        leay    -1,y
        dey
        rts
        rts
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
GetTwoParams:
GetTwoParams:
Line 1193... Line 1472...
        rol             mon_numwka+1
        rol             mon_numwka+1
        rol             mon_numwka
        rol             mon_numwka
        rts
        rts
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Get a hexidecimal number. Maximum of nine digits.
; Get a hexidecimal number. Maximum of twelve digits.
 
;
 
; Modifies:
; Y = text pointer (updated)
; Y = text pointer (updated)
; D = number of digits
; D = number of digits
; mon_numwka contains number
; mon_numwka contains number
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
GetHexNumber:
GetHexNumber:
        clrd
        clrd
        std             mon_numwka
        std             mon_numwka      ; zero out work area
        std             mon_numwka+2
        std             mon_numwka+2
        pshs    x
        pshs    x
        ldx             #0                                      ; max 9 eight digits
        ldx             #0                                      ; max 12 eight digits
gthxn2:
gthxn2:
        bsr             MonGetch
        bsr             MonGetch
        bsr             AsciiToHexNybble
        bsr             AsciiToHexNybble
        cmpb    #-1
        cmpb    #-1
        beq             gthxn1
        beq             gthxn1
Line 1218... Line 1499...
        bsr             shl_numwka
        bsr             shl_numwka
        andb    #$0f
        andb    #$0f
        orb             mon_numwka+3
        orb             mon_numwka+3
        stb             mon_numwka+3
        stb             mon_numwka+3
        inx
        inx
        cmpx    #9
        cmpx    #12
        blo             gthxn2
        blo             gthxn2
gthxn1:
gthxn1:
        tfr             x,d
        tfr             x,d
        puls    x,pc
        puls    x,pc
 
 
Line 1254... Line 1535...
; to a hex nybble.
; to a hex nybble.
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
AsciiToHexNybble:
AsciiToHexNybble:
        cmpb    #'0'
        cmpb    #'0'
        bcc             gthx3
        blo             gthx3
        cmpb    #'9'+1
        cmpb    #'9'
        bcs             gthx5
        bhi             gthx5
        subb    #'0'
        subb    #'0'
        rts
        rts
gthx5:
gthx5:
        cmpb    #'A'
        cmpb    #'A'
        bcc             gthx3
        blo             gthx3
        cmpb    #'F'+1
        cmpb    #'F'
        bcs             gthx6
        bhi             gthx6
        subb    #'A'
        subb    #'A'
        addb    #10
        addb    #10
        rts
        rts
gthx6:
gthx6:
        cmpb    #'a'
        cmpb    #'a'
        bcc             gthx3
        blo             gthx3
        cmpb    #'z'+1
        cmpb    #'z'
        bcs             gthx3
        bhi             gthx3
        subb    #'a'
        subb    #'a'
        addb    #10
        addb    #10
        rts
        rts
gthx3:
gthx3:
        ldb             #-1             ; not a hex number
        ldb             #-1             ; not a hex number
Line 1313... Line 1594...
;       db      "S = Boot from SD Card",CR,LF
;       db      "S = Boot from SD Card",CR,LF
;       db      ": = Edit memory bytes",CR,LF
;       db      ": = Edit memory bytes",CR,LF
;       db      "L = Load sector",CR,LF
;       db      "L = Load sector",CR,LF
;       db      "W = Write sector",CR,LF
;       db      "W = Write sector",CR,LF
        fcb "DR = Dump registers",CR,LF
        fcb "DR = Dump registers",CR,LF
;       db      "D = Dump memory",CR,LF
        fcb     "D = Dump memory",CR,LF
;       db      "F = Fill memory",CR,LF
;       db      "F = Fill memory",CR,LF
;       db  "FL = Dump I/O Focus List",CR,LF
;       db  "FL = Dump I/O Focus List",CR,LF
        fcb "FIG = start FIG Forth",CR,LF
        fcb "FIG = start FIG Forth",CR,LF
;       db      "KILL n = kill task #n",CR,LF
;       db      "KILL n = kill task #n",CR,LF
;       db      "B = start tiny basic",CR,LF
;       db      "B = start tiny basic",CR,LF
Line 1325... Line 1606...
        fcb     "J = Jump to code",CR,LF
        fcb     "J = Jump to code",CR,LF
        fcb "RAM = test RAM",CR,LF
        fcb "RAM = test RAM",CR,LF
;       db      "R[n] = Set register value",CR,LF
;       db      "R[n] = Set register value",CR,LF
;       db      "r = random lines - test bitmap",CR,LF
;       db      "r = random lines - test bitmap",CR,LF
;       db      "e = ethernet test",CR,LF
;       db      "e = ethernet test",CR,LF
 
        fcb     "s = serial output test",CR,LF
;       db      "T = Dump task list",CR,LF
;       db      "T = Dump task list",CR,LF
;       db      "TO = Dump timeout list",CR,LF
;       db      "TO = Dump timeout list",CR,LF
;       db      "TI = display date/time",CR,LF
        fcb     "TI = display date/time",CR,LF
;       db      "TEMP = display temperature",CR,LF
;       db      "TEMP = display temperature",CR,LF
;       db      "P = Piano",CR,LF,0
;       db      "P = Piano",CR,LF,0
        fcb             0
        fcb             0
 
 
msgRegHeadings
msgRegHeadings
Line 1341... Line 1623...
        jsr             HEX4
        jsr             HEX4
        rts
        rts
 
 
nXBLANK:
nXBLANK:
        ldb             #' '
        ldb             #' '
        bra             OUTCH
        lbra    OUTCH
 
 
 
;------------------------------------------------------------------------------
 
; Dump Memory
 
;
 
; Usage:
 
;       $D FFFC12 8
 
;
 
; Dump formatted to look like:
 
;               :FFFC12 012 012 012 012 555 666 777 888
 
;
 
;------------------------------------------------------------------------------
 
 
 
DumpMemory:
 
        bsr             GetTwoParams
 
        ldy             #0
 
        ldy             mon_r1+2
 
dmpm2:
 
        lbsr    CRLF
 
        ldb             #':'
 
        lbsr    OUTCH
 
        tfr             y,d
 
        ;addd   mon_r1+2                                        ; output the address
 
        lbsr    DispWordAsHex
 
        ldb             #' '
 
        lbsr    OUTCH
 
        ldx             #8                                                              ; number of bytes to display
 
dmpm1:
 
;       ldb             far [mon_r1+1],y
 
        ;ldb            [mon_r1+2],y
 
        ldb             ,y
 
        iny
 
        lbsr    DispByteAsHex                   ; display byte
 
        ldb             #' '                                                    ; followed by a space
 
        lbsr    OUTCH
 
        clrb
 
        clra
 
        lbsr    INCH
 
        cmpb    #CTRLC
 
        beq             dmpm3
 
        dex
 
        bne             dmpm1
 
        ; Now output ascii
 
        ldb             #' '
 
        lbsr    OUTCH
 
        ldx             #8                                                              ; 8 chars to output
 
        leay    -8,y                                                    ; backup pointer
 
dmpm5:
 
;       ldb             far [mon_r1+1],y        ; get the char
 
;       ldb             [mon_r1+2],y                    ; get the char
 
        ldb             ,y
 
        cmpb    #$20                                                    ; is it a control char?
 
        bhs             dmpm4
 
        ldb             #'.'
 
dmpm4:
 
        lbsr    OUTCH
 
        iny
 
        dex
 
        bne             dmpm5
 
        cmpy    mon_r2+2
 
        blo             dmpm2
 
dmpm3:
 
        lbsr    CRLF
 
        lbra    Monitor
 
 
 
;------------------------------------------------------------------------------
 
; Dump Registers
 
;
 
;       Usage:
 
;               $DR
 
;------------------------------------------------------------------------------
 
 
DumpRegs
DumpRegs:
        ldx             #msgRegHeadings
        ldd             #msgRegHeadings
        ldd             #msgRegHeadings>>16
        lbsr    DisplayString
        jsr             DisplayStringDX
 
        bsr             nXBLANK
        bsr             nXBLANK
        ldd             mon_DSAVE
        ldd             mon_DSAVE
        bsr             nHEX4
        bsr             nHEX4
        bsr             nXBLANK
        bsr             nXBLANK
        ldd             mon_XSAVE
        ldd             mon_XSAVE
Line 1363... Line 1714...
        bsr             nHEX4
        bsr             nHEX4
        bsr             nXBLANK
        bsr             nXBLANK
        ldd             mon_SSAVE
        ldd             mon_SSAVE
        bsr             nHEX4
        bsr             nHEX4
        bsr             nXBLANK
        bsr             nXBLANK
        ldd             mon_PCSAVE
        ldb             mon_PCSAVE+1
        bsr             nHEX4
        lbsr    DispByteAsHex
        ldd             mon_PCSAVE+2
        ldd             mon_PCSAVE+2
        bsr             nHEX4
        bsr             nHEX4
        bsr             nXBLANK
        bsr             nXBLANK
        ldd             mon_DPRSAVE
        ldd             mon_DPRSAVE
        jsr             HEX2
        jsr             HEX2
        bsr             nXBLANK
        bsr             nXBLANK
        lda             mon_CCRSAVE
        lda             mon_CCRSAVE
        jsr             HEX2
        lbsr    HEX2
        bsr             nXBLANK
        bsr             nXBLANK
        jmp             Monitor
        lbra    Monitor
 
 
 
;------------------------------------------------------------------------------
; Jump to code
; Jump to code
 
;
 
; Registers are loaded with values from the monitor register save area before
 
; the code is jumped to.
 
;
 
; J 
 
;------------------------------------------------------------------------------
 
 
jump_to_code:
jump_to_code:
        bsr             GetHexNumber
        bsr             GetHexNumber
        sei
        sei
        lds             mon_SSAVE
        lds             mon_SSAVE
        ldd             #
        ldd             #
        pshs    d
        pshs    d
        ldd             #>jtc_exit
        ldb             #>jtc_exit
        pshs    b
        pshs    b
        ldd             mon_numwka+2
        ldd             mon_numwka+2
        pshs    d
        pshs    d
        ldd             mon_numwka
        ldb             mon_numwka+1
        pshs    d
        pshs    b
        ldd             mon_USAVE
        ldd             mon_USAVE
        pshs    d
        pshs    d
        ldd             mon_YSAVE
        ldd             mon_YSAVE
        pshs    d
        pshs    d
        ldd             mon_XSAVE
        ldd             mon_XSAVE
Line 1403... Line 1762...
        pshs    d
        pshs    d
        lda             mon_CCRSAVE
        lda             mon_CCRSAVE
        pshs    a
        pshs    a
        puls    far ccr,d,dpr,x,y,u,pc
        puls    far ccr,d,dpr,x,y,u,pc
jtc_exit:
jtc_exit:
        pshs    ccr
        sts             >mon_SSAVE              ; need to use extended addressing, no direct page setting
        std             mon_DSAVE
        leas    $6FFF                                   ; reset stack to system area, dont modify flags register!
 
        pshs    ccr                                             ; now the stack can be used
 
        pshs    a                                                       ; save acca register so we can use it
 
        tfr             dpr,a                                   ; a = outgoing dpr value
 
        sta             >mon_DPRSAVE    ; force extended addressing mode usage here dpr is not set
 
        clra                                                            ; dpg register must be set to zero before values are
 
        tfr             a,dpr                                   ; saved in the monitor register save area.
 
        puls    a                                                       ; get back acca
 
        std             mon_DSAVE                       ; save regsters, can use direct addressing now
        stx             mon_XSAVE
        stx             mon_XSAVE
        sty             mon_YSAVE
        sty             mon_YSAVE
        stu             mon_USAVE
        stu             mon_USAVE
        tfr             dpr,a
        puls    a                                                       ; get back ccr
        sta             mon_DPRSAVE
        sta             mon_CCRSAVE             ; and save it too
        puls    a
        ; Reset vectors in case they got toasted.
        sta             mon_CCRSAVE
        ldd             #SerialPeekCharDirect
        sts             mon_SSAVE
        std             CharInVec
        lds             #$3FFF
        ldd             #DisplayChar
 
        std             CharOutVec
        ; todo set according to coreid
        ; todo set according to coreid
        jmp             DumpRegs
        lbra    DumpRegs                        ; now go do a register dump
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
swi3_rout:
swi3_rout:
        sei
        sei
Line 1430... Line 1798...
        stx             mon_XSAVE
        stx             mon_XSAVE
        sty             mon_YSAVE
        sty             mon_YSAVE
        stu             mon_USAVE
        stu             mon_USAVE
        tfr             dpr,a
        tfr             dpr,a
        sta             mon_DPRSAVE
        sta             mon_DPRSAVE
 
        puls    a
 
        sta             mon_PCSAVE
        puls    D
        puls    D
        std             mon_PCSAVE
        std             mon_PCSAVE+1
        puls    D
 
        std             mon_PCSAVE+2
 
        sts             mon_SSAVE
        sts             mon_SSAVE
        lds             #$3FFF
        lds             #$3FFF
        cli
        cli
        jmp             DumpRegs
        jmp             DumpRegs
swi3_exit:
swi3_exit:
        sei
        sei
        lds             mon_SSAVE
        lds             mon_SSAVE
        ldd             mon_PCSAVE+2
        ldd             mon_PCSAVE+1
        pshs    d
 
        ldd             mon_PCSAVE
 
        pshs    d
        pshs    d
 
        lda             mon_PCSAVE
 
        pshs    a
        ldu             mon_USAVE
        ldu             mon_USAVE
        ldy             mon_YSAVE
        ldy             mon_YSAVE
        ldx             mon_XSAVE
        ldx             mon_XSAVE
        pshs    x,y,u
        pshs    x,y,u
        lda             mon_DPRSAVE
        lda             mon_DPRSAVE
Line 1461... Line 1829...
        cli
        cli
        rti
        rti
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
 
firq_rout:
 
        rti
 
 
irq_rout:
irq_rout:
        ; Reset the edge sense circuit in the PIC
;       lbsr    SerialIRQ       ; check for recieved character
        lda             #2                              ; Timer is IRQ #2
;       lbsr    TimerIRQ
        sta             PIC+6                   ; register 6 is edge sense reset reg
 
 
 
 
        ; Reset the edge sense circuit in the PIC
 
        lda             #31                                                     ; Timer is IRQ #31
        sta             IrqSource               ; stuff a byte indicating the IRQ source for PEEK()
        sta             IrqSource               ; stuff a byte indicating the IRQ source for PEEK()
 
        sta             PIC+16                                  ; register 16 is edge sense reset reg
 
        lda             VIA+VIA_IFR
 
        bpl             notTimerIRQ2
 
        bita    #$800
 
        beq             notTimerIRQ2
 
        clr             VIA+VIA_T3LL
 
        clr             VIA+VIA_T3LH
 
        inc             $E00037                                 ; update timer IRQ screen flag
 
notTimerIRQ2:
 
 
        lda             IrqBase                 ; get the IRQ flag byte
        lda             IrqBase                 ; get the IRQ flag byte
        lsra
        lsra
        ora             IrqBase
        ora             IrqBase
        anda    #$E0
        anda    #$E0
        sta             IrqBase
        sta             IrqBase
 
 
        inc             TEXTSCR+110             ; update IRQ live indicator on screen
;       inc             TEXTSCR+54              ; update IRQ live indicator on screen
 
 
        ; flash the cursor
        ; flash the cursor
        ; only bother to flash the cursor for the task with the IO focus.
        ; only bother to flash the cursor for the task with the IO focus.
        lda             COREID
;       lda             COREID
        cmpa    IOFocusID
;       cmpa    IOFocusID
        bne             tr1a
;       bne             tr1a
        lda             CursorFlash             ; test if we want a flashing cursor
;       lda             CursorFlash             ; test if we want a flashing cursor
        beq             tr1a
;       beq             tr1a
        lbsr    CalcScreenLoc   ; compute cursor location in memory
;       lbsr    CalcScreenLoc   ; compute cursor location in memory
        tfr             d,y
;       tfr             d,y
        lda             $2000,y                 ; get color code $2000 higher in memory
;       lda             $2000,y                 ; get color code $2000 higher in memory
        ldb             IRQFlag                 ; get counter
;       ldb             IRQFlag                 ; get counter
        lsrb
;       lsrb
        lsra
;       lsra
        lsra
;       lsra
        lsra
;       lsra
        lsra
;       lsra
        lsrb
;       lsrb
        rola
;       rola
        lsrb
;       lsrb
        rola
;       rola
        lsrb
;       lsrb
        rola
;       rola
        lsrb
;       lsrb
        rola
;       rola
        sta             $E00000,y               ; store the color code back to memory
;       sta             $E00000,y               ; store the color code back to memory
tr1a
tr1a:
        rti
        rti
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
nmi_rout:
nmi_rout:
        ldb             COREID
        ldb             COREID
        lda             #'I'
        lda             #'I'
        ldx             #TEXTSCR+40
        ldx             #TEXTSCR+40
        abx
        sta             b,x
        sta             ,x
rti_insn:
        rti
        rti
 
 
        org             $FFFFF0
; Special Register Area
        nop
        org             $FFFFE0
        nop
 
        fcw             swi3_rout
 
 
 
        org             $FFFFF8
; Interrupt vector table
        fcw             irq_rout
 
 
        org             $FFFFF0
 
        fcw             rti_insn                ; reserved
 
        fcw             swi3_rout               ; SWI3
 
        fcw             rti_insn                ; SWI2
 
        fcw             firq_rout               ; FIRQ
 
        fcw             irq_rout                ; IRQ
        fcw             start                           ; SWI
        fcw             start                           ; SWI
        fcw             nmi_rout                ; NMI
        fcw             nmi_rout                ; NMI
        fcw             start                           ; RST
        fcw             start                           ; RST

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.