;
; This is an example STARTUP file.
; @(#)cstart.a96	1.5
;
STARTUP MODULE  CMAIN

        RSEG
SP	EQU	018H:WORD

      cseg at 0C000H
;  ------------------------
; Interrupt service routine addresses to be used in RISM EPROM.
; Note:
;  Of all these interrupt vectors, only the SERIAL, NMI and TRAP vectors are 
;  required for operation of the RISM.  The other vectors are provided as 
;  fixed entry points for routines which may be loaded into RAM in the 
;  diagnostic mode.
;  In the diagnostic mode memory at the interrupt vectors is mapped to EPROM
;  so it is not possible to write into the vector table.

	EXTRN	main:NULL
	EXTRN	RSIExtInt:NULL
	EXTRN	RSITimer2:NULL
	EXTRN	RSI_Hsi:NULL

cstart:
	PUBLIC	cstart

	DI
	LD	SP,#100H	; pila al final variables 
	EI


; Some applications might want to do a CALL to main,
; and also have exit() calls.
; In that case enable the following:

	LCALL	main

_exit:
	PUBLIC	_exit
exit:
	PUBLIC	exit
_cstop:
	PUBLIC	_cstop		; public for debuggers to set a breakpoint
	BR	_cstop			; keep on looping

EXTINT:
	PUSHA
	LCALL	RSIExtInt
	POPA
	RET

HSIINT:
  PUSHA
  LCALL   RSI_Hsi
  POPA
  RET
				
TIMER2_OVF:
  PUSHA
  LCALL   RSITimer2
  POPA
  RET

;; Button (INT7)
cseg at 0d0e0h
   br EXTINT

;; Interrupcio de "Data available" del HSI (INT2)
cseg at 0d040h
   br HSIINT

;; InterrupciĆ³ de "Timer 2 Overflow" (INT12)
cseg at 0d180h
   br TIMER2_OVF

END