// SPDX-License-Identifier: Apache-2.0
/*
 * Copyright 2001-2026 Richard Lesh
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define	iPUT_NL				200
#define	iPUT_INT			201
#define	iPUT_DEC			202
#define	iPUT_HEX			203
#define	iPUT_FP				204
#define	iPUTS				205
#define iPUT_LINE			206

#define	iGET_INT			207
#define	iGET_DEC			208
#define	iGET_HEX			209
#define	iGET_FP				210
#define	iGETS				211
#define iGET_LINE			212

#define	iPRINTF				213
#define	iCOND_PRINTF		214

#define	iOPEN_FILE_READ			220
#define	iOPEN_FILE_WRITE		221
#define	iOPEN_FILE_APPEND		222
#define	iOPEN_RAW_FILE_READ		223
#define	iOPEN_RAW_FILE_WRITE	224
#define	iOPEN_RAW_FILE_APPEND	225
#define	iCLOSE_FILE				226
#define	iFLUSH					227
#define	iDELETE_FILE			228
#define	iMAKE_DIR				229
#define	iDELETE_DIR				230
#define	iIS_DIR					231
#define	iIS_FILE				232
#define	iFILE_EXISTS			233
#define	iFILES					234
#define	iTEMP_DIR				235
#define	iTEMP_FILE				236

#define	CHAR	0
#define	BYTE	1
#define	SHORT	2
#define	WORD	4
#define	SINGLE	4
#define	DWORD	8
#define	LONG	8
#define	DOUBLE	8

#define	STDIN	0
#define	STDOUT	1
#define	STDERR	2

#define	READ_MODE	0
#define	WRITE_MODE	1
#define	APPEND_MODE	2

#def_macro	IN0(register,port)
	in	${register}, CHAR, ${port}
#end_macro
#def_macro	IN1(register,port)
	in	${register}, BYTE, ${port}
#end_macro
#def_macro	IN2(register,port)
	in	${register}, SHORT, ${port}
#end_macro
#def_macro	IN4(register,port)
	in	${register}, WORD, ${port}
#end_macro
#def_macro	IN8(register,port)
	in	${register}, LONG, ${port}
#end_macro

#def_macro	OUT0(register, port)
	out		${register}, CHAR, ${port}
#end_macro
#def_macro	OUT1(register, port)
	out		${register}, BYTE, ${port}
#end_macro
#def_macro	OUT2(register, port)
	out		${register}, SHORT, ${port}
#end_macro
#def_macro	OUT4(register, port)
	out		${register}, WORD, ${port}
#end_macro
#def_macro	OUT8(register, port)
	out		${register}, LONG, ${port}
#end_macro

#def_macro	PUT_NL()
	move	r1, STDOUT
	int		iPUT_NL
#end_macro

#def_macro	PUTS(str)
	move	r2, ${str}
	move	r1, STDOUT
	int		iPUTS
#end_macro

#def_macro  PUT_INT(val, base)
	move	r2, ${val}
	move	r3, ${base}
	move	r1, STDOUT
	int		iPUT_INT
#end_macro

#def_macro  PUT_DEC(val)
	move	r2, ${val}
	move	r1, STDOUT
	int		iPUT_DEC
#end_macro

#def_macro  PUT_HEX(val)
	move	r2, ${val}
	move	r1, STDOUT
	int		iPUT_HEX
#end_macro

#def_macro  PUT_FP(val, prec)
	move	f1, ${val}
	move	r1, STDOUT
	move	r2, ${prec}
	int		iPUT_FP
#end_macro
