summaryrefslogtreecommitdiff
path: root/base-isa.ms
blob: 6ec951332516db78b5a02a7149e5dcf8060aa8c1 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
.\" Start of the Base ISA.
.NH
.XN The Sux Base Instruction Set, Version 1.0
.LP
This chapter describes version 1.0 of the Sux base instruction set.
.bp +1
.\" Start of the programmers' model.
.NH 2
.XN Programmers' Model for the Base ISA
.LP
Figure 2 Shows the state for the base ISA. The base ISA only has
four registers, each of which are 64 bits in size, each register
has a special property, but can be still be used like general
purpose registers.
.LP
The accumulator, or A is the main register of the base ISA,
and is used for all ALU based instructions. the B register
is a secondary ALU register, and can be used in place of a
memory address for all ALU instructions, the X register is
a register that can be used for indexing, but has a special
property, as it is the only register that can set the stack
pointer, and finally, the Y register, like the X register
can be used for indexing, both normal, and pointer based.
.begin dformat
style bitwid .04
style recht .1618033
style recspread 0
noname
	63-0-64 A
noname
	63-0-64 B
noname
	63-0-64 X
noname
	63-0-64 Y
.end
.ce
Figure 2: Sux base register state.
.\" End of the programmers' model.
.
.bp +1
.\" Start of instruction format.
.NH 2
.XN Base Instruction Format
.LP
The base Sux ISA has variable length instructions ranging
from a single byte, to as many as 10 bytes, and are always
byte aligned. The base ISA is also little endian, with no
possiblity for bi-endian setups.
.LP
The reasoning for why we chose little endian, was because it
is much simpler to work with, plus, it is very easy to understand,
and is very intuitive.
.LP
The high code density is achived by using a prefix byte,
which is not part of the instruction, but rather tells
the CPU extra information like, how many bytes to read/write,
whether it should use 8/16 bit addresses, or 32/64 bit addresses,
or what instruction set extension it should use.
.LP
The base ISA is made up of 198 total opcodes, comprised of
93 instructions. All of the opcodes are one byte in length.
The max operand count for the base ISA is one. These might
look like typos, but all of them were done on purpose, both
in order to make the base ISA easier to understand, and to
keep the opcode length at one byte.
.LP
The instruction formatting for the Sux base ISA is shown in Figure 2.1.
.begin dformat
style bitwid .08
style recht .3
style recspread 0
noname
	71-40-32 opr[63:32]
	39-24-16 opr[31:16]
	23-16-8 opr[15:8]
	15-8-8 opr[7:0]
	7-0-8 opcode
	7-0-8-dashed prefix
.end
Figure 2.1: Sux base instruction format. There are subfields
for the operand because the prefix byte can specify the size
of the operand, from 8 bits, all the way up to 64 bits.
.LP
The processor status register, is a register that contains
flags for use with conditional branches, Figure 2.2 shows
the layout of these flags, the processor status register
is 64 bits in size, but only eight bits are used, this is
so that we can have upto eight sets of these flags, and
make conditional branching with threads, much easier.
.LP
The Carry flag, or C denotes when a register has carried over.
The Zero flag, or Z denotes when a register is zero.
The Interrupt flag, or I is used to disable/enable
maskable interrupts, when set, it disables interrupts,
when cleared, it enables interrupts.
The Stack protection flag, or S is used to prevent stack
overflows, and stack underflows, by not incrementing, or
decrementing if the stack pointer is at it's lowest value,
or it's highest value.
The Overflow flag, or V denotes whenever an overflow of a
register occurs.
And the Negative flag, or N is used to denote a negative
value, and allows the use of signed integers.
.begin dformat
style bitwid .5
style recspread 0
noname
	7-7-1 N
	6-6-1 V
	--1
	--1
	3-3-1 S
	2-2-1 I
	1-1-1 Z
	0-0-1 C
.end
.ce
Figure 2.2: The flags of the Processor status register.
.\" End of instruction format
.
.bp +1
.\" Start of instruction opcodes.
.NH 2
.XN Base Instruction Opcodes
.LP
This section describes each of the instructions, for the Sux base
ISA, and provides a table, listing the opcodes for every instruction.
.so base-op-table.ms
.bp +1
.so base-op-desc.ms
.\" End of instruction opcodes.
.
.bp +1
.\" Start of the prefix byte.
.NH 2
.XN The Prefix Byte
.LP
As mentioned before, there is a prefix byte. The prefix byte
is a byte that occurs before the opcode, and gives the CPU
more control over things like, the number of bytes that it will
read/write, switching between 8/16 bit addressing, and 32/64 bit
addressing, and switching between different instruction set extensions.
.LP
Figure 2.3 shows the layout of the prefix byte.
.br
Table 2 explains what the prefix bits do.
.begin dformat
style bitwid .5
style recspread 0
noname
	7-7-1 EX1
	6-6-1 EX0
	5-5-1 RS1
	4-4-1 RS0
	3-3-1 AM
	2-2-1 1
	1-1-1 1
	0-0-1 1
.end
.ce
Figure 2.3: The control bits of the prefix byte.

.ce
Table 2. Description of the prefix bits
.TS
center tab(;) allbox;
lb lb
l l
l l
lb lb
l l
l l
l l
l l
lb lb
l l
l l
l l
l l.
AM;Addressing Modes
0;Normal Addressing Modes (8/16 bit)
1;Extended Addressing Modes (32/64 bit)
RS1/RS0;Register Size
0/0;8 bit register
0/1;16 bit register
1/0;32 bit register
1/1;64 bit register
EX1/EX0;Extension Selection
0/0;Base ISA
0/1;GFsuX Graphics Oriented Extension
1/0;Unused
1/1;\[*m]DCROM
.TE

.LP
If no prefix byte is found, then it treats that byte as an
opcode, and acts as if it had a prefix byte, with all the
prefix bits set to 0.
.\" End of the prefix byte.
.
.bp +1
.\" Start of assembly syntax.
.NH 2
.XN Assembly Language Syntax for the Sux Base ISA
.LP
The syntax of Sux assembly, was designed to be simple,
and very easy to understand. The syntax looks like this.
.ce
ADC.W #$1000
This is what it means.
.TS
tab(;) allbox;
lb l.
ADC;Instruction
\.W;Register Size Suffix
#$1000;Operand
.TE
.LP
For the Register Size Suffixes, there are four options.
.TS
tab(;) allbox;
lb l.
None;One byte (8 bits)
\.W/\.2;Two bytes (16 bits)
\.D/\.4;Four bytes (32 bits)
\.Q/\.8;Eight bytes (64 bits)
.TE
.LP
These Suffixes control the prefix byte. If there is no suffix,
then it will not place a prefix byte, saving a byte.
.LP
The operand can be a few things.
.TS
tab(;) allbox;
lb lb
l l.
Syntax;Description
Value;Decimal Address
$<Value>;Hexadecimal Address
%<Value>;Binary Address
#[token]<Value>;Immediate Data Value
[token]<Value>, <X/Y>;Zero Matrix, Indexed with X, or Y
([token]<Value>);Indirect Addressing
([token]<Value>, X);Indexed Indirect Addressing
([token]<Value>), Y;Indirect Indexed Addressing
.TE
.\" End of assembly syntax.
.
.bp +1
.\" Start of the MicroDeCodeROM.
.NH 2
.XN The \[*m]DCROM
.LP
The \[*m]DCROM is a type of Programmable Logic Array (PLA) that has each of it's interconnects
connected to an SRAM bit. This SRAM can then be accessed just like any other part of memory,
and as such, is fully reprogrammable by the user.
.LP
The starting location of the \[*m]DCROM, is value located at the \[*m]DCROM vector.
.LP
The byte before the start of the \[*m]DCROM is the control byte, which is used
to specify how the \[*m]DCROM should be accessed.
.\" End of the MicroDeCodeROM.
.\" End of the Base ISA.