Subversion Repositories Spectranet

[/] [branches/] [gnubinutils/] [rom/] [zeropage.asm] - Diff between revs 371 and 384

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

Rev 371 Rev 384
Line 17... Line 17...
;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
;THE SOFTWARE.
;THE SOFTWARE.
 
.include        "sysdefs.inc"
 
.include        "sysvars.inc"
 
.include        "spectranet.inc"
 
 
; ZEROPAGE ENTRY POINTS
; ZEROPAGE ENTRY POINTS
; This file should be included first in "rom.asm"; it sets the org.
; This file should be included first in "rom.asm0"; it sets the org.
;
;
; RST 0xNN instructions - This is where all the restarts live:
; RST 0xNN instructions - This is where all the restarts live:
; 00    Reset
; 00    Reset
; 08    Entry point for BASIC traps
; 08    Entry point for BASIC traps
; 10    CALLBAS restart for BASIC extensions
; 10    CALLBAS restart for BASIC extensions
Line 33... Line 36...
; 30
; 30
; 38    Maskable interrupt service routine
; 38    Maskable interrupt service routine
;
;
; NMI entry point at 0x0066
; NMI entry point at 0x0066
; Unpage entry point at 0x007C
; Unpage entry point at 0x007C
 
.section rst0
        org 0x0000
RESET:
RESET
 
        di              ; This should be done already for a real reset.
        di              ; This should be done already for a real reset.
        jp J_reset
        jp J_reset
 
 
        block 0x08-$,0xFF
.section rst8
TRAPBAS
TRAPBAS:
        jp do_rst8
        jp do_rst8
        block 0x10-$,0xFF
.section rst10
CALLBAS
CALLBAS:
        ld (v_hlsave), hl
        ld (v_hlsave), hl
        ld (v_desave), de
        ld (v_desave), de
        pop hl
        pop hl
        jp do_callbas
        jp do_callbas
        block 0x28-$,0xFF
.section rst28
MODULECALL_NOPAGE
MODULECALL_NOPAGE:
        jp J_moduledispatch
        jp J_moduledispatch
        block 0x30-$,0xFF
.section rst30
MODULECALL
MODULECALL:
        call J_moduledispatch
        call J_moduledispatch
        ex (sp), hl             ; throw away return to 0x3FF9
        ex (sp), hl             ; throw away return to 0x3FF9
        pop hl
        pop hl
        jr UNPAGE               ; unpage and return to caller
        jr UNPAGE               ; unpage and return to caller
        block 0x38-$,0xFF
.section isr
INTERRUPT
INTERRUPT:                      ; 0x0038
        push hl
        push hl
        ld hl, (v_intcount)     ; really, just to indicate that an
        ld hl, (v_intcount)     ; really, just to indicate that an
        inc hl                  ; interrupt took place
        inc hl                  ; interrupt took place
        ld (v_intcount), hl
        ld (v_intcount), hl
        pop hl
        pop hl
        ei
        ei
        reti                    ; TODO - do something!
        reti                    ; TODO - do something!
 
 
        block 0x66-$,0xFF
.section nmi                    ; 0x0066
NMI
 
        ld (NMISTACK), sp       ; save SP
        ld (NMISTACK), sp       ; save SP
        ld sp, NMISTACK-4       ; set up new stack
        ld sp, NMISTACK-4       ; set up new stack
 
 
        ; stack everything that will be changed.
        ; stack everything that will be changed.
        push hl
        push hl
Line 82... Line 83...
        ex af, af'
        ex af, af'
        push af
        push af
        ld hl, (NMISTACK)       ; HL = address of the return address
        ld hl, (NMISTACK)       ; HL = address of the return address
        jr NMI2
        jr NMI2
 
 
        block 0x7B-$,0xFF
 
        ; When unpaging, put the address where you want to end up on
        ; When unpaging, put the address where you want to end up on
        ; the stack, and the RET instruction will set the PC to this address.
        ; the stack, and the RET instruction will set the PC to this address.
 
.section unpage                 ; 0x007B
        ei
        ei
UNPAGE
UNPAGE:
        ret
        ret
NMI2
.text
 
NMI2:
        ld bc, CTRLREG          ; test for trap enable
        ld bc, CTRLREG          ; test for trap enable
        in a, (c)
        in a, (c)
        and MASK_PROGTRAP_EN
        and MASK_PROGTRAP_EN
        jr z, .nmimenu          ; not enabled
        jr z, .nmimenu0         ; not enabled
        ld a, (v_trapcomefrom)  ; get comefrom address LSB
        ld a, (v_trapcomefrom)  ; get comefrom address LSB
        cp (hl)                 ; equal to low order?
        cp (hl)                 ; equal to low order?
        jr nz, .nmimenu         ; no
        jr nz, .nmimenu0                ; no
        inc hl                  ; return address MSB
        inc hl                  ; return address MSB
        ld a, (v_trapcomefrom+1) ; comefrom MSB
        ld a, (v_trapcomefrom+1) ; comefrom MSB
        cp (hl)                 ; equal to high order?
        cp (hl)                 ; equal to high order?
        jr nz, .nmimenu         ; no
        jr nz, .nmimenu0                ; no
 
 
        ; Set up the environment ready to handle the trap.
        ; Set up the environment ready to handle the trap.
        ld a, (v_trappage)      ; get the page to page in
        ld a, (v_trappage)      ; get the page to page in
        and a                   ; if it's zero though, ignore it.
        and a                   ; if it's zero though, ignore it.
        call nz, F_pushpageB    ; page in requested page, stacking current
        call nz, F_pushpageB    ; page in requested page, stacking current
        ld hl, (v_trapaddr)     ; no paging to be done - just get the call addr
        ld hl, (v_trapaddr)     ; no paging to be done - just get the call addr
        jp (hl)                 ; jump to it
        jp (hl)                 ; jump to it
 
 
.nmimenu
.nmimenu0:
        ld a, 0x02              ; Utility ROM
        ld a, 0x02              ; Utility ROM
        call F_setpageB
        call F_setpageB
        ld hl, (NMI_VECTOR)     ; Test NMI_VECTOR
        ld hl, (NMI_VECTOR)     ; Test NMI_VECTOR
        ld a, 0xFF
        ld a, 0xFF
        cp h                    ; FF = unset
        cp h                    ; FF = unset
        jr z, .nmidone
        jr z, .nmidone0
        ld de, .nmidone         ; get return address
        ld de, .nmidone0                ; get return address
        push de                 ; save it, so subsequent RET comes back
        push de                 ; save it, so subsequent RET comes back
        jp (hl)                 ; jump to the NMI vector
        jp (hl)                 ; jump to the NMI vector
.nmidone
.nmidone0:
        pop af
        pop af
        ex af, af'
        ex af, af'
        pop af
        pop af
        pop bc
        pop bc
        pop de
        pop de