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

Subversion Repositories rtf65002

[/] [rtf65002/] [trunk/] [software/] [asm/] [bootrom.asm] - Diff between revs 15 and 18

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

Rev 15 Rev 18
Line 104... Line 104...
asl
asl
endm
endm
 
 
; BIOS vars at the top of the 8kB scratch memory
; BIOS vars at the top of the 8kB scratch memory
;
;
 
JMPTMP          EQU             0x7A0
 
SP8Save         EQU             0x7AE
 
SRSave          EQU             0x7AF
 
R1Save          EQU             0x7B0
 
R2Save          EQU             0x7B1
 
R3Save          EQU             0x7B2
 
R4Save          EQU             0x7B3
 
R5Save          EQU             0x7B4
 
R6Save          EQU             0x7B5
 
R7Save          EQU             0x7B6
 
R8Save          EQU             0x7B7
 
R9Save          EQU             0x7B8
 
R10Save         EQU             0x7B9
 
R11Save         EQU             0x7BA
 
R12Save         EQU             0x7BB
 
R13Save         EQU             0x7BC
 
R14Save         EQU             0x7BD
 
R15Save         EQU             0x7BE
 
SPSave          EQU             0x7BF
 
 
CharColor       EQU             0x7C0
CharColor       EQU             0x7C0
ScreenColor     EQU             0x7C1
ScreenColor     EQU             0x7C1
CursorRow       EQU             0x7C2
CursorRow       EQU             0x7C2
CursorCol       EQU             0x7C3
CursorCol       EQU             0x7C3
CursorFlash     EQU             0x7C4
CursorFlash     EQU             0x7C4
Milliseconds    EQU             0x7C5
Milliseconds    EQU             0x7C5
 
IRQFlag         EQU             0x7C6
 
 
KeybdHead       EQU             0x7D0
KeybdHead       EQU             0x7D0
KeybdTail       EQU             0x7D1
KeybdTail       EQU             0x7D1
KeybdEcho       EQU             0x7D2
KeybdEcho       EQU             0x7D2
KeybdBad        EQU             0x7D3
KeybdBad        EQU             0x7D3
Line 144... Line 164...
        trs             r0,dp                   ; set direct page register
        trs             r0,dp                   ; set direct page register
        trs             r0,dp8                  ; and 8 bit mode direct page
        trs             r0,dp8                  ; and 8 bit mode direct page
        trs             r0,abs8                 ; and 8 bit mode absolute address offset
        trs             r0,abs8                 ; and 8 bit mode absolute address offset
 
 
        ; setup interrupt vectors
        ; setup interrupt vectors
        ldx             #$05FFF000              ; interrupt vector table from $5FFF000 to $5FFF1FF
        ldx             #$05FFF001              ; interrupt vector table from $5FFF000 to $5FFF1FF
 
                                                        ; also sets nmoi policy (native mode on interrupt)
        trs             r2,vbr
        trs             r2,vbr
 
        dex
        lda             #brk_rout
        lda             #brk_rout
        sta             (x)
        sta             (x)
        lda             #slp_rout
        lda             #slp_rout
        sta             1,x
        sta             1,x
        lda             #KeybdRST
        lda             #KeybdRST
Line 796... Line 818...
; Display the byte in r1
; Display the byte in r1
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
DisplayByte:
DisplayByte:
        pha
        pha
        lsr
        lsr             r1,r1,#4
        lsr
 
        lsr
 
        lsr
 
        jsr             DisplayNybble
        jsr             DisplayNybble
        pla
        pla
        jmp             DisplayNybble   ; tail rts
        jmp             DisplayNybble   ; tail rts
message "785"
message "785"
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Display the half-word in r1
; Display the half-word in r1
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
DisplayHalf:
DisplayHalf:
        pha
        pha
        m_lsr8
        lsr             r1,r1,#8
        jsr             DisplayByte
        jsr             DisplayByte
        pla
        pla
        jsr             DisplayByte
        jsr             DisplayByte
        rts
        rts
 
 
Line 823... Line 842...
; Display the half-word in r1
; Display the half-word in r1
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
DisplayWord:
DisplayWord:
        pha
        pha
        m_lsr8
        lsr             r1,r1,#16
        m_lsr8
 
        jsr             DisplayHalf
        jsr             DisplayHalf
        pla
        pla
        jsr             DisplayHalf
        jsr             DisplayHalf
        rts
        rts
message "810"
message "810"
Line 870... Line 888...
;==============================================================================
;==============================================================================
; System Monitor Program
; System Monitor Program
;==============================================================================
;==============================================================================
;
;
Monitor:
Monitor:
        ldx             #$1000                  ; top of stack; reset the stack pointer
        ldx             #$05FFFFF8              ; setup stack pointer top of memory
        txs
        txs
        stz             KeybdEcho               ; turn off keyboard echo
        stz             KeybdEcho               ; turn off keyboard echo
PromptLn:
PromptLn:
        jsr             CRLF
        jsr             CRLF
        lda             #'$'
        lda             #'$'
Line 913... Line 931...
;
;
Prompt2:
Prompt2:
        cmp             #':'
        cmp             #':'
        beq             EditMem
        beq             EditMem
        cmp             #'D'
        cmp             #'D'
        beq             DumpMem
        bne             Prompt8
 
        lda             (y)
 
        iny
 
        jsr             ScreenToAscii
 
        cmp             #'R'
 
        beq             DumpReg
 
        dey
 
        bra             DumpMem
 
Prompt8:
        cmp             #'F'
        cmp             #'F'
        beq             FillMem
        beq             FillMem
Prompt7:
Prompt7:
        cmp             #'B'                    ; $B - start tiny basic
        cmp             #'B'                    ; $B - start tiny basic
        bne             Prompt4
        bne             Prompt4
Line 999... Line 1025...
        db      "? = Display help",CR,LF
        db      "? = Display help",CR,LF
        db      "CLS = clear screen",CR,LF
        db      "CLS = clear screen",CR,LF
        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 S19 file",CR,LF
        db      "L = Load S19 file",CR,LF
 
        db  "DR = Dump registers",CR,LF
        db      "D = Dump memory",CR,LF
        db      "D = Dump memory",CR,LF
        db      "F = Fill memory",CR,LF
        db      "F = Fill memory",CR,LF
        db      "B = start tiny basic",CR,LF
        db      "B = start tiny basic",CR,LF
        db      "b = start EhBasic 6502",CR,LF
        db      "b = start EhBasic 6502",CR,LF
        db      "J = Jump to code",CR,LF
        db      "J = Jump to code",CR,LF
        db      "R = Random lines",CR,LF
        db      "R[n] = Set register value",CR,LF
        db      "T = get temperature",CR,LF
        db      "T = get temperature",CR,LF
        db      "P = Piano",CR,LF,0
        db      "P = Piano",CR,LF,0
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Ignore blanks in the input
; Ignore blanks in the input
Line 1049... Line 1076...
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
ExecuteCode:
ExecuteCode:
        jsr             ignBlanks
        jsr             ignBlanks
        jsr             GetHexNumber
        jsr             GetHexNumber
        jsr             (r1)
        st              r1,JMPTMP
 
        lda             #xcret                  ; push return address so we can do an indirect jump
 
        pha
 
        ld              r1,R1Save
 
        ld              r2,R2Save
 
        ld              r3,R3Save
 
        ld              r4,R4Save
 
        ld              r5,R5Save
 
        ld              r6,R6Save
 
        ld              r7,R7Save
 
        ld              r8,R8Save
 
        ld              r9,R9Save
 
        ld              r10,R10Save
 
        ld              r11,R11Save
 
        ld              r12,R12Save
 
        ld              r13,R13Save
 
        ld              r14,R14Save
 
        ld              r15,R15Save
 
        jmp             (JMPTMP)
 
xcret:
 
        php
 
        st              r1,R1Save
 
        st              r2,R2Save
 
        st              r3,R3Save
 
        st              r4,R4Save
 
        st              r5,R5Save
 
        st              r6,R6Save
 
        st              r7,R7Save
 
        st              r8,R8Save
 
        st              r9,R9Save
 
        st              r10,R10Save
 
        st              r11,R11Save
 
        st              r12,R12Save
 
        st              r13,R13Save
 
        st              r14,R14Save
 
        st              r15,R15Save
 
        tsr             sp,r1
 
        st              r1,SPSave
 
        tsr             sp8,r1
 
        st              r1,SP8Save
 
        pla
 
        sta             SRSave
        jmp     Monitor
        jmp     Monitor
 
 
LoadSector:
LoadSector:
        jsr             ignBlanks
        jsr             ignBlanks
        jsr             GetHexNumber
        jsr             GetHexNumber
        ld              r2,#0x3800
        ld              r2,#0x3800
        jsr             spi_read_sector
        jsr             spi_read_sector
        jmp             Monitor
        jmp             Monitor
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
 
; Dump the register set.
 
;------------------------------------------------------------------------------
 
DumpReg:
 
        ldy             #0
 
DumpReg1:
 
        jsr             CRLF
 
        lda             #':'
 
        jsr             DisplayChar
 
        lda             #'R'
 
        jsr             DisplayChar
 
        ldx             #0
 
        tya
 
        jsr             PRTNUM
 
        lda             #' '
 
        jsr             DisplayChar
 
        lda             R1Save,y
 
        jsr             DisplayWord
 
        iny
 
        cpy             #15
 
        bne             DumpReg1
 
        jsr             CRLF
 
        lda             #':'
 
        jsr             DisplayChar
 
        lda             #'S'
 
        jsr             DisplayChar
 
        lda             #'P'
 
        jsr             DisplayChar
 
        lda             #' '
 
        jsr             DisplayChar
 
        lda             SPSave
 
        jsr             DisplayWord
 
        jsr             CRLF
 
        rts
 
 
 
;------------------------------------------------------------------------------
; Do a memory dump of the requested location.
; Do a memory dump of the requested location.
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
DumpMem:
DumpMem:
        jsr             ignBlanks
        jsr             ignBlanks
Line 1119... Line 1222...
        iny
        iny
        jsr             ScreenToAscii
        jsr             ScreenToAscii
        jsr             AsciiToHexNybble
        jsr             AsciiToHexNybble
        cmp             #-1
        cmp             #-1
        beq             gthxn1
        beq             gthxn1
        asl             r2,r2
        asl             r2,r2,#4
        asl             r2,r2
 
        asl             r2,r2
 
        asl             r2,r2
 
        and             #$0f
        and             #$0f
        or              r2,r2,r1
        or              r2,r2,r1
        dec             r4
        dec             r4
        bne             gthxn2
        bne             gthxn2
gthxn1:
gthxn1:
Line 1242... Line 1342...
        phx
        phx
        phy
        phy
        push    r4
        push    r4
 
 
        sta             SPIMASTER+SPI_SD_SECT_7_0_REG
        sta             SPIMASTER+SPI_SD_SECT_7_0_REG
        m_lsr8
        lsr             r1,r1,#8
        sta             SPIMASTER+SPI_SD_SECT_15_8_REG
        sta             SPIMASTER+SPI_SD_SECT_15_8_REG
        m_lsr8
        lsr             r1,r1,#8
        sta             SPIMASTER+SPI_SD_SECT_23_16_REG
        sta             SPIMASTER+SPI_SD_SECT_23_16_REG
        m_lsr8
        lsr             r1,r1,#8
        sta             SPIMASTER+SPI_SD_SECT_31_24_REG
        sta             SPIMASTER+SPI_SD_SECT_31_24_REG
 
 
        ld              r4,#20  ; retry count
        ld              r4,#20  ; retry count
 
 
spi_read_retry:
spi_read_retry:
Line 1328... Line 1428...
        bne             spi_write_sect1
        bne             spi_write_sect1
 
 
        ; set the sector number in the spi master address registers
        ; set the sector number in the spi master address registers
        pla
        pla
        sta             SPIMASTER+SPI_SD_SECT_7_0_REG
        sta             SPIMASTER+SPI_SD_SECT_7_0_REG
        m_lsr8
        lsr             r1,r1,#8
        sta             SPIMASTER+SPI_SD_SECT_15_8_REG
        sta             SPIMASTER+SPI_SD_SECT_15_8_REG
        m_lsr8
        lsr             r1,r1,#8
        sta             SPIMASTER+SPI_SD_SECT_23_16_REG
        sta             SPIMASTER+SPI_SD_SECT_23_16_REG
        m_lsr8
        lsr             r1,r1,#8
        sta             SPIMASTER+SPI_SD_SECT_31_24_REG
        sta             SPIMASTER+SPI_SD_SECT_31_24_REG
 
 
        ; issue the write command
        ; issue the write command
        lda             #RW_WRITE_SD_BLOCK
        lda             #RW_WRITE_SD_BLOCK
        sta             SPIMASTER+SPI_TRANS_TYPE_REG
        sta             SPIMASTER+SPI_TRANS_TYPE_REG
Line 1348... Line 1448...
        nop                                                     ; just a delay between consecutive status reg reads
        nop                                                     ; just a delay between consecutive status reg reads
        nop
        nop
        cmp             #SPI_TRANS_BUSY
        cmp             #SPI_TRANS_BUSY
        beq             spi_write_sect2
        beq             spi_write_sect2
        lda             SPIMASTER+SPI_TRANS_ERROR_REG
        lda             SPIMASTER+SPI_TRANS_ERROR_REG
        lsr
        lsr             r1,r1,#4
        lsr
 
        lsr
 
        lsr
 
        and             #3
        and             #3
        cmp             #SPI_WRITE_NO_ERROR
        cmp             #SPI_WRITE_NO_ERROR
        bne             spi_write_error
        bne             spi_write_error
        lda             #0
        lda             #0
        bra             spi_write_ret
        bra             spi_write_ret
Line 1376... Line 1473...
        phx
        phx
        stz             startSector                                             ; default starting sector
        stz             startSector                                             ; default starting sector
        lda             #0                                                              ; r1 = sector number (#0)
        lda             #0                                                              ; r1 = sector number (#0)
        ldx             #SECTOR_BUF<<2                                  ; r2 = target address (word to byte address)
        ldx             #SECTOR_BUF<<2                                  ; r2 = target address (word to byte address)
        jsr             spi_read_sector
        jsr             spi_read_sector
 
        cmp             #0
 
        bne             spi_rp1
        lb              r1,BYTE_SECTOR_BUF+$1C9
        lb              r1,BYTE_SECTOR_BUF+$1C9
asl
        asl             r1,r1,#8
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
        orb             r1,r1,BYTE_SECTOR_BUF+$1C8
        orb             r1,r1,BYTE_SECTOR_BUF+$1C8
        asl
        asl             r1,r1,#8
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
 
 
        orb             r1,r1,BYTE_SECTOR_BUF+$1C7
        orb             r1,r1,BYTE_SECTOR_BUF+$1C7
asl
        asl             r1,r1,#8
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
        orb             r1,r1,BYTE_SECTOR_BUF+$1C6
        orb             r1,r1,BYTE_SECTOR_BUF+$1C6
        sta             startSector                                             ; r1 = 0, for okay status
        sta             startSector                                             ; r1 = 0, for okay status
 
        plx
        lda             #0
        lda             #0
 
        rts
 
spi_rp1:
        plx
        plx
 
        lda             #1
        rts
        rts
 
 
; Read the boot sector from the disk.
; Read the boot sector from the disk.
; Make sure it's the boot sector by looking for the signature bytes 'EB' and '55AA'.
; Make sure it's the boot sector by looking for the signature bytes 'EB' and '55AA'.
;
;
Line 1451... Line 1532...
; Load the root directory from disk
; Load the root directory from disk
; r2 = where to place root directory in memory
; r2 = where to place root directory in memory
;
;
loadBootFile:
loadBootFile:
        lb              r1,BYTE_SECTOR_BUF+$17                  ; sectors per FAT
        lb              r1,BYTE_SECTOR_BUF+$17                  ; sectors per FAT
        m_asl8
        asl             r1,r1,#8
        orb             r1,r1,BYTE_SECTOR_BUF+$16
        orb             r1,r1,BYTE_SECTOR_BUF+$16
        bne             loadBootFile7
        bne             loadBootFile7
        lb              r1,BYTE_SECTOR_BUF+$27                  ; sectors per FAT, FAT32
        lb              r1,BYTE_SECTOR_BUF+$27                  ; sectors per FAT, FAT32
asl
        asl             r1,r1,#8
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
        orb             r1,r1,BYTE_SECTOR_BUF+$26
        orb             r1,r1,BYTE_SECTOR_BUF+$26
asl
        asl             r1,r1,#8
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
        orb             r1,r1,BYTE_SECTOR_BUF+$25
        orb             r1,r1,BYTE_SECTOR_BUF+$25
asl
        asl             r1,r1,#8
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
        orb             r1,r1,BYTE_SECTOR_BUF+$24
        orb             r1,r1,BYTE_SECTOR_BUF+$24
loadBootFile7:
loadBootFile7:
        lb              r4,BYTE_SECTOR_BUF+$10                  ; number of FATs
        lb              r4,BYTE_SECTOR_BUF+$10                  ; number of FATs
        mul             r3,r1,r4                                                ; offset
        mul             r3,r1,r4                                                ; offset
        lb              r1,BYTE_SECTOR_BUF+$F                   ; r1 = # reserved sectors before FAT
        lb              r1,BYTE_SECTOR_BUF+$F                   ; r1 = # reserved sectors before FAT
asl
        asl             r1,r1,#8
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
asl
 
        orb             r1,r1,BYTE_SECTOR_BUF+$E
        orb             r1,r1,BYTE_SECTOR_BUF+$E
        add             r3,r3,r1                                                ; r3 = root directory sector number
        add             r3,r3,r1                                                ; r3 = root directory sector number
        ld              r6,startSector
        ld              r6,startSector
        add             r5,r3,r6                                                ; r5 = root directory sector number
        add             r5,r3,r6                                                ; r5 = root directory sector number
        lb              r1,BYTE_SECTOR_BUF+$D                   ; sectors per cluster
        lb              r1,BYTE_SECTOR_BUF+$D                   ; sectors per cluster
Line 1558... Line 1611...
; 100 Hz interrupt
; 100 Hz interrupt
; - takes care of "flashing" the cursor
; - takes care of "flashing" the cursor
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;
;
p100Hz:
p100Hz:
 
        inc             IRQFlag                 ; support tiny basic's IRQ rout
        inc             TEXTSCR+83
        inc             TEXTSCR+83
        stz             0xFFDCFFFC              ; clear interrupt
        stz             0xFFDCFFFC              ; clear interrupt
        rti
        rti
 
 
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
Line 1581... Line 1635...
        rti
        rti
nmirout
nmirout
        rti
        rti
message "1298"
message "1298"
include "TinyBasic65002.asm"
include "TinyBasic65002.asm"
 
message "1640"
        org $0FFFFFFF4          ; NMI vector
        org $0FFFFFFF4          ; NMI vector
        dw      nmirout
        dw      nmirout
 
 
        org     $0FFFFFFF8              ; reset vector, native mode
        org     $0FFFFFFF8              ; reset vector, native mode
        dw      start
        dw      start

powered by: WebSVN 2.1.0

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