aboutsummaryrefslogtreecommitdiff
path: root/src/instset.c
blob: 94c3df7f5b39d8592e34c6f4764dde1805bdccf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <assert.h>
#include "types.h"
#include "instset.h"

boolean sal_is_inst(uint32 word)
{
	/*
	* Test if a given 32 bit integer contains a valid Salis instruction.
	*/
	return word < INST_COUNT;
}

static boolean is_in_between(uint32 inst, uint32 low, uint32 hi)
{
	/*
	* Test whether a Salis instruction lies within a given range. This is
	* useful for identifying template instructions and/or register modifiers.
	*/
	assert(sal_is_inst(inst));
	assert(sal_is_inst(low));
	assert(sal_is_inst(hi));
	return (inst >= low) && (inst <= hi);
}

boolean sal_is_template(uint32 inst)
{
	/*
	* Test whether a given instruction is a template element (i.e. NOP0 or
	* NOP1).
	*/
	assert(sal_is_inst(inst));
	return is_in_between(inst, NOP0, NOP1);
}

boolean sal_is_mod(uint32 inst)
{
	/*
	* Test whether a given instruction is a register modifier (i.e. MODA, MODB,
	* MODC or MODD).
	*/
	assert(sal_is_inst(inst));
	return is_in_between(inst, MODA, MODD);
}