// Atari TOS definitions
// Copyright (C) Florian Negele

// This file is part of the Eigen Compiler Suite.

// The ECS 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.

// The ECS 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.

// Under Section 7 of the GNU General Public License version 3,
// the copyright holder grants you additional permissions to use
// this file as described in the ECS Runtime Support Exception.

// You should have received a copy of the GNU General Public License
// and a copy of the ECS Runtime Support Exception along with
// the ECS.  If not, see <https://www.gnu.org/licenses/>.

#ifndef ECS_DEF_TOS_HEADER_INCLUDED
#define ECS_DEF_TOS_HEADER_INCLUDED

#include "assembly"

#define SYSTEM_CALL(name, number, vector) \
	asm (CODE (name) SHARED INSTR (movea.l (sp)+, a3) INSTR (move.w number, -(sp)) INSTR (trap vector) INSTR (addq.l 2, sp) INSTR (movea.l d0, a0) INSTR (jmp (a3)));

#define GEMDOS(name, number) SYSTEM_CALL (name, number, 1)
#define BIOS(name, number) SYSTEM_CALL (name, number, 13)
#define XBIOS(name, number) SYSTEM_CALL (name, number, 14)

#endif // ECS_DEF_TOS_HEADER_INCLUDED
