#
#    Mecrisp-Quintus - A native code Forth implementation for RISC-V
#    Copyright (C) 2018  Matthias Koch
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# -----------------------------------------------------------------------------
# Start with some essential macro definitions
# -----------------------------------------------------------------------------

.set reorder # Assembler takes care of inserting NOPs into the delay slots if the instruction before cannot be swapped with the jump opcode.

.include "../common/mips-v.s"

# -----------------------------------------------------------------------------
# Swiches for capabilities of this chip
# -----------------------------------------------------------------------------

.equ mipscore, 1

# -----------------------------------------------------------------------------
# Speicherkarte für Flash und RAM
# Memory map for Flash and RAM
# -----------------------------------------------------------------------------

# Konstanten für die Größe des Ram-Speichers

.equ RamAnfang, 0xA0000000 # Start of RAM          Porting: Change this !
.equ RamEnde,   0xA0010000 # End   of RAM.  64 kb. Porting: Change this !

# Konstanten für die Größe und Aufteilung des Flash-Speichers

.equ FlashAnfang, 0xBD000000 # Start of Flash          Porting: Change this !
.equ FlashEnde,   0xBD080000 # End   of Flash. 512 kb. Porting: Change this !

.equ Kernschutzadresse,     FlashAnfang + 0x8000 # 32 kb reserved for core.
.equ FlashDictionaryAnfang, FlashAnfang + 0x8000 # 32 kb reserved for core.
.equ FlashDictionaryEnde,   FlashEnde

# -----------------------------------------------------------------------------
# Boot flash area for low-level memory initialisation
# -----------------------------------------------------------------------------

.section .boot, "a"

.globl _start
_start:

  j Reset

# -----------------------------------------------------------------------------
# Core start
# -----------------------------------------------------------------------------

.text

# -----------------------------------------------------------------------------
# Include the Forth core of Mecrisp-Quintus
# -----------------------------------------------------------------------------

.include "../common/forth-core.s"

# -----------------------------------------------------------------------------
Reset: # Forth begins here
# -----------------------------------------------------------------------------

  .include "../common/catchflashpointers.s"

  call uart_init

  welcome " for PIC32MX570F512L by Matthias Koch"

  # Ready to fly !
  .include "../common/boot.s"

